Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Conversation

@ajgarlag
Copy link
Contributor

QA
Branch?3.4 up to 4.2
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#31436
LicenseMIT

This PR adds a test to demonstrate the bug, and a fix to squash it.

@ajgarlagajgarlagforce-pushed thehotfix/denormalize-variadic-constructor-parameter branch from1171ce3 to7108f84CompareMay 9, 2019 07:23
@nicolas-grekasnicolas-grekas added this to the3.4 milestoneMay 9, 2019
@nicolas-grekasnicolas-grekas changed the title Fix denormalization of object with variadic constructor typed argument[Serializer] Fix denormalization of object with variadic constructor typed argumentMay 9, 2019
@ajgarlagajgarlagforce-pushed thehotfix/denormalize-variadic-constructor-parameter branch from36056a4 to995d189CompareMay 9, 2019 08:38
@ajgarlag
Copy link
ContributorAuthor

PR ready to merge

);

$params =array_merge($params,$variadicParameters);
unset($data[$key]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why this change?

Copy link
ContributorAuthor

@ajgarlagajgarlagMay 10, 2019
edited
Loading

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.

https://github.com/ajgarlag/symfony/blob/a736781cc2499a3ab829ddbf7898740e1638d128/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php#L147-L150

dunglas reacted with thumbs up emoji
@nicolas-grekasnicolas-grekasforce-pushed thehotfix/denormalize-variadic-constructor-parameter branch froma736781 toc8c3c56CompareMay 11, 2019 09:57
@nicolas-grekas
Copy link
Member

Thank you@ajgarlag.

@nicolas-grekasnicolas-grekas merged commitc8c3c56 intosymfony:3.4May 11, 2019
nicolas-grekas added a commit that referenced this pull requestMay 11, 2019
…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
Copy link
ContributorAuthor

@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
Copy link
Member

There is nothing to do on your side, we will merge 3.4 into 4.2 with the fix.

@WalentinG
Copy link

WalentinG commentedMay 20, 2019
edited
Loading

@nicolas-grekas, the fix breaks current workaround
try the dummy object below in your test, with

$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 was referencedMay 22, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

5 participants

@ajgarlag@nicolas-grekas@WalentinG@dunglas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp