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 denormalizing custom class in UidNormalizer#44600

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

Merged

Conversation

@fancyweb
Copy link
Contributor

QA
Branch?5.3
Bug fix?yes
New feature?no
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

Considering we support denormalizing any subclass ofAbstractUid::class we should not denormalize any$type !== Ulid::class toUuid::class because this is wrong. We need to call$type::fromString (seeTestCustomUid).
ButfromString() is an abstract method, so it cannot be called directly on abstract classes, I guess we should have not supported them from the start. However, since they work right now (since all abstract classes fall back to theUuid:class behavior) we cannot break it. So I propose to deprecate supporting abstract classes in 6.1 and remove it in 7.0.

@fancywebfancywebforce-pushed theserializer/fix-custom-uid branch from0634cf2 toba9e002CompareDecember 13, 2021 16:53
}catch (\InvalidArgumentException$exception) {
thrownewNotNormalizableValueException(sprintf('The data is not a valid "%s" string representation.',$type));
}catch (\Error$e) {
if (str_starts_with($e->getMessage(),'Cannot instantiate abstract class')) {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Catching the error and looking for the message looks better than doing reflection to me, maybe there's a better way?

@nicolas-grekas
Copy link
Member

Thank you@fancyweb.

@nicolas-grekasnicolas-grekas merged commitfdc61b4 intosymfony:5.3Dec 15, 2021
@fancywebfancyweb deleted the serializer/fix-custom-uid branchDecember 15, 2021 11:01
nicolas-grekas added a commit that referenced this pull requestDec 15, 2021
This PR was merged into the 5.3 branch.Discussion----------[Serializer] Fix symfony/uid requirement| Q             | A| ------------- | ---| Branch?       | 5.3| Bug fix?      | no| New feature?  | no| Deprecations? | -| Tickets       | -| License       | MIT| Doc PR        | -#44600 needs8247779Commits-------6a0fd54 [Serializer] Fix symfony/uid requirement
This was referencedDec 29, 2021
nicolas-grekas added a commit that referenced this pull requestFeb 23, 2022
…alization in UidNormalizer (fancyweb)This PR was merged into the 6.1 branch.Discussion----------[Serializer] Deprecate support for abstract uid denormalization in UidNormalizer| Q             | A| ------------- | ---| Branch?       | 6.1| Bug fix?      | no| New feature?  | no| Deprecations? | yes| Tickets       | -| License       | MIT| Doc PR        | -Continuation of#44600. All abstract classes should not be denormalized to Uuid::class. We need a concrete class. Instead of penalizing everyone with reflection in supportsDenormalization(), let's just bubble up the PHP \Error (we are going to do the same in UidValueResolver).Commits-------6fc4287 [Serializer] Deprecate support for abstract uid denormalization in UidNormalizer
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.3

Development

Successfully merging this pull request may close these issues.

3 participants

@fancyweb@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp