Skip to content

Commit b641a76

Browse files
committed
bug symfony#24021 [DI] Don't track merged configs when the extension doesn't expose it (nicolas-grekas)
This PR was merged into the 3.3 branch. Discussion ---------- [DI] Don't track merged configs when the extension doesn't expose it | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#24020 | License | MIT | Doc PR | - This is driving me crazy :) Commits ------- a8e6aac [DI] Don't track merged configs when the extension doesn't expose it
2 parents bd1bf2c + a8e6aac commit b641a76

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function process(ContainerBuilder $container)
6767

6868
if ($resolvingBag instanceof MergeExtensionConfigurationParameterBag) {
6969
// don't keep track of env vars that are *overridden* when configs are merged
70-
$resolvingBag->freezeAfterProcessing($extension);
70+
$resolvingBag->freezeAfterProcessing($extension, $tmpContainer);
7171
}
7272

7373
$container->merge($tmpContainer);
@@ -92,12 +92,16 @@ public function __construct(parent $parameterBag)
9292
$this->mergeEnvPlaceholders($parameterBag);
9393
}
9494

95-
public function freezeAfterProcessing(Extension $extension)
95+
public function freezeAfterProcessing(Extension $extension, ContainerBuilder $container)
9696
{
97+
if (!$config = $extension->getProcessedConfigs()) {
98+
// Extension::processConfiguration() wasn't called, we cannot know how configs were merged
99+
return;
100+
}
97101
$this->processedEnvPlaceholders = array();
98102

99-
// serialize config to catch env vars nested in object graphs
100-
$config = serialize($extension->getProcessedConfigs());
103+
// serialize config and container to catch env vars nested in object graphs
104+
$config = serialize($config).serialize($container->getDefinitions()).serialize($container->getAliases()).serialize($container->getParameterBag()->all());
101105

102106
foreach (parent::getEnvPlaceholders() as $env => $placeholders) {
103107
foreach ($placeholders as $placeholder) {

0 commit comments

Comments
 (0)