Description
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