Skip to content

Commit 4c9e1a4

Browse files
committed
fix(dependency-injection): reset env vars with kernel.reset
- fixes #59128
1 parent af68b6e commit 4c9e1a4

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.php

+1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class_exists(WorkflowEvents::class) ? WorkflowEvents::ALIASES : []
195195
tagged_iterator('container.env_var_loader'),
196196
])
197197
->tag('container.env_var_processor')
198+
->tag('kernel.reset', ['method' => 'reset'])
198199

199200
->set('slugger', AsciiSlugger::class)
200201
->args([

src/Symfony/Component/DependencyInjection/Container.php

+8
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ public function reset(): void
290290
$this->envCache = $this->services = $this->factories = $this->privates = [];
291291
}
292292

293+
/**
294+
* @internal
295+
*/
296+
public function resetEnvCache(): void
297+
{
298+
$this->envCache = [];
299+
}
300+
293301
/**
294302
* Gets all service ids.
295303
*

src/Symfony/Component/DependencyInjection/EnvVarProcessor.php

+4
Original file line numberDiff line numberDiff line change
@@ -374,5 +374,9 @@ public function reset(): void
374374
{
375375
$this->loadedVars = [];
376376
$this->loaders = $this->originalLoaders;
377+
378+
if ($this->container instanceof Container) {
379+
$this->container->resetEnvCache();
380+
}
377381
}
378382
}

0 commit comments

Comments
 (0)