[FrameworkBundle] Ensure a fresh container is used after cache warmup in KernelTestCase#63016
Merged
Merged
Conversation
ad8172a to
76acd37
Compare
joelwurtz
reviewed
Jan 8, 2026
KernelTestCase
… in KernelTestCase When the cache is empty, and a test starts, it will compile the container, and warm up the cache. However, this means that the container used during the test is not fresh anymore, as it has been compiled with the cache warmer service registered. This change ensures that if the cache warmer is detected in the container after booting, a new kernel is booted to provide a fresh container for the test.
76acd37 to
2af5e9c
Compare
nicolas-grekas
approved these changes
Jan 12, 2026
Member
|
Thank you @lyrixx. |
This was referenced Jan 24, 2026
Merged
Merged
Merged
Merged
nicolas-grekas
added a commit
that referenced
this pull request
Mar 4, 2026
…elTestCase (nicolas-grekas) This PR was merged into the 6.4 branch. Discussion ---------- [FrameworkBundle] Fix stale container after reboot in KernelTestCase | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #63519 | License | MIT The reboot logic added in #63016 to get a fresh container after cache warmup populates two static freshness caches: `Kernel::$freshCache` and `SelfCheckingResourceChecker::$cache`. These caches persist across `shutdown()`/`boot()` cycles within the same PHP process, preventing subsequent boots from detecting resource changes (e.g. `FileExistenceResource`). This causes `ensureKernelShutdown()` + `bootKernel()` to reuse a stale container even when tracked resources have changed between boots. The fix clears both static caches via reflection in `ensureKernelShutdown()` when a cache warmer reboot has occurred. The clearing is guarded by a flag to avoid unnecessary reset on every shutdown, and wrapped in try/catch to be forward-compatible with future refactoring of these internals. Commits ------- c9f0161 [FrameworkBundle] Fix stale container after reboot in KernelTestCase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the cache is empty, and a test starts, it will compile the container, and
warm up the cache. However, this means that the container used during the test
is not fresh anymore, as it has been compiled with the cache warmer service
registered. This change ensures that if the cache warmer is detected in the
container after booting, a new kernel is booted to provide a fresh container for
the test.