Skip to content

Commit f0c6c79

Browse files
bug #62586 [DependencyInjection][FrameworkBundle] fix BC break when dumping container for build/lint commands (aschempp)
This PR was squashed before being merged into the 7.4 branch. Discussion ---------- [DependencyInjection][FrameworkBundle] fix BC break when dumping container for build/lint commands | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT #60597 introduced a BC break in that it assumes the `ContainerBuilder` constructor accepts the parameter bag as its first argument. However, in our application, we have a custom version of the `ContainerBuilder`. Since the container is already built at this state, I understand that calling `__construct()` again is just a hack to re-set the parameter bag. A direct setter function for this case should fix the issue. PS: `Kernel::buildContainer` must always return an instance of `ContainerBuilder`, so the setter method must always be there (our class inherits from it as well). Links: - Original issue: contao/contao#9058 - Custom `ContainerBuilder` https://github.com/contao/manager-plugin/blob/main/src/Config/ContainerBuilder.php Commits ------- 843fbca [DependencyInjection][FrameworkBundle] fix BC break when dumping container for build/lint commands
2 parents 56c348c + 843fbca commit f0c6c79

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilde
6464
$dumpedContainer = unserialize(file_get_contents(substr_replace($file, '.ser', -4)));
6565
$container->setDefinitions($dumpedContainer->getDefinitions());
6666
$container->setAliases($dumpedContainer->getAliases());
67-
$container->__construct($dumpedContainer->getParameterBag());
67+
68+
$parameterBag = $container->getParameterBag();
69+
$parameterBag->clear();
70+
$parameterBag->add($dumpedContainer->getParameterBag()->all());
6871
} else {
6972
(new XmlFileLoader($container, new FileLocator()))->load($file);
7073
$locatorPass = new ServiceLocatorTagPass();

0 commit comments

Comments
 (0)