8000 [Serializer] ChainEncoder does not honor context support check if called repeatedly · Issue #38270 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content 8000
[Serializer] ChainEncoder does not honor context support check if called repeatedly #38270
Closed
@Guite

Description

@Guite

ChainEncoder#getEncoder method reads:

        if (isset($this->encoderByFormat[$format])
            && isset($this->encoders[$this->encoderByFormat[$format]])
        ) {
            return $this->encoders[$this->encoderByFormat[$format]];
        }

        foreach ($this->encoders as $i => $encoder) {
            if ($encoder->supportsEncoding($format, $context)) {
                $this->encoderByFormat[$format] = $i;

                return $encoder;
            }
        }

If that method is called more than once with different $context arguments the wrong encoder could be returned because $encoder->supportsEncoding($format, $context) is not called again.

Hence, I disabled the first check and return statement and things worked like a charm.

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

      0