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

Skip to content

Commit fd00244

Browse files
committed
do not overwrite the cache key when it is false
1 parent 4eb23d8 commit fd00244

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ protected function createChildContext(array $parentContext, string $attribute, ?
783783
$context = parent::createChildContext($parentContext, $attribute, $format);
784784
if ($context['cache_key'] ?? false) {
785785
$context['cache_key'] .= '-'.$attribute;
786-
} else {
786+
} elseif (false !== ($context['cache_key'] ?? null)) {
787787
$context['cache_key'] = $this->getCacheKey($format, $context);
788788
}
789789

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,6 @@ public function testProvidingContextCacheKeyGeneratesSameChildContextCacheKey()
555555
$foobar->foo = new EmptyDummy();
556556
$foobar->bar = 'bar';
557557
$foobar->baz = 'baz';
558-
$data = [
559-
'foo' => [],
560-
'bar' => 'bar',
561-
'baz' => 'baz',
562-
];
563558

564559
$normalizer = new class() extends AbstractObjectNormalizerDummy {
565560
public $childContextCacheKey;
@@ -600,11 +595,6 @@ public function testChildContextKeepsOriginalContextCacheKey()
600595
$foobar->foo = new EmptyDummy();
601596
$foobar->bar = 'bar';
602597
$foobar->baz = 'baz';
603-
$data = [
604-
'foo' => [],
605-
'bar' => 'bar',
606-
'baz' => 'baz',
607-
];
608598

609599
$normalizer = new class() extends AbstractObjectNormalizerDummy {
610600
public $childContextCacheKey;
@@ -640,11 +630,6 @@ public function testChildContextCacheKeyStaysFalseWhenOriginalCacheKeyIsFalse()
640630
$foobar->foo = new EmptyDummy();
641631
$foobar->bar = 'bar';
642632
$foobar->baz = 'baz';
643-
$data = [
644-
'foo' => [],
645-
'bar' => 'bar',
646-
'baz' => 'baz',
647-
];
648633

649634
$normalizer = new class() extends AbstractObjectNormalizerDummy {
650635
public $childContextCacheKey;

0 commit comments

Comments
 (0)