Skip to content

Commit 25c5f9c

Browse files
committed
bug symfony#58327 [FrameworkBundle] Do not access the container when the kernel is shut down (jderusse)
This PR was merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Do not access the container when the kernel is shut down | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT symfony#58240 play with the container after the kernel was shut down. This is an issue when the kernel performs a cleanup operation. For instance, the `@Nyholm` TestBundle [deletes cache files](https://github.com/SymfonyTest/symfony-bundle-test/blob/241bf0e2f00f28f7327113570ab20e24a5828829/src/TestKernel.php#L184-L199) as a result, the service is not accessible anymore and triggers errors. This PR move the call to `container->get` before `kernel::shutdown` Commits ------- e68f88c [FrameworkBundle] Do not access the container when the kernel is shut down
2 parents 6687e4e + e68f88c commit 25c5f9c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,15 @@ protected static function ensureKernelShutdown()
157157
if (null !== static::$kernel) {
158158
static::$kernel->boot();
159159
$container = static::$kernel->getContainer();
160-
static::$kernel->shutdown();
161-
static::$booted = false;
162160

163161
if ($container->has('services_resetter')) {
164162
// Instantiate the service because Container::reset() only resets services that have been used
165163
$container->get('services_resetter');
166164
}
167165

166+
static::$kernel->shutdown();
167+
static::$booted = false;
168+
168169
if ($container instanceof ResetInterface) {
169170
$container->reset();
170171
}

0 commit comments

Comments
 (0)