SensioFrameworkExtraBundle
SensioFrameworkExtraBundle copied to clipboard
User attribute "user" cannot be defined as it collides with built-in security expression variables.
I just updated my symfony from 5.1 to 5.3 and I am getting the follow warning message:
sensio/framework-extra-bundle version 6.1.5
Controller argument "user" collided with the built-in security expression variables. The built-in values are being used for the @Security expression.
How to reproduce:
-
Create UserController
-
Add the annotation below in the UserController class or on the route function
@Security("is_granted('ROLE_ADMIN')")
-
Create a route with
User $user
as a parameter, like below:public function edit(Request $request, User $user)
If I remove the @Security
or if i change the variable $user
the warning message doesn't appear.
This does seem a bit silly, I'm working on an application with hundreds of these controller parameters and it will be very tricky to update them all. Would be good to know if there is any likelihood that this can be solved in the framework at some point
Hi there, I'm facing the same warning message.
Should I rename variable $user
to something else? Or a patch is planned?
Rgs,
Currently it is necessary to change the $user
variable name so this error does not occur