diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php index 440c4762a95e9..ea8931f2361d1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php @@ -38,8 +38,10 @@ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilde if ($this->containerBuilder) { return $this->containerBuilder; } + $container = $kernel->getContainer(); + $containerDump = $container->hasParameter('debug.container.dump') ? $container->getParameter('debug.container.dump') : null; - if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) { + if (null === $containerDump || !(new ConfigCache($containerDump, $kernel->isDebug()))->isFresh()) { $buildContainer = \Closure::bind(function () { $this->initializeBundles(); @@ -50,7 +52,7 @@ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilde $container->getCompilerPassConfig()->setAfterRemovingPasses([]); $container->compile(); } else { - (new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump')); + (new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($containerDump); $locatorPass = new ServiceLocatorTagPass(); $locatorPass->process($container); } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 645d45a38b4d7..63fb6d642fec3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -938,9 +938,7 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con $debug = $container->getParameter('kernel.debug'); - if ($debug) { - $container->setParameter('debug.container.dump', '%kernel.build_dir%/%kernel.container_class%.xml'); - } + $container->setParameter('debug.container.dump', '%kernel.build_dir%/%kernel.container_class%.xml'); if ($debug && class_exists(Stopwatch::class)) { $loader->load('debug.php'); diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index 7f439bb572f87..ae48a84788b91 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -160,11 +160,11 @@ public function build(ContainerBuilder $container) $container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING); $container->addCompilerPass(new RemoveUnusedSessionMarshallingHandlerPass()); $container->addCompilerPass(new SessionPass()); + $container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_BEFORE_REMOVING, -255); if ($container->getParameter('kernel.debug')) { $container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2); $container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING); - $container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_BEFORE_REMOVING, -255); $container->addCompilerPass(new CacheCollectorPass(), PassConfig::TYPE_BEFORE_REMOVING); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 3df35509237c9..4758d0d17dfa0 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -382,6 +382,7 @@ public function testRememberMeCookieInheritFrameworkSessionCookie($config, $same $container->registerExtension(new FrameworkExtension()); $container->setParameter('kernel.bundles_metadata', []); $container->setParameter('kernel.project_dir', __DIR__); + $container->setParameter('kernel.build_dir', __DIR__); $container->setParameter('kernel.cache_dir', __DIR__); $container->setParameter('kernel.container_class', 'FooContainer');