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

Skip to content

[Serializer] Misconfiguration when multiple serializers are defined #36113

Closed
@davidkmenta

Description

@davidkmenta

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...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions