Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 922b946

Browse files
committed
bug #16609 [HttpKernel] Don't reset on shutdown but in FrameworkBundle/Test/KernelTestCase (nicolas-grekas)
This PR was merged into the 2.8 branch. Discussion ---------- [HttpKernel] Don't reset on shutdown but in FrameworkBundle/Test/KernelTestCase | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15185 | License | MIT | Doc PR | - While trying to migrate Blackfire to 2.8-beta, I found this BC-break: by resetting the container on kernel shut-down, functional tests are broken when they need to use the container after a call to `$this->client->request()`. Broken because e.g . the session or the profiler state is lost between consecutive requests in the same test, and because a call to $container->get('kernel') throws a synthetic-related exception. This PR fixes the BC-break by reverting to the <=2.7 behavior (not resetting the container on kernel shut-down), and moving resetting to the KernelTestCase. Commits ------- baad4da [HttpKernel] Don't reset on shutdown but in FrameworkBundle/Test/KernelTestCase
2 parents 43d82e7 + baad4da commit 922b946

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Test;
1313

14+
use Symfony\Component\DependencyInjection\ResettableContainerInterface;
1415
use Symfony\Component\Finder\Finder;
1516
use Symfony\Component\HttpKernel\KernelInterface;
1617

@@ -171,7 +172,11 @@ protected static function createKernel(array $options = array())
171172
protected static function ensureKernelShutdown()
172173
{
173174
if (null !== static::$kernel) {
175+
$container = static::$kernel->getContainer();
174176
static::$kernel->shutdown();
177+
if ($container instanceof ResettableContainerInterface) {
178+
$container->reset();
179+
}
175180
}
176181
}
177182

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
2424
use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
2525
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
26-
use Symfony\Component\DependencyInjection\ResettableContainerInterface;
2726
use Symfony\Component\HttpFoundation\Request;
2827
use Symfony\Component\HttpFoundation\Response;
2928
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
@@ -171,10 +170,6 @@ public function shutdown()
171170
$bundle->setContainer(null);
172171
}
173172

174-
if ($this->container instanceof ResettableContainerInterface) {
175-
$this->container->reset();
176-
}
177-
178173
$this->container = null;
179174
}
180175

0 commit comments

Comments
 (0)