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] FixObjectNormalizer gives warnings on normalizing with public static property#58255

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
nicolas-grekas merged 1 commit intosymfony:6.4fromalaugks:issue-58221
Oct 3, 2024

Conversation

@alaugks
Copy link
Contributor

@alaugksalaugks commentedSep 13, 2024
edited by nicolas-grekas
Loading

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#58221
LicenseMIT

The error message has been occurring since version 6.4.11/7.1.2. If the condition is changed to version >=7.1.2, the error message no longer occurs.

The error is thrown with the following ObjectNormalizer configuration:

$class =newclass {publicstaticstring$foo ="hallo";};$normalizer =newObjectNormalizer(newClassMetadataFactory(newAttributeLoader()));$normalizer->normalize($class);

(\is_object($classOrObject) && $this->propertyAccessor->isReadable($classOrObject, $attribute)) is true and therefore the entire condition is true.

I moved the condition into a method to improve readability and reduce complexity.

All serializer tests are successful.

Condition

For better readability here with breaks.

7.1.1
https://github.com/symfony/symfony/blob/v7.1.1/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php#L180

if (!isset(self::$isReadableCache[$class.$attribute])) {self::$isReadableCache[$class.$attribute] =$this->propertyInfoExtractor->isReadable($class,$attribute)    ||$this->hasAttributeAccessorMethod($class,$attribute);}

>=7.2.2
https://github.com/symfony/symfony/blob/v7.1.2/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php#L180

if (!isset(self::$isReadableCache[$class.$attribute])) {self::$isReadableCache[$class.$attribute] =    (\is_object($classOrObject) &&$this->propertyAccessor->isReadable($classOrObject,$attribute))    ||$this->propertyInfoExtractor->isReadable($class,$attribute)    ||$this->hasAttributeAccessorMethod($class,$attribute);}

Fixed condition

if (!isset(self::$isReadableCache[$class.$attribute])) {self::$isReadableCache[$class.$attribute] =$this->propertyInfoExtractor->isReadable($class,$attribute)    ||$this->hasAttributeAccessorMethod($class,$attribute)    || (\is_object($classOrObject) &&$this->propertyAccessor->isReadable($classOrObject,$attribute));}

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "7.1" but it seems your PR description refers to branch ">= 7.1.2".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@xabbuh
Copy link
Member

Does this also affect 6.4?

@alaugks
Copy link
ContributorAuthor

@xabbuh It also affects 6.4. I have tested it with v6.4.11.

@xabbuhxabbuh modified the milestones:7.1,6.4Sep 13, 2024
@alaugks
Copy link
ContributorAuthor

@alexandre-daubois try-catch is removed. However, I have leftexpectNotToPerformAssertions() in the test so that the test is not marked with "This test did not perform any assertions".

alexandre-daubois reacted with thumbs up emoji

@alexandre-daubois
Copy link
Member

@xabbuh It also affects 6.4. I have tested it with v6.4.11.

You may rebase your PR onto 6.4 and change the target branch of the PR. This way, the fix is available on all (still supported) affected branches

@OskarStarkOskarStark changed the title[Serializer] Fix ObjectNormalizer gives warnings on normalizing with static property[Serializer] FixObjectNormalizer gives warnings on normalizing with static propertySep 14, 2024
alaugks added a commit to alaugks/symfony that referenced this pull requestSep 14, 2024
@alaugksalaugks changed the title[Serializer] FixObjectNormalizer gives warnings on normalizing with static property[Serializer] FixObjectNormalizer gives warnings on normalizing with public static propertySep 14, 2024
Copy link
Member

@xabbuhxabbuh left a comment

Choose a reason for hiding this comment

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

LGTM

@nicolas-grekas
Copy link
Member

Thank you@alaugks.

alaugks reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas merged commitf5a5104 intosymfony:6.4Oct 3, 2024
9 of 10 checks passed
This was referencedOct 27, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas left review comments

@stofstofstof left review comments

@alexandre-dauboisalexandre-dauboisalexandre-daubois left review comments

@xabbuhxabbuhxabbuh approved these changes

@lyrixxlyrixxAwaiting requested review from lyrixx

@ycerutoycerutoAwaiting requested review from yceruto

@welcoMatticwelcoMatticAwaiting requested review from welcoMattic

@kbondkbondAwaiting requested review from kbond

@chalasrchalasrAwaiting requested review from chalasr

@OskarStarkOskarStarkAwaiting requested review from OskarStark

@jderussejderusseAwaiting requested review from jderusse

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

7 participants

@alaugks@carsonbot@xabbuh@alexandre-daubois@nicolas-grekas@dunglas@stof

[8]ページ先頭

©2009-2025 Movatter.jp