8000 [FrameworkBundle] make GetSetMethodNormalizer available by default by dunglas · Pull Request #12295 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] make GetSetMethodNormalizer available by default #12295

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

Closed
wants to merge 1 commit into from

Conversation

dunglas
Copy link
Member
@dunglas dunglas commented Oct 22, 2014
Q A
Bug fix? no
New feature? yes
BC breaks? very limited
Deprecations? no
Tests pass? yes
License MIT
Doc PR not yet

The GetSetMethodNormalizer has not been enabled by default in #6815 because it was broken by design. Since #12098 has been merged, circular references are handled and that normalizer cannot breaks applications.
This PR makes that normalizer automatically available when the serializer is enabled. To keep BC, I've set a "high" priority for this service (higher than the default 0).

@@ -6,6 +6,7 @@

<parameters>
<parameter key="serializer.class">Symfony\Component\Serializer\Serializer</parameter>
<parameter key="serializer.normalizer.get_set_method.class">Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer</parameter>
Copy link
Member

Choose a reason for hiding this comment

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

Afaik it was decided to not use class parameters any more.

Copy link
Member Author

Choose a reason for hiding this comment

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

For consistency should I remove existing class parameters (it's a BC)?
Or is mixing class parameters / no class parameters in the same file OK?

Copy link
Member

Choose a reason for hiding this comment

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

The existing ones must be kept for BC. It's okay to mix them (see for example #12182).

@dunglas dunglas force-pushed the normalizer_service branch from 0f18d65 to 885c238 Compare October 23, 2014 06:57
@dunglas
Copy link
Member Author
dunglas commented Oct 23, 2014

@xabbuh removed class parameter.

@stof
Copy link
Member
stof commented Oct 23, 2014

Avoiding BC is a bad idea. We want to avoid breaking BC, not keeping it.

and making this normalizer run at a high priority is definitely a BC break, as it means it would run before custom normalizers registered the simple way, thus changing the behavior for existing apps

@dunglas
Copy link
Member Author
dunglas commented Oct 23, 2014

@stof sorry I've misspelled my sentence. I want to keep BC of course :)
But it seems that the lower is the value of the "priority" tag, the higher is the "real" priority: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SerializerPass.php#L57

So my current code is OK (or FrameworkBundle must be fixed).

@stof
Copy link
Member
stof commented Oct 23, 2014

@dunglas krsort is meant to sort the high priority first (i.e. sorting in descending order). The effect is to make the high priority win (as the serializer uses the first normalizer supporting the value)

@dunglas
Copy link
Member Author
dunglas commented Oct 23, 2014

@stof Ok I got it. I've missed the r in krsort! I'll fix the code.

@dunglas dunglas force-pushed the normalizer_service branch from 885c238 to 7ad35e4 Compare October 23, 2014 17:48
@dunglas
Copy link
Member Author
dunglas commented Oct 23, 2014

Fixed and squashed.

8000

<!-- Normalizer -->
<service id="serializer.normalizer.get_set_method" class="Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer" public="false">
<!-- Arbitrary "low" priority to keep BC -->
Copy link
Member

Choose a reason for hiding this comment

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

talking about keeping BC in the comment is the wrong explanation. The reason to make it last (even without BC concern) is that it will report (nearly) any object as supported, so it should give other normalizer a chance to pick the object first.

@dunglas
Copy link
Member Author
dunglas commented Nov 21, 2014

Changed according to @stof comments.

@fabpot
Copy link
Member
fabpot commented Dec 12, 2014

Thank you @dunglas.

@fabpot fabpot closed this in f47ade6 Dec 12, 2014
@dunglas dunglas deleted the normalizer_service branch December 5, 2015 09:01
@dunglas dunglas restored the normalizer_service branch December 5, 2015 09:01
@dunglas dunglas deleted the normalizer_service branch December 5, 2015 09:01
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.

4 participants
0