-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBundle] Fixed caching of templates in src/Resources/<BundleName>/views on cache warmup #28376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This iterator suffers from tachycardia having to duplicate the paths registration and convention :) Note that we're still missing custom paths registered in a third party bundles through $container->getDefinition('twig.loader.native_filesystem')
->addMethodCall('addPath', array('/foo/templates/path', 'Foo')); The templates inside it, will not be cached on cache warmup. I wondering if can we iterate over the Twig loader filesystem instead? |
We should recommend third-party bundles to add their paths through adding them in the bundle config (with PrependExtensionInterface on their DI extension). Adding paths directly on the filesystem loader is quite fragile, because Symfony is injecting the paths in multiple places, and |
I've a use case where that recommendation wouldn't work. For example: a shared third-party bundle aiming to override templates (company design & themes standardization) from others third-party bundles ( This shared bundle will work for our 4.0+ projects only (without Therefore, reading method calls added on this services ( This shared bundle would also define a new
I think it is possible to detect that situation and inject the right loader, as well as the method calls are copied during this transition: symfony/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php Line 110 in ef1f7ff
Still I think that the current logic behind this iterator is quite fragile too and prone to errors, by using the Twig loader we can remove all this logic and rely only on the registered paths. Thus, removing the need to keep updated the iterator This is just an idea, meanwhile we can merge this as it is. |
but your own compiler pass might be running *after that transition. That's precisely why I'm saying it is fragile to do it |
Can't I use (in my own compiler pass) the About the |
e53c98a
to
83a75f4
Compare
This is ready on my side. I'll move the discussion about the |
Could be seen as a BC break. I would only do the change in master with a note in the UPGRADE file. WDYT? |
Are you referring to the proposal "iterate over the Twig loader filesystem instead"? I agree, I'll do it soon. However, we still have to fix this bug on |
I was referring to the current patch. People might have stored their templates in the current supported directory |
AFAIK this path |
Even if ppl registering it (manually in Twig This fix the cache warmup of the overriding convention templates in
|
Thank you @yceruto. |
…BundleName>/views on cache warmup (yceruto) This PR was merged into the 2.8 branch. Discussion ---------- [TwigBundle] Fixed caching of templates in src/Resources/<BundleName>/views on cache warmup | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Same as #27764, but in this case the convention is wrong. Corrected according to: https://github.com/symfony/symfony/blob/992a174470fd557e1cddccd3a35447209602aea3/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php#L165 Commits ------- 83a75f4 Caching missed templates on cache warmup
Same as #27764, but in this case the convention is wrong.
Corrected according to:
symfony/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
Line 165 in 992a174