Skip to content

[Serializer] ensure ChainEncoder/ChainDecoder properly consider the context #43231

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 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
invert logic
  • Loading branch information
Guite committed Oct 28, 2021
commit 25cefc27843e560f376afb3ee85265dbc60a375c
4 changes: 2 additions & 2 deletions src/Symfony/Component/Serializer/Encoder/ChainDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getDecoder(string $format, array $context): DecoderInterface
{
$hasContext = 0 < \count($context);
if (
$hasContext
!$hasContext
&& isset($this->decoderByFormat[$format])
&& isset($this->decoders[$this->decoderByFormat[$format]])
) {
Expand All @@ -72,7 +72,7 @@ public function getDecoder(string $format, array $context): DecoderInterface

foreach ($this->decoders as $i => $decoder) {
if ($decoder->supportsDecoding($format, $context)) {
if ($hasContext) {
if (!$hasContext) {
// cache decoder if no dynamic context is given
$this->decoderByFormat[$format] = $i;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Serializer/Encoder/ChainEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getEncoder(string $format, array $context): EncoderInterface
{
$hasContext = 0 < \count($context);
if (
$hasContext
!$hasContext
&& isset($this->encoderByFormat[$format])
&& isset($this->encoders[$this->encoderByFormat[$format]])
) {
Expand All @@ -90,7 +90,7 @@ public function getEncoder(string $format, array $context): EncoderInterface

foreach ($this->encoders as $i => $encoder) {
if ($encoder->supportsEncoding($format, $context)) {
if ($hasContext) {
if (!$hasContext) {
// cache encoder if no dynamic context is given
$this->encoderByFormat[$format] = $i;
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy