Search code examples
debuggingtwigshopware6

Difference in Twig Rendering between Local <-> Staging


We have a problem on a staging system which the same code, same composer.lock, composer install done, cache flushed.

I even activated FroshDevelopmentHelper on Staging and set it to ENV=dev to be able to see more debugging infos.

On Staging:

<!-- BLOCK BEGIN base_body_inner (custom/plugins/OurTheme/src/Resources/views/storefront/base.html.twig) -->

On Local (there the feature works):

<!-- BLOCK BEGIN base_body_inner (vendor/store.shopware.com/moorlfoundation/src/Resources/views/storefront/base.html.twig) 

We also ensure a consistent plugin loading order by setting the installed_at, but that is also the same order on both system

The database was also copied from Staging (just base URL changed after the local import) + rebuilt storefront and admin.

Does anybody have a pointer what else could influcence the loading order or cause such a problem?

EDIT:

I added some debug code here:

vi vendor/shopware/core/Framework/Adapter/Twig/NamespaceHierarchy/BundleHierarchyBuilder.php +52

asort($extensions);
dd($extensions);  # added

This gives me different results on both systems.

Before Shopware loaded the templates according to installation date - now the TemplatePriority is used, which is in most cases 0, so my theory is, that a kind of chaotic order is constructed, if the TemplatePriority is not set anyhwere.


Solution

  • I am pretty sure, this new feature is the reason:

    Since 6.4.13.0 it is possible to set the load order of templates using the template priority. This was a shortcomming for a while and we are very happy about this fix.

    Unfortunately it breaks our workflow, where we currently hard-code the plugin installed_at date and assumed that the templates are loaded in a certain way.

    XKCD Comic about breaking a workflow by a fix

    Follow up: Set template priority for 3rd party plugins

    See also: https://issues.shopware.com/issues/NEXT-23822