From c2c03738b2de2a0b22aad754890d64c4bde6f88b Mon Sep 17 00:00:00 2001 From: Aerendir Date: Wed, 9 Aug 2023 16:51:26 +0200 Subject: [PATCH] fix: restore the use of placeholders named differently than id --- src/Serializer/AbstractItemNormalizer.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Serializer/AbstractItemNormalizer.php b/src/Serializer/AbstractItemNormalizer.php index 3a1bdd0eaf1..05da02d5a2c 100644 --- a/src/Serializer/AbstractItemNormalizer.php +++ b/src/Serializer/AbstractItemNormalizer.php @@ -513,9 +513,12 @@ protected function denormalizeCollection(string $attribute, ApiProperty $propert $collectionKeyType = $type->getCollectionKeyTypes()[0] ?? null; $collectionKeyBuiltinType = $collectionKeyType?->getBuiltinType(); $childContext = $this->createChildContext(['resource_class' => $className] + $context, $attribute, $format); - unset($childContext['uri_variables']); - if ($this->resourceMetadataCollectionFactory) { - $childContext['operation'] = $this->resourceMetadataCollectionFactory->create($className)->getOperation(); + $lastUriVariable = \array_key_exists('uri_variables', $childContext) ? array_key_last($childContext['uri_variables']) : null; + if ('id' === $lastUriVariable) { + unset($childContext['uri_variables']); + if ($this->resourceMetadataCollectionFactory) { + $childContext['operation'] = $this->resourceMetadataCollectionFactory->create($className)->getOperation(); + } } $values = [];