-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
ObjectNormalizer can't normalize data if data class has annotation @Ignore and method "getSomething" with the required parameter #46592
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
Labels
Comments
astepin
added a commit
to CloudPlayDev/symfony
that referenced
this issue
Jul 16, 2022
astepin
added a commit
to CloudPlayDev/symfony
that referenced
this issue
Jul 16, 2022
Hey @DariusPeza in my opinion this is indeed a bug. I have created a PR for the fix here: #46958 |
astepin
added a commit
to CloudPlayDev/symfony
that referenced
this issue
Jul 17, 2022
fabpot
added a commit
that referenced
this issue
Jul 19, 2022
…46592) (astepin) This PR was merged into the 5.4 branch. Discussion ---------- [Serializer] Ignore getter with required parameters (Fix #46592) | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #46592 | License | MIT | Doc PR | na If no Ignore annotation is used, the attributes for serialization are obtained using `Symfony\Component\Serializer\Normalizer\ObjectNormalizer::extractAttributes`. There it is checked if the method has required parameters and if yes, the method is ignored. However, if you use the Ignore annotation, the attributes are determined with a different method. Here I have adapted at least for get methods the behavior as it was before. If someone serialized a class with Ignore annotations before, he got here `\Symfony\Component\PropertyAccess\PropertyAccessor::readProperty` an exception as written in ticket #46592. With this fix the methods are ignored and there is no exception anymore. Commits ------- fda9281 Fix #46592 - Ignore getter with required parameters
derrabus
added a commit
that referenced
this issue
Jul 19, 2022
* 5.4: Fix CS Fix CS quote address names if they contain parentheses [FrameworkBundle] Fail gracefully when forms use disabled CSRF [Mime] Fix inline parts when added via attachPart() Fail gracefully when attempting to autowire composite types [VarDumper] Add a test case for nesting intersection and union types Fix #46592 - Ignore getter with required parameters [Serializer] Fix inconsistent behaviour of nullable objects in key/value arrays
derrabus
added a commit
that referenced
this issue
Jul 19, 2022
* 6.0: Fix CS Fix CS quote address names if they contain parentheses [FrameworkBundle] Fail gracefully when forms use disabled CSRF [Mime] Fix inline parts when added via attachPart() Fail gracefully when attempting to autowire composite types [VarDumper] Add a test case for nesting intersection and union types Fix #46592 - Ignore getter with required parameters [Serializer] Fix inconsistent behaviour of nullable objects in key/value arrays
derrabus
added a commit
that referenced
this issue
Jul 19, 2022
* 6.1: Fix CS Fix CS quote address names if they contain parentheses [FrameworkBundle] Fail gracefully when forms use disabled CSRF [Mime] Fix inline parts when added via attachPart() Fail gracefully when attempting to autowire composite types [VarDumper] Add a test case for nesting intersection and union types Fix #46592 - Ignore getter with required parameters [Serializer] Fix inconsistent behaviour of nullable objects in key/value arrays
This was referenced Jul 29, 2022
Merged
Merged
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected
6.1.0
Description
ObjectNormalizer can't normalize data if data class has annotation @ignore and method "getSomething" with the required parameter.
If data class don't use
@Ignore
annotation then methods with prefix get and required parameters are successfully ignored. But if any other method is annotated with@Ignore
in this case ObjectNormalizer fails to ignore "get" methods with required parameters.How to reproduce
expected response:
array(2) { ["name"]=> string(11) "Person name" }
got:
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: