-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] enabling cache-reloading when cache file is rebuilt #20065
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 allows the cache file to be deleted and thus rebuilt between Container builds in WebTestCase scenario, to enable testing of multiple configurations of the same application through WebTestCase.
In fact, the CacheWarming test that fails here is misleading; In master, the two test cases, This PR effectively re-generates classes that are 'not fresh' while ditching the logic behind This makes for a much more powerful testing suite, being able to test a Container with a config that changes between test cases. |
This test fails if run before the previous test, so is actually dependent on the current execution history.
…che file When generating multiple versions of the same container class, each new class name is suffixed with an incrementing version number, as you can't re-use class names. So when we load the class file, the class itself may have a different name than the file name suggests - so after we load the class file, we have to find the class name.
@fabpot @jakzal @nicolas-grekas - can someone please nudge |
thanks for reporting this @stampycode ! |
…ucksaun) This PR was merged into the 2.7 branch. Discussion ---------- [TwigBundle] Fix CacheWarmingTest are order dependent | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Fix issue reported in #20065 Commits ------- fcd6ec2 [TwigBundle] Fix CacheWarmingTest are order dependent
…rmer introduced in 2.8 (tucksaun) This PR was merged into the 2.8 branch. Discussion ---------- [TwigBundle] Adjust CacheWarmingTest for TemplateCacheWarmer introduced in 2.8 | 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 | - With #20103, issue reported in #20065 is fixed, however it will now break in 2.8+ as another cache warmer has been introduced with #16271. Commits ------- 360ca48 [TwigBundle] Adjust CacheWarmingTest for TemplateCacheWarmer introduced in 2.8
@stampycode problem with this PR in my view is that it introduces quite a lot of code (that could potentially break other people's code) for what I see as an edge case. |
@jakzal Surely any change to the Kernel could potentially break other people's code if other people are toying with the Kernel? In my mind this PR is fixing a bug - you can put debug statements in the parameters.php file and see that the file is being reloaded, but there is no indication that the cache file is not being reloaded when the file is re-generated. It's not a core deliverable of Symfony to silently block the re-loading of that cache file in a single execution, such as during PHPUnit tests. It may break people's code if they are depending on this bug existing, but that doesn't sound like a good argument to not fix it. And this would make PHPUnit and WebTestCase much more powerful. |
Loading the kernel class that changes during the request is not a supported use case (this doesn't happen in real life). I think this PR is a wrong solution to the problem since it introduces code in a production class that would only be there for tests. |
symfony/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php
Line 34 in f29d46f
Allows the cache file to be deleted, rebuilt & reloaded between Container builds in WebTestCase scenario, to enable testing of multiple configurations of the same application through WebTestCase.
Will only reload the cache file when in debug mode and the cache class file is deleted.