Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Serializer] Fixed "Warning: Attempt to read property "value" on string" #54851

Merged

Conversation

michaljusiega
Copy link
Contributor

@michaljusiega michaljusiega commented May 6, 2024

Q A
Branch? 7.1 (7.1.0-BETA1)
Bug fix? yes
New feature? no
Deprecations? no
Issues Fixed regresion of #53160
License MIT

Hi! I've updated my project to 7.1.0-BETA1 and I found an error.

After update I got: Warning: Attempt to read property "value" on string in vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:748 because in 733 line the enum-case of value TypeIdentifier has been already readed.

obraz

Quite not sure if tests are possible here.

@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.0-BETA1".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

Copy link
Member

@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

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

Can we cover this change with a test to prevent future regressions?

@michaljusiega
Copy link
Contributor Author

Can we cover this change with a test to prevent future regressions?

I'll try tomorrow.

@michaljusiega
Copy link
Contributor Author

This is a reproduce code at the moment:

class AbstractObjectNormalizerTest extends KernelTestCase
{
    public function testDenormalizeNestedValues()
    {
        $normalizer = self::getContainer()->get(NormalizerInterface::class); // service
        $normalizer->denormalize(['values' => [['1'], ['2'], ['3'], ['4'], ['5']]], TypeClassReproducer::class);
    }
}

class TypeClassReproducer
{
    /**
     * @param array<int, array<int, string>>|null $values
     */
    public function __construct(
        private readonly array|null $values = null,
    ) {
    }
    /** @return array<int, array<int, string>>|null */
    public function getValues(): array|null
    {
        return $this->values;
    }
}

@michaljusiega
Copy link
Contributor Author

michaljusiega commented May 7, 2024

@xabbuh I gave up. Could you help me ?

@xabbuh xabbuh force-pushed the bugfix-attempt-read-on-value-from-enum branch from 58fccef to eda1dfc Compare May 17, 2024 07:16
@xabbuh
Copy link
Member

xabbuh commented May 17, 2024

thanks for the snippet, I was able to create a test based on it 👍

@xabbuh xabbuh force-pushed the bugfix-attempt-read-on-value-from-enum branch from eda1dfc to 975d64c Compare May 17, 2024 07:22
@xabbuh xabbuh force-pushed the bugfix-attempt-read-on-value-from-enum branch from 975d64c to 90251c9 Compare May 17, 2024 07:24
@xabbuh
Copy link
Member

xabbuh commented May 17, 2024

Thank you @michaljusiega.

@xabbuh xabbuh merged commit bb91614 into symfony:7.1 May 17, 2024
7 of 10 checks passed
@michaljusiega michaljusiega deleted the bugfix-attempt-read-on-value-from-enum branch May 17, 2024 07:40
@michaljusiega
Copy link
Contributor Author

Thank you too @xabbuh !

@fabpot fabpot mentioned this pull request May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants