Skip to content

Commit 2e92aea

Browse files
committed
Merge 3.4
2 parents da659fa + bc9da99 commit 2e92aea

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## v3.3.9
4+
5+
### Bug fixes
6+
7+
* [84df46786](https://github.com/api-platform/core/commit/84df4678618869f439a7995a2534440c031e10f3) fix(jsonld): remove request uri variables when denormalizing output (#6467)
8+
* [ffb4ad31f](https://github.com/api-platform/core/commit/ffb4ad31f30b531a5102da8cd92235e070f43b86) fix(jsonld): mitigate #6465 (#6469)
9+
310
## v3.3.8
411

512
### Bug fixes

src/Serializer/AbstractItemNormalizer.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ public function normalize(mixed $object, ?string $format = null, array $context
139139
// Never remove this, with `application/json` we don't use our AbstractCollectionNormalizer and we need
140140
// to remove the collection operation from our context or we'll introduce security issues
141141
if (isset($context['operation']) && $context['operation'] instanceof CollectionOperationInterface) {
142-
unset($context['operation_name']);
143-
unset($context['operation']);
144-
unset($context['iri']);
142+
unset($context['operation_name'], $context['operation'], $context['iri']);
145143
}
146144

147145
if ($this->resourceClassResolver->isResourceClass($resourceClass)) {
@@ -174,8 +172,7 @@ public function normalize(mixed $object, ?string $format = null, array $context
174172
$data = parent::normalize($object, $format, $context);
175173

176174
$context['data'] = $data;
177-
unset($context['property_metadata']);
178-
unset($context['api_attribute']);
175+
unset($context['property_metadata'], $context['api_attribute']);
179176

180177
if ($emptyResourceAsIri && \is_array($data) && 0 === \count($data)) {
181178
$context['data'] = $iri;
@@ -758,6 +755,7 @@ protected function getAttributeValue(object $object, string $attribute, ?string
758755
unset(
759756
$context['resource_class'],
760757
$context['force_resource_class'],
758+
$context['uri_variables'],
761759
);
762760

763761
// Anonymous resources
@@ -788,8 +786,11 @@ protected function getAttributeValue(object $object, string $attribute, ?string
788786
throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class));
789787
}
790788

791-
unset($context['resource_class']);
792-
unset($context['force_resource_class']);
789+
unset(
790+
$context['resource_class'],
791+
$context['force_resource_class'],
792+
$context['uri_variables']
793+
);
793794

794795
$attributeValue = $this->propertyAccessor->getValue($object, $attribute);
795796

@@ -847,8 +848,7 @@ protected function normalizeRelation(ApiProperty $propertyMetadata, ?object $rel
847848
$context['iri'] = $iri = $this->iriConverter->getIriFromResource(resource: $relatedObject, context: $context);
848849
$context['data'] = $iri;
849850
$context['object'] = $relatedObject;
850-
unset($context['property_metadata']);
851-
unset($context['api_attribute']);
851+
unset($context['property_metadata'], $context['api_attribute']);
852852

853853
if ($this->tagCollector) {
854854
$this->tagCollector->collect($context);
@@ -906,6 +906,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
906906
) {
907907
$resourceClass = $this->resourceClassResolver->getResourceClass(null, $className);
908908
$context['resource_class'] = $resourceClass;
909+
unset($context['uri_variables']);
909910

910911
return $this->denormalizeCollection($attribute, $propertyMetadata, $type, $resourceClass, $value, $format, $context);
911912
}
@@ -930,7 +931,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
930931
throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', DenormalizerInterface::class));
931932
}
932933

933-
unset($context['resource_class']);
934+
unset($context['resource_class'], $context['uri_variables']);
934935

935936
return $this->serializer->denormalize($value, $className.'[]', $format, $context);
936937
}
@@ -940,7 +941,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
940941
throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', DenormalizerInterface::class));
941942
}
942943

943-
unset($context['resource_class']);
944+
unset($context['resource_class'], $context['uri_variables']);
944945

945946
return $this->serializer->denormalize($value, $className, $format, $context);
946947
}

tests/Fixtures/app/AppKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [
274274
$c->prependExtensionConfig('doctrine', [
275275
'orm' => [
276276
'report_fields_where_declared' => true,
277-
'controller_resolver' => ['auto_mapping' => true],
277+
'controller_resolver' => ['auto_mapping' => false],
278278
'enable_lazy_ghost_objects' => true,
279279
],
280280
]);

0 commit comments

Comments
 (0)