-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[6.2] [doctrine-bridge] EntityValueResolver priority is too high and there is no way to be skipped by a custom ParamCoverter #48433
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report. Can you please confirm that #48489 would fix the issue? |
@nicolas-grekas thanks for the response. Unfortunately, it won't help. The problem is it will continue to execute a find method in EntityManager
It would help if the EntityValueResolver would be skipped if the identifier is null. EDIT:
|
OK thanks. Can you provide a small reproducing app that I could play with locally to work on this? |
having higher priority than RequestAttributeValueResolver is the intended purpose, as this supports essential features when using only the value resolver system. But we should indeed add a condition to skip this |
I will do so later today or tomorrow.
Skipping the EntityValueResolver if the attribute is already an object would help. We are going to migrate to an argument resolver sooner or later, but to be honest I miss some option to skip this visitor pattern which iterates the whole stack of arguments resolvers (it's also not the best thing to do for performance reasons). It would be cool to add some attribute for parameters which would allow to define a specific argument resolver right away and skip the whole process with priority. |
I updated #48489 to follow this idea, does that work for you? |
Thank you! I tested it and it works for me. |
…nding request attribute is already an object (nicolas-grekas) This PR was merged into the 6.2 branch. Discussion ---------- [DoctrineBridge] Skip resolving entities when the corresponding request attribute is already an object | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #48433 | License | MIT | Doc PR | - Commits ------- 9b0d717 [DoctrineBridge] Skip resolving entities when the corresponding request attribute is already an object
Symfony version(s) affected
6.2
Description
EntityValueResolver introduced in Symfony 6.2 priority (110) is higher than RequestAttributeValueResolver priority (100) which makes ParamConverter unusable in some cases. Only UserValueResolver has a higher priority.
How to reproduce
Consider this controller action:
In this case,
AssetFile
andJwDistribution
represent Doctrine's entities, butJwDistribution
doesn't exist in repository and should be converted by a custom converter (serializer). Instead,EntityValueResolver
is used also forJwDistribution
and it obviously fails to convert (because it's entity object without identifier). That must be at least some kind of regression. Could we do something about it?Possible Solution
At least
RequestAttributeValueResolver should has a higher priority than EntityValueResolver.
Additional Context
No response
The text was updated successfully, but these errors were encountered: