File tree 1 file changed +16
-5
lines changed
Filter options
src/Symfony/Component/DependencyInjection
1 file changed +16
-5
lines changed
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
22
22
{
23
23
private $ container ;
24
24
private $ loaders ;
25
+ private $ loadedLoaderIndex = 0 ;
25
26
private $ loadedVars = [];
26
27
27
28
/**
@@ -30,8 +31,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
30
31
public function __construct (ContainerInterface $ container , \Traversable $ loaders = null )
31
32
{
32
33
$ this ->container = $ container ;
33
- $ this ->loaders = new \IteratorIterator ($ loaders ?? new \ArrayIterator ());
34
- $ this ->loaders = $ this ->loaders ->getInnerIterator ();
34
+ $ this ->loaders = $ loaders ?? new \ArrayIterator ();
35
35
}
36
36
37
37
/**
@@ -145,11 +145,22 @@ public function getEnv($prefix, $name, \Closure $getEnv)
145
145
$ this ->loaders = new \ArrayIterator ();
146
146
147
147
try {
148
- while ((false === $ env || null === $ env ) && $ loaders ->valid ()) {
149
- $ loader = $ loaders ->current ();
150
- $ loaders ->next ();
148
+ $ index = 0 ;
149
+ $ ended = true ;
150
+ foreach ($ loaders as $ loader ) {
151
+ if ($ index ++ < $ this ->loadedLoaderIndex ) {
152
+ continue ;
153
+ }
151
154
$ this ->loadedVars [] = $ vars = $ loader ->loadEnvVars ();
155
+ $ this ->loadedLoaderIndex = $ index ;
152
156
$ env = $ vars [$ name ] ?? false ;
157
+ if (false !== $ env ) {
158
+ $ ended = false ;
159
+ break ;
160
+ }
161
+ }
162
+ if ($ ended ) {
163
+ $ loaders = new \ArrayIterator ();
153
164
}
154
165
} catch (ParameterCircularReferenceException $ e ) {
155
166
// skip loaders that need an env var that is not defined
You can’t perform that action at this time.
0 commit comments