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 collecting only first missing constructor argument#51907

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

@HypeMC
Copy link
Member

@HypeMCHypeMC commentedOct 9, 2023
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets-
LicenseMIT

Alternative to#51866, sort of followup to#49832

Currently on 5.4 only the first exception is added to thenot_normalizable_value_exceptions array whenCOLLECT_DENORMALIZATION_ERRORS istrue or only the first argument is mentioned in theMissingConstructorArgumentsException when it isfalse.
On 6.3 however, the part with theMissingConstructorArgumentsException was fix with#49832, but the part with thenot_normalizable_value_exceptions was overlooked.
IMO this is inconsistent behavior as the two cases are actually the same thing with the only difference being that in one case an exception is thrown while in the other the errors are collected.

I'm not sure if#51866 really qualifies as a bug or is actually more a feature, but the reason#49832 was merged onto 6.3 was because of the changes originally done in#49013, which itself was a feature.

If#51866 does qualify as a bug then it would make sense to backport#49832 to 5.4 for consistency, which is what this PR does.

The PR contains two commits:

  1. backport of[Serializer] Fix MissingConstructorArgumentsException returning missing argument one by one #49832
  2. alternative toadd all missing properties #51866

If#51866 does not qualify as a bug, the first commit can be drooped and the second one can be rebased with 6.4.

PS I think it's easier to review the changes commit by commit.

@y4roc
Copy link

Your solution looks great, but I see a conflict with RequestMapper.

Do you tested your solution with PayloadMapper in 6.3?

@HypeMCHypeMCforce-pushed thefix-collecting-only-first-missing-constructor-argument branch 2 times, most recently from258ae0f tocd90ab7CompareOctober 10, 2023 01:38
@HypeMC
Copy link
MemberAuthor

@y4roc Hi, you were right, my changes did cause an issue with theRequestPayloadValueResolver because the functionality used there was not covered on 5.4.
I've added a test (testCollectDenormalizationErrorsWithInvalidConstructorTypes) so this wouldn't be a problem in the future. I've also tested my changes on 6.3 to check that there are no other failing tests.

);
$context['not_normalizable_value_exceptions'][] =$exception;

return$reflectionClass->newInstanceWithoutConstructor();
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This is now handled in thetry...catch block.

@nicolas-grekasnicolas-grekasforce-pushed thefix-collecting-only-first-missing-constructor-argument branch fromcd90ab7 to0f398ceCompareOctober 17, 2023 06:59
@nicolas-grekas
Copy link
Member

Thank you@HypeMC.

@nicolas-grekasnicolas-grekas merged commitbccdccc intosymfony:5.4Oct 17, 2023
@HypeMCHypeMC deleted the fix-collecting-only-first-missing-constructor-argument branchOctober 17, 2023 07:12
@fabpotfabpot mentioned this pull requestOct 21, 2023
@fabpotfabpot mentioned this pull requestOct 29, 2023
nicolas-grekas added a commit that referenced this pull requestNov 20, 2023
This PR was merged into the 5.4 branch.Discussion----------[Serializer] Fix denormalize constructor arguments| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Issues        |Fix#52499,Fix#52422| License       | MITSince this PR:#51907, objects with partial constructor parameters were wrongly instantiated.This PR fixes that issue by delegating the properties values assignment, by unsetting normalized data only when the constructor has been called properly.This might correct#50759 as well.Commits-------8f7c7ae [Serializer] Fix denormalize constructor arguments
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

4 participants

@HypeMC@y4roc@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp