Skip to content

Commit bf55775

Browse files
Thomason, JamesThomason, James
authored andcommitted
Fix stripos(array, string) bug with array env vars
1 parent 7b11eed commit bf55775

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,16 +1408,18 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs
14081408
}
14091409
$envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders;
14101410

1411+
$completed = false;
14111412
foreach ($envPlaceholders as $env => $placeholders) {
14121413
foreach ($placeholders as $placeholder) {
1413-
if (false !== stripos($value, $placeholder)) {
1414+
if (\is_string($value) && false !== stripos($value, $placeholder)) {
14141415
if (true === $format) {
14151416
$resolved = $bag->escapeValue($this->getEnv($env));
14161417
} else {
14171418
$resolved = sprintf($format, $env);
14181419
}
14191420
if ($placeholder === $value) {
14201421
$value = $resolved;
1422+
$completed = true;
14211423
} else {
14221424
if (!is_string($resolved) && !is_numeric($resolved)) {
14231425
throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "env(%s)" of type %s inside string value "%s".', $env, gettype($resolved), $value));
@@ -1426,6 +1428,10 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs
14261428
}
14271429
$usedEnvs[$env] = $env;
14281430
$this->envCounters[$env] = isset($this->envCounters[$env]) ? 1 + $this->envCounters[$env] : 1;
1431+
1432+
if ($completed) {
1433+
break 2;
1434+
}
14291435
}
14301436
}
14311437
}

0 commit comments

Comments
 (0)