Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DI] Avoid leaking unused env placeholders #27681

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
Jun 23, 2018
Merged
Show file tree
Hide file tree
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
[DI] Avoid leaking unused env placeholders
  • Loading branch information
ro0NL committed Jun 22, 2018
commit 41f8494722b98d51a92f7c1516ed16fa0c93503b
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public function process(ContainerBuilder $container)
} finally {
BaseNode::resetPlaceholders();
}

$resolvingBag->clearUnusedEnvPlaceholders();
}

private static function getType($value): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public function getUnusedEnvPlaceholders(): array
return $this->unusedEnvPlaceholders;
}

public function clearUnusedEnvPlaceholders()
{
$this->unusedEnvPlaceholders = array();
}

/**
* Merges the env placeholders of another EnvPlaceholderParameterBag.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,29 @@ public function testEnvWithVariableNode(): void
public function testConfigurationWithoutRootNode(): void
{
$container = new ContainerBuilder();
$container->registerExtension($ext = new EnvExtension(new EnvConfigurationWithoutRootNode()));
$container->registerExtension(new EnvExtension(new EnvConfigurationWithoutRootNode()));
$container->loadFromExtension('env_extension');

$this->doProcess($container);

$this->addToAssertionCount(1);
}

public function testDiscardedEnvInConfig(): void
{
$container = new ContainerBuilder();
$container->setParameter('env(BOOLISH)', '1');
$container->setParameter('boolish', '%env(BOOLISH)%');
$container->registerExtension(new EnvExtension());
$container->prependExtensionConfig('env_extension', array(
'array_node' => array('bool_force_cast' => '%boolish%'),
));

$container->compile(true);

$this->assertSame('1', $container->getParameter('boolish'));
}

private function doProcess(ContainerBuilder $container): void
{
(new MergeExtensionConfigurationPass())->process($container);
Expand All @@ -260,8 +275,19 @@ public function getConfigTreeBuilder()
->ifTrue(function ($value) { return !is_array($value); })
->then(function ($value) { return array('child_node' => $value); })
->end()
->beforeNormalization()
->ifArray()
->then(function (array $v) {
if (isset($v['bool_force_cast'])) {
$v['bool_force_cast'] = (bool) $v['bool_force_cast'];
}

return $v;
})
->end()
->children()
->scalarNode('child_node')->end()
->booleanNode('bool_force_cast')->end()
->integerNode('int_unset_at_zero')
->validate()
->ifTrue(function ($value) { return 0 === $value; })
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.