Skip to content

[DI] Don't track merged configs when the extension doesn't expose it #24021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function process(ContainerBuilder $container)

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

$container->merge($tmpContainer);
Expand All @@ -92,12 +92,16 @@ public function __construct(parent $parameterBag)
$this->mergeEnvPlaceholders($parameterBag);
}

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

// serialize config to catch env vars nested in object graphs
$config = serialize($extension->getProcessedConfigs());
// serialize config and container to catch env vars nested in object graphs
$config = serialize($config).serialize($container->getDefinitions()).serialize($container->getAliases()).serialize($container->getParameterBag()->all());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aliases don't need to be serialized. They only have a target and a public flag, and these cannot use parameters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


foreach (parent::getEnvPlaceholders() as $env => $placeholders) {
foreach ($placeholders as $placeholder) {
Expand Down