Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DI]ContainerBuilder can throw when resolving unescaped parameters #59594

Open
@MatTheCat

Description

@MatTheCat

Symfony version(s) affected

≥ 3.3.7

Description

WhenContainerBuilder::compile is called with$resolveEnvPlaceholders, it will end up creating a newParameterBag from the old one:

if ($resolveEnvPlaceholders) {
$this->parameterBag =newParameterBag($this->resolveEnvPlaceholders($bag->all(),true));
}

Withtrue as its second parameter,resolveEnvPlaceholders will start by calling the bag’sresolveValue method:

if (true ===$format ??='%%env(%s)%%') {
$value =$bag->resolveValue($value);
}

Problem is, at this point the parameter bag already has been resolved by theResolveParameterPlaceHoldersPass, which means parameters’ value have been unescaped:

$parameters[$key] =$this->unescapeValue($value);

Since unescaped parameters can appear as if they contain a placeholder, those will trigger aParameterNotFoundException.

How to reproduce

$builder =newContainerBuilder();$builder->setParameter('foo','%%bar%%');$builder->compile(true);

Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException: You have requested a non-existent parameter "bar".

Possible Solution

I guess an easy fix would be to ignoreParameterNotFoundExceptions when creating the newParameterBag? It feels like addressing a symptom rather than a cause though.

Additional Context

Spotted while investigating#59028.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp