You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem is, at this point the parameter bag already has been resolved by the ResolveParameterPlaceHoldersPass, which means parameters’ value have been unescaped:
Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException: You have requested a non-existent parameter "bar".
Possible Solution
I guess an easy fix would be to ignore ParameterNotFoundExceptions when creating the new ParameterBag? It feels like addressing a symptom rather than a cause though.
MatTheCat
changed the title
[DI] ContainerBuilder can resolve some parameters twice, resulting in ParameterNotFoundException
[DI] ContainerBuilder can try resolving unescaped parameters
Jan 23, 2025
MatTheCat
changed the title
[DI] ContainerBuilder can try resolving unescaped parameters
[DI] ContainerBuilder can throw when resolving unescaped parameters
Jan 27, 2025
Symfony version(s) affected
≥ 3.3.7
Description
When
ContainerBuilder::compile
is called with$resolveEnvPlaceholders
, it will end up creating a newParameterBag
from the old one:symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
Lines 825 to 827 in 05d5bb3
With
true
as its second parameter,resolveEnvPlaceholders
will start by calling the bag’sresolveValue
method:symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
Lines 1480 to 1482 in 05d5bb3
Problem is, at this point the parameter bag already has been resolved by the
ResolveParameterPlaceHoldersPass
, which means parameters’ value have been unescaped:symfony/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
Line 161 in 05d5bb3
Since unescaped parameters can appear as if they contain a placeholder, those will trigger a
ParameterNotFoundException
.How to reproduce
Possible Solution
I guess an easy fix would be to ignore
ParameterNotFoundException
s when creating the newParameterBag
? It feels like addressing a symptom rather than a cause though.Additional Context
Spotted while investigating #59028.
The text was updated successfully, but these errors were encountered: