-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel][FrameworkBundle] Add RebootableInterface, fix and un-deprecate cache:clear with warmup #23792
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
7a2f817
to
f25709d
Compare
} else { | ||
$realKernel->reboot($warmupDir); | ||
|
||
if (!$isRebootable = $realKernel->getCacheDir() === $realCacheDir) { |
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.
Should be:
- if (!$isRebootable = $realKernel->getCacheDir() === $realCacheDir) {
+ if (!$isRebootable = $realKernel->getCacheDir() !== $realCacheDir) {
right?
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.
comments addressed thanks
f25709d
to
2f023ba
Compare
81671eb
to
f8adb38
Compare
rebased and ready |
It's hard to review PRs without description (even if the long title explains a bit what this PR does). For this and every other PR I'd like to have two brief descriptions:
Thanks! |
f8adb38
to
13823e0
Compare
cache:clear[ --no-warmup]
with new RebootableInterface9ec551a
to
a600b3d
Compare
a600b3d
to
f2d2e05
Compare
@nicolas-grekas does it fixes #8500 also? |
@Koc looks like so, but only you can confirm :) |
does no new instance of |
That's correct, it reuses (reboots) the same instance. |
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.
should removals in UPGRADE and CHANGELOG files be reverted (already removed in #23825)?
* | ||
* @author Nicolas Grekas <p@tchwork.com> | ||
*/ | ||
interface RebootableInterface |
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.
Should this interface be merged into HttpKernel
for 4.0? It seems a lot of stuff will rely on the reboot()
method with this PR, maybe there's no sense to keep it in a separate interface and still require kernels to implement it?
(note that my comment would apply specifically for 4.0, not 3.x)
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.
Clearly not in HttpKernel, as only Kernel implements it, not HttpKernel.
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.
Yep my bad, Kernel
!
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.
But the method is used only in the cache:clear command, not sure that accounts for "a lot" :)
f2d2e05
to
c200b89
Compare
UPGRADE-3.4.md
Outdated
{ | ||
public function getCacheDir() | ||
{ | ||
return $this->getWarmupDir() ?: 'my-cache-dir'; |
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.
I don't like the fact that an implementation detail leaks (getWarmupDir()
is really an internal detail). I would prefer to not change this method at all. getCacheDir()
is public because it's part of HttpKernelInterface
to provide an easy way to override the cache dir in the project's kernel. It was never meant to be called directly, and most devs probably use kernel.cache_dir
anyway.
Instead, we could add a phpdoc warning explaining what I've just written :)
…clear with warmup (fabpot)" (nicolas-grekas) This PR was merged into the 3.3 branch. Discussion ---------- Revert "feature #21038 [FrameworkBundle] deprecated cache:clear with warmup (fabpot)" This reverts commit 3495b35, reversing changes made to 7f7b897. | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21038 | License | MIT | Doc PR | - Sibling to #23792: there is no need to trigger the deprecation in 3.3 if we un-deprecate in 3.4. Commits ------- 9009970 Revert "feature #21038 [FrameworkBundle] deprecated cache:clear with warmup (fabpot)"
22c419d
to
1f08478
Compare
getWarmupDir is now gone, comments updated |
3ae675f
to
14b08ec
Compare
@@ -786,9 +799,6 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container | |||
@chmod($dir.$file, 0666 & ~umask()); | |||
} | |||
|
|||
// track changes made to the container directory | |||
$container->fileExists(dirname($dir.$file)); |
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.
Removes a transient test (CacheClearCommandTest::testCacheIsFreshAfterCacheClearedWithWarmup: Meta file "FixtureTestDebugProjectContainer.php.meta" is not fresh
)
and allows debugging the container by patching its generated files when needed (I added this code in 3.4. A bad idea.)
If you mess up with the container files, that's your problem :)
namespace Symfony\Component\HttpKernel; | ||
|
||
/** | ||
* Rebotable extends the Kernel to allow it to reboot using a temporary cache directory. |
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.
typo Rebootable
. Anway, I would say Allows the Kernel to be rebooted using ...
* | ||
* @param string|null $warmupDir | ||
*/ | ||
public function reboot($warmupDir); |
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.
What's the use case for passing null
?
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.
-
* @param string|null $warmupDir pass `null` to reboot to the regular cache dir
302592c
to
03e6ef6
Compare
* The getCacheDir() method of a rebootable kernel should not be called | ||
* while building the container. Use the %kernel.cache_dir% parameter instead. | ||
* | ||
* @param string|null $warmupDir pass `null` to reboot to the regular cache dir |
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.
null without ```
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.
to reboot in the regular cache dir?
…recate cache:clear with warmup
03e6ef6
to
a4fc492
Compare
Thank you @nicolas-grekas. |
… fix and un-deprecate cache:clear with warmup (nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel][FrameworkBundle] Add RebootableInterface, fix and un-deprecate cache:clear with warmup | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #23592, #8500 | License | MIT | Doc PR | - This PR fixes the reasons why we deprecated cache:clear without --no-warmup. Internally, it requires some cooperation from the Kernel, so that a deprecation is needed. This allows the same kernel instance to be rebooted under a new cache directory, used during the warmup. It leverages the new capability to create two independent non colliding containers. Commits ------- a4fc492 [HttpKernel][FrameworkBundle] Add RebootableInterface, fix and un-deprecate cache:clear with warmup
Thank you for this @nicolas-grekas! I think this blog post could be updated mentioning |
Good idea, ping @javiereguiluz |
The original (and outdated) 3.3 news is still the first to see on google - and kind of very easy to miss the very important notice about the un-deprecation. Could it be a bit more visible? I'd write there, but comments are closed. |
@amici I agree with you. Instead of making the warning more visible ... we've decided to remove the original blog post content. See https://symfony.com/blog/new-in-symfony-3-3-deprecated-cache-clear-with-warmup Thanks! |
This PR fixes the reasons why we deprecated cache:clear without --no-warmup.
Internally, it requires some cooperation from the Kernel, so that a deprecation is needed.
This allows the same kernel instance to be rebooted under a new cache directory, used during the warmup.
It leverages the new capability to create two independent non colliding containers.