Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpKernel] Handle previously convertedDateTime arguments#46199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[HttpKernel] Handle previously convertedDateTime arguments#46199
Uh oh!
There was an error while loading.Please reload this page.
Conversation
src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DateTimeValueResolver.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
chalasr commentedApr 30, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Can you elaborate on the side effects? I'm really not fond of patching Symfony to support a mix of param converters and argument value resolvers |
5fb1e88 toa48ecb6Comparembabker commentedMay 1, 2022
If your app already relies on them, then turning off the param converters (especially with#43854 not making it into 6.1) ends up being a much bigger refactoring. As much as I don't like the patch either, being a pragmatist here, I do think it solves the upgrade issue in a way that causes the least frustration for end-users (as otherwise you really either have to turn off the param converters and rewrite all controllers relying on those or mess with the container to remove one of the services to avoid the double-conversion issue), and this one condition can be re-evaluated or removed once we're at a version where both of the |
chalasr commentedMay 1, 2022
I thought it was in, thanks. |
nicolas-grekas commentedMay 1, 2022
Thank you@mbabker. |
I'm not sure I like this fix, but given the order of operations between the param converters in SensioFrameworkExtraBundle and the controller argument resolvers in the HttpKernel component, this is probably going to cause the least number of headaches for users when upgrading. And in some ways, this is the same problem as#40333 but in reverse.
Because the param converters are triggered on the
kernel.controllerevent, they will handle converting values before the controller argument resolvers are fired. This means that a typehintedDateTimeInterfacewill potentially be handled twice (once by the param converter, once by the argument resolver). To avoid theTypeErrornoted in the issue, a practical fix is to gracefully handle a previously converted value in this resolver. As the other options aren't great (removing services from the container or turning off the param converters in full, which has other side effects), this is probably the most practical fix.