Skip to content

Commit

Permalink
bug #34301 [DI] fix loading env while env loaders are loaded (nicolas…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
nicolas-grekas committed Nov 8, 2019
2 parents 7c111bd + 522bd5d commit 26f25ab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Symfony/Component/DependencyInjection/EnvVarProcessor.php
Expand Up @@ -141,15 +141,20 @@ public function getEnv($prefix, $name, \Closure $getEnv)
}
}

$loaders = $this->loaders;
$this->loaders = new \ArrayIterator();

try {
while ((false === $env || null === $env) && $this->loaders->valid()) {
$loader = $this->loaders->current();
$this->loaders->next();
while ((false === $env || null === $env) && $loaders->valid()) {
$loader = $loaders->current();
$loaders->next();
$this->loadedVars[] = $vars = $loader->loadEnvVars();
$env = $vars[$name] ?? false;
}
} catch (ParameterCircularReferenceException $e) {
// skip loaders that need an env var that is not defined
} finally {
$this->loaders = $loaders;
}

if (false === $env || null === $env) {
Expand Down

0 comments on commit 26f25ab

Please sign in to comment.