Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] Misconfiguration when multiple serializers are defined #36113

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
davidkmenta opened this issue Mar 17, 2020 · 3 comments
Closed

Comments

@davidkmenta
Copy link

Symfony version(s) affected: 4.3.0

Description
Normalizers and encoders implementing \Symfony\Component\Serializer\SerializerAwareInterface may become inconsistent when multiple serializers are defined.

How to reproduce

  1. Create custom definition of serializer service (autoconfigured, autowired).
  2. Create custom defintion of PropertyNormalizer service (autoconfigured, autowired) and pass it to the serializer from step 1.
  3. Create custom denormalizer and pass it to the custom serializer from step 1 (DON'T autoconfigure or autowire it).

Into the existing serializer service definition (@serializer) is the PropertyNormalizer service mentioned above automatically passed because it is autocofigured. A that's the problem (I guess) because the instance of PropertyNormalizer firstly receives through the \Symfony\Component\Serializer\SerializerAwareTrait::setSerializer new definition of serializer and when the generic @serializer is instatiated the custom serializer inside PropertyNormalizer is overwritten by it but without the custom NON-tagged denormalizer. And that's causing problems when (de)normalizing data...

@xabbuh
Copy link
Member

xabbuh commented Mar 18, 2020

Can you create a small example application that allows to reproduce your issue?

@alanpoulain
Copy link
Contributor

alanpoulain commented Mar 18, 2020

Related information can also be found in the description of my PR: #35374.

This is a real issue. The only workaround is to duplicate the (de)normalizers without autoconfiguring them.

@xabbuh
Copy link
Member

xabbuh commented Mar 26, 2020

I am going to close here for now due to the lack of feedback. Please let us know when you have more information and we can consider to reopen.

@xabbuh xabbuh closed this as completed Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants