-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBundle][FrameworkBundle] Fixed that Twig cache warmer is not being added as cache warmer #15034
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
…ng added as cache warmer PassConfig::TYPE_OPTIMIZE argument added to 'addCompilerPass' method call when adding the AddCacheWarmerPass to the container
Can you add a test to avoid any future regression? |
…ng added as cache warmer Test added to avoid any future regression
4af0aac
to
19e8c29
Compare
@fabpot Just added a test to avoid any future regression. I doubted a little bit about where I should add this test, because the fix is applied on the |
…ng added as cache warmer * Removed the previous committed TemplateCacheCacheWarmerTest from the TwigBundle * Added a generic CacheWarmerTest to the FrameworkBundle
After investigating what causes the Travis CI build to fail I realized that the test I added is never going to pass when the I hope I did everything as it should be. If not, please comment! :-) |
there is an issue. This compiler pass should still run before the optimization passes, otherwise it could break optimizations (if you have circular references between your cache warmer and the CacheWarmerAggregate, they won't be detected anymore for instance because the circular reference will be created only after the validation. and there might be other broken cases). So -1 for the current patch. IMO, what is needed is a way to set a priority between all compiler passes running before optimizations (because almost every compiler pass provided by bundles must actually run before optimizing the container) |
What would actually happen when added the |
{ | ||
return true; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing newline
Closing for the reasons explained by @stof |
This PR was merged into the 2.7 branch. Discussion ---------- [TwigBundle] Fix Twig cache is not properly warmed | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15982 | License | MIT | Doc PR | - Alternative to #15034 Commits ------- e704ee4 [TwigBundle] Fix Twig cache is not properly warmed
Description
Since version 2.7 the Twig cache warmer is not being triggered during a
app/console cache:warmup
. The bug is introduced with commit 0d537c4 where the tagkernel.cache_warmer
is removed from the service definitiontwig.cache_warmer
and is added dynamically by theExtensionPass
.The problem lies in the fact that the
AddCacheWarmerPass
of theFrameworkBundle
has already been processed on the moment theExtensionPass
adds the tag to thetwig.cache_warmer
service. Therefore thetwig.cache_warmer
is not being picked up by theAddCacheWarmerPass
and will not be used during anapp/console cache:warmup
.To verify my hypothesis I made a small change in
AppKernel
and placedTwigBundle
aboveFrameworkBundle
, to force a different processing order of compiler passes and that fixed the problem.Steps to reproduce
symfony new test
app/console cache:warmup
Notice that the directory
app/cache/dev/twig
doesn't exists.Solution
My suggested fix is small but effective and consists of adding the argument
PassConfig::TYPE_OPTIMIZE
to theaddCompilerPass
method call when adding theAddCacheWarmerPass
to the container. This ensures that other bundles were able to add tags to there service definitions, regarding cache warmers, before theAddCacheWarmerPass
is being called.