File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
src/Symfony/Component/DependencyInjection Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -469,7 +469,8 @@ protected function getEnv($name)
469469 return $ this ->envCache [$ name ];
470470 }
471471 if (!$ this ->has ($ id = 'container.env_var_processors_locator ' )) {
472- $ this ->set ($ id , new ServiceLocator (array ()));
472+ // Prevent an infinite loop, because set() call getRemovedIds() that may call getEnv()
473+ $ this ->services [$ id ] = new ServiceLocator (array ());
473474 }
474475 if (!$ this ->getEnv ) {
475476 $ this ->getEnv = new \ReflectionMethod ($ this , __FUNCTION__ );
Original file line number Diff line number Diff line change @@ -538,6 +538,23 @@ public function testReplacingAPreDefinedServiceIsDeprecated()
538538
539539 $ this ->assertSame ($ bar , $ c ->get ('bar ' ), '->set() replaces a pre-defined service ' );
540540 }
541+
542+ public function testNoInfiniteLoopInGetEnv ()
543+ {
544+ $ _ENV ['bar ' ] = 'hello ' ;
545+ $ this ->assertCount (1 , (new RemovedIdsCallGetEnvContainer ())->getRemovedIds ());
546+ unset($ _ENV ['bar ' ]);
547+ }
548+ }
549+
550+ class RemovedIdsCallGetEnvContainer extends Container
551+ {
552+ public function getRemovedIds ()
553+ {
554+ return array (
555+ 'foo. ' .$ this ->getEnv ('bar ' ) => true ,
556+ );
557+ }
541558}
542559
543560class ProjectServiceContainer extends Container
You can’t perform that action at this time.
0 commit comments