Skip to content

Commit 11ef58e

Browse files
committed
Merge branch '3.3' into 3.4
* 3.3: [HttpFoundation] Support 0 bit netmask in IPv6 () [DI] Impossible to set an environment variable and then an array as container parameter [LDAP] added missing dots at the end of some exception messages. Set `width: auto` on WebProfiler toolbar's reset. [Process] Dont rely on putenv(), it fails on ZTS PHP [HttpKernel] detect deprecations thrown by container initialization during tests [HttpKernel] Fix logging of post-terminate errors/exceptions [Debug] Fix catching fatal errors in case of nested error handlers [VarDumper] Fixed file links leave blank pages when ide is configured Fix hidden currency element with Bootstrap 3 theme
2 parents 159c90d + 20ab1ba commit 11ef58e

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

ContainerBuilder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,11 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs
13621362
$format = '%%env(%s)%%';
13631363
}
13641364

1365+
$bag = $this->getParameterBag();
1366+
if (true === $format) {
1367+
$value = $bag->resolveValue($value);
1368+
}
1369+
13651370
if (is_array($value)) {
13661371
$result = array();
13671372
foreach ($value as $k => $v) {
@@ -1374,11 +1379,6 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs
13741379
if (!is_string($value)) {
13751380
return $value;
13761381
}
1377-
1378-
$bag = $this->getParameterBag();
1379-
if (true === $format) {
1380-
$value = $bag->resolveValue($value);
1381-
}
13821382
$envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders;
13831383

13841384
foreach ($envPlaceholders as $env => $placeholders) {

Tests/ContainerBuilderTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,28 @@ public function testResolveEnvValues()
616616
unset($_ENV['DUMMY_ENV_VAR'], $_SERVER['DUMMY_SERVER_VAR'], $_SERVER['HTTP_DUMMY_VAR']);
617617
}
618618

619+
public function testResolveEnvValuesWithArray()
620+
{
621+
$_ENV['ANOTHER_DUMMY_ENV_VAR'] = 'dummy';
622+
623+
$dummyArray = array('1' => 'one', '2' => 'two');
624+
625+
$container = new ContainerBuilder();
626+
$container->setParameter('dummy', '%env(ANOTHER_DUMMY_ENV_VAR)%');
627+
$container->setParameter('dummy2', $dummyArray);
628+
629+
$container->resolveEnvPlaceholders('%dummy%', true);
630+
$container->resolveEnvPlaceholders('%dummy2%', true);
631+
632+
$this->assertInternalType('array', $container->resolveEnvPlaceholders('%dummy2%', true));
633+
634+
foreach ($dummyArray as $key => $value) {
635+
$this->assertArrayHasKey($key, $container->resolveEnvPlaceholders('%dummy2%', true));
636+
}
637+
638+
unset($_ENV['ANOTHER_DUMMY_ENV_VAR']);
639+
}
640+
619641
public function testCompileWithResolveEnv()
620642
{
621643
putenv('DUMMY_ENV_VAR=du%%y');

0 commit comments

Comments
 (0)