Skip to content

Commit 2e2664c

Browse files
authored
fix(serializer): uriTemplate wrong cache usage in hal format (#6313)
* add failing test * prevent components caching between different subresources * fix tests for MongoDB
1 parent 2770a4f commit 2e2664c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Serializer/ItemNormalizer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ private function getComponents(object $object, ?string $format, array $context):
184184

185185
$relation['iri'] = $this->iriConverter->getIriFromResource($object, UrlGeneratorInterface::ABS_PATH, $operation, $childContext);
186186
$relation['operation'] = $operation;
187+
$cacheKey = null;
187188
}
188189

189190
if ($propertyMetadata->isReadableLink()) {
@@ -200,7 +201,7 @@ private function getComponents(object $object, ?string $format, array $context):
200201
}
201202
}
202203

203-
if (false !== $context['cache_key']) {
204+
if ($cacheKey && false !== $context['cache_key']) {
204205
$this->componentsCache[$cacheKey] = $components;
205206
}
206207

0 commit comments

Comments
 (0)