Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Serializer] Fix denormalization of object with variadic constructor typed argument#31438
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
[Serializer] Fix denormalization of object with variadic constructor typed argument#31438
Uh oh!
There was an error while loading.Please reload this page.
Conversation
1171ce3 to7108f84Compare36056a4 to995d189Compareajgarlag commentedMay 9, 2019
PR ready to merge |
src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| ); | ||
| $params =array_merge($params,$variadicParameters); | ||
| unset($data[$key]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Without this change, when using thePropertyNormalizer, the deserialized object is successfully instantiated, but the property is overwritten again with the original$data[$key] array value ignoring the type hint.
a736781 toc8c3c56Comparenicolas-grekas commentedMay 11, 2019
Thank you@ajgarlag. |
…onstructor typed argument (ajgarlag)This PR was squashed before being merged into the 3.4 branch (closes#31438).Discussion----------[Serializer] Fix denormalization of object with variadic constructor typed argument| Q | A| ------------- | ---| Branch? | 3.4 up to 4.2| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#31436| License | MITThis PR adds a test to demonstrate the bug, and a fix to squash it.Commits-------c8c3c56 [Serializer] Fix denormalization of object with variadic constructor typed argument
ajgarlag commentedMay 16, 2019
@nicolas-grekas I'd like to have this issue fixed in 4.2 branch too. Can you tell me when will be merged into that branch? Thanks. |
nicolas-grekas commentedMay 16, 2019
There is nothing to do on your side, we will merge 3.4 into 4.2 with the fix. |
WalentinG commentedMay 20, 2019 • 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.
@nicolas-grekas, the fix breaks current workaround $extractor =newPropertyInfoExtractor([], [newPhpDocExtractor(),newReflectionExtractor()]);$normalizer =newPropertyNormalizer(null,null,$extractor); <?phpnamespaceSymfony\Component\Serializer\Tests\Fixtures;finalclass VariadicConstructorAnnotationTypedArgsDummy{/** @var Dummy[] */private$foo;publicfunction__construct(...$foo) {$this->foo =$foo; }publicfunctiongetFoo() {return$this->foo; }} |
This PR adds a test to demonstrate the bug, and a fix to squash it.