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] Allow (de)normalization of empty objects in PropertyNormalizer#46417

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

Open
olsavmic wants to merge2 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromolsavmic:olsavmic-property-normalizer-allow-empty-object

Conversation

olsavmic
Copy link
Contributor

@olsavmicolsavmic commentedMay 20, 2022
edited by derrabus
Loading

QA
Branch?6.2
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#46280 (comment)
LicenseMIT
Doc PRsymfony/symfony-docs#...

This PR adds optional support for the normalization of objects without properties (in the case ofPropertyNormalizer) or objects without getters (in the case ofGetSetMethodNormalizer). Backward compatibility is preserved since this change is disabled by default for now.

Reasoning behind this change is explained in the discussion of the linked issue (#46280)

@olsavmicolsavmic requested a review fromdunglas as acode ownerMay 20, 2022 15:25
@carsonbotcarsonbot added this to the6.2 milestoneMay 20, 2022
@olsavmicolsavmic changed the base branch from6.2 to6.1May 20, 2022 15:28
@olsavmicolsavmic changed the title[Serializer] Allow (de)normalization of empty objects in PropertyNorm…WIP: [Serializer] Allow (de)normalization of empty objects in PropertyNorm…May 20, 2022
@carsonbot
Copy link

Hey!

I think@mtarld has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@olsavmicolsavmic changed the titleWIP: [Serializer] Allow (de)normalization of empty objects in PropertyNorm…[Serializer] Allow (de)normalization of empty objects in PropertyNorm…May 23, 2022
@olsavmicolsavmicforce-pushed theolsavmic-property-normalizer-allow-empty-object branch from4989076 tob80705aCompareMay 23, 2022 11:19
@olsavmic
Copy link
ContributorAuthor

@mtarld The original issue is marked asBug, should I target 4.x release or 6.1? I'd say it's rather a feature.

Also, I don't see any documentation for normalizers except forhttps://symfony.com/doc/5.2/serializer/normalizers.html#built-in-normalizers, I guess it's self-documented enough.

And lastly, I'm still wondering if the backward compatible behavior is needed in this edge case. Or at least what about adding a deprecation notice in case the original check does not pass so that we can delete it in a subsequent version? I mean I don't mind and most people configuring their normalizers can probably find this configuration option but it would prevent the unexpected first encounter of thisfeature 😄

@mtarld
Copy link
Contributor

Yes indeed, IMO it must be a feature 🙂

I guess the documentation, code, and context builders are enough.

For the BC migration path part, it is tricky. The behavior of these normalizers is changed (and the same goes for the serializer itself), so we must trigger a deprecation IMHO.

Maybe we could leverage thefunc_num_args function as it does not count the optional args that aren't explicitly given. This will hopefully work as theallowNormalizationOfObjectsWithoutXXX is the last property.
Something likeif (func_num_args() < 6) then trigger a deprecation that tells the user to explicitly give theallowNormalizationOfObjectsWithoutXXX as it'll default totrue in the 7.0 release.

WDYT?

@olsavmicolsavmicforce-pushed theolsavmic-property-normalizer-allow-empty-object branch fromb80705a to14f5c30CompareMay 23, 2022 17:29
@olsavmic
Copy link
ContributorAuthor

olsavmic commentedMay 23, 2022
edited
Loading

Sounds good, I've added the deprecation, updated the default symfony bundle configuration (src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php) and updated tests so that the deprecation is not triggered :)

Do we want to target 6.1 or 6.2 release?

mtarld reacted with thumbs up emoji

@olsavmicolsavmicforce-pushed theolsavmic-property-normalizer-allow-empty-object branch from38a3438 toca505aaCompareMay 23, 2022 17:59
@mtarld
Copy link
Contributor

As 6.1 is in feature freeze, we must target 6.2

Copy link
Contributor

@mtarldmtarld left a comment

Choose a reason for hiding this comment

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

Almost good for me! 🙂

@olsavmicolsavmicforce-pushed theolsavmic-property-normalizer-allow-empty-object branch from2d0f77f tod7114f0CompareMay 27, 2022 17:13
@olsavmicolsavmic requested a review fromyceruto as acode ownerMay 27, 2022 17:13
@olsavmicolsavmic changed the base branch from6.1 to6.2May 27, 2022 17:14
@olsavmicolsavmicforce-pushed theolsavmic-property-normalizer-allow-empty-object branch 2 times, most recently from72c0c98 to02a8212CompareMay 27, 2022 17:25
@OskarStarkOskarStark changed the title[Serializer] Allow (de)normalization of empty objects in PropertyNorm…[Serializer] Allow (de)normalization of empty objects in PropertyNormalizerMay 29, 2022
Copy link
Contributor

@mtarldmtarld left a comment

Choose a reason for hiding this comment

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

LGTM!

@olsavmicolsavmicforce-pushed theolsavmic-property-normalizer-allow-empty-object branch from648b0d4 to9de526dCompareAugust 8, 2022 16:27
@olsavmic
Copy link
ContributorAuthor

Failing checks seem to be unrelated

@nicolas-grekasnicolas-grekas modified the milestones:6.2,6.3Nov 5, 2022
@olsavmic
Copy link
ContributorAuthor

Anything I can do to get a second review and merge it?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mtarldmtarldmtarld approved these changes

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

@ycerutoycerutoAwaiting requested review from yceruto

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

Symfony\Component\Serializer\Normalizer\PropertyNormalizer is unable to construct object without properties
6 participants
@olsavmic@carsonbot@mtarld@fabpot@nicolas-grekas@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp