8000 bug #34301 [DI] fix loading env while env loaders are loaded (nicolas… · symfony/symfony@26f25ab · GitHub
[go: up one dir, main page]

Skip to content

Commit 26f25ab

Browse files
bug #34301 [DI] fix loading env while env loaders are loaded (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [DI] fix loading env while env loaders are loaded | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- 522bd5d [DI] fix loading env while env loaders are loaded
2 parents 7c111bd + 522bd5d commit 26f25ab

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Symfony/Component/DependencyInjection/EnvVarProcessor.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,20 @@ public function getEnv($prefix, $name, \Closure $getEnv)
141141
}
142142
}
143143

144+
$loaders = $this->loaders;
145+
$this->loaders = new \ArrayIterator();
146+
144147
try {
145-
while ((false === $env || null === $env) && $this->loaders->valid()) {
146-
$loader = $this->loaders->current();
147-
$this->loaders->next();
148+
while ((false === $env || null === $env) && $loaders->valid()) {
149+
$loader = $loaders->current();
150+
$loaders->next();
148151
$this->loadedVars[] = $vars = $loader->loadEnvVars();
149152
$env = $vars[$name] ?? false;
150153
}
151154
} catch (ParameterCircularReferenceException $e) {
152155
// skip loaders that need an env var that is not defined
156+
} finally {
157+
$this->loaders = $loaders;
153158
}
154159

155160
if (false === $env || null === $env) {

0 commit comments

Comments
 (0)
0