Skip to content

[5.6]: Problems with Singel Entries witch are used as globals #16474

@alexanderbuergin

Description

@alexanderbuergin

What happened?

Description

After updating to Craft CMS 5.6, we noticed an issue where Single Entries used as Global are no longer available as expected within included templates. This issue was not present in Craft 5.5.

Here’s an example from our code:

<div class="logo item">
    <a class="logo" href="{{ siteUrl }}" title="{{ gloSeo.seoSiteName }}">
        {{ svg('@webroot/a/i/logo/logo' ~ logoStyle ~ '.svg') }}
    </a>
</div>

After the update, the following error is thrown:

Twig\Error\RuntimeError: Variable "gloSeo" does not exist. in /path/to/templates/_includes/_baseParts/mainTopbar.twig:28

Additional Information:

• The issue occurs when these variables are used in templates included via mechanisms like {% include %}.
• Before updating to Craft 5.6, these variables were accessible without any problems.
• It seems that the global availability of Single Entries has been restricted by the update.

Steps to Reproduce:

  1. Create a Single Entry and use it as a global variable (e.g., for SEO information).
  2. Include this variable in a template that is embedded in a main template (e.g., using {% include %}).
  3. Try accessing the variable (e.g., {{ gloSeo.seoSiteName }}).
  4. After updating to Craft 5.6, the error occurs.

Expected Behavior:

Global variables defined by Single Entries should remain accessible in all templates, as they were in Craft 5.5.

Craft CMS version

5.6

PHP version

8.3

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions