Skip to content

[DoctrineBridge] EntityValueResolver breaks BC when DoctrineParamConverter is disabled #48526

Closed
@tjveldhuizen

Description

@tjveldhuizen

Symfony version(s) affected

6.2.*

Description

In our project, we have disabled the DoctrineParamConverter since we have more strict ParamConverters in place. Now the new EntityValueResolver is added in Symfony 6.2, our project suddenly started resolving entities in de less-strict way. I think enabling EntityValueResolver when DoctrineParamConverter is disabled breaks the BC-promise.

How to reproduce

A simplified example given this team in the database (I admit I did not test this code):

Club Type Number Name
club-foo male 2 Club Foo Male 2

And those controllers

#[Route(path: '/first-team/{club}/{type}')]
public function indexFirstTeam(string $club, string $type)
{
    return $this->forward('...::indexTeam', ['club' => $club, 'type' => $type]);
}

#[Route(path: '/team/{club}/{type}/{number}')]
public function indexTeam(string $club, string $type, ?Team $team = null)
{
    dump($team);
}

Before Symfony 6.2, /first-team/club-foo/male resulted in $team === null because in our custom ParamConverter the default value for $number is 1, so the criteria for the query are ['club' => 'club-foo', 'type' => 'male', 'number' => 1]
Now the EntityValueResolver is used, the same URL results in $team->name === 'Club Foo Male 2' because the EntityValueResolver is running a Doctrine query based on criteria ['club' => 'club-foo', 'type' => 'male'].

Possible Solution

No response

Additional Context

No response

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