Skip to content

Commit 9f87a34

Browse files
minor symfony#52716 [Serializer] do not detect the deserialization_path context value twice (xabbuh)
This PR was merged into the 6.3 branch. Discussion ---------- [Serializer] do not detect the deserialization_path context value twice | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT symfony#52713 must not be applied on 6.3+ as the logic is already part of the `getAttributeDenormalizationContext()` method introduced in symfony#46680. Commits ------- 9b027a5 do not detect the deserialization_path context value twice
2 parents 09e2cba + 9b027a5 commit 9f87a34

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,12 @@ protected function instantiateObject(array &$data, string $class, array &$contex
342342
$missingConstructorArguments = [];
343343
$params = [];
344344
$unsetKeys = [];
345-
$objectDeserializationPath = $context['deserialization_path'] ?? null;
346345

347346
foreach ($constructorParameters as $constructorParameter) {
348347
$paramName = $constructorParameter->name;
349348
$attributeContext = $this->getAttributeDenormalizationContext($class, $paramName, $context);
350349
$key = $this->nameConverter ? $this->nameConverter->normalize($paramName, $class, $format, $context) : $paramName;
351350

352-
$context['deserialization_path'] = $objectDeserializationPath ? $objectDeserializationPath.'.'.$paramName : $paramName;
353-
354351
$allowed = false === $allowedAttributes || \in_array($paramName, $allowedAttributes);
355352
$ignored = !$this->isAllowedAttribute($class, $paramName, $format, $context);
356353
if ($constructorParameter->isVariadic()) {
@@ -406,15 +403,13 @@ protected function instantiateObject(array &$data, string $class, array &$contex
406403
sprintf('Failed to create object because the class misses the "%s" property.', $constructorParameter->name),
407404
$data,
408405
['unknown'],
409-
$objectDeserializationPath,
406+
$context['deserialization_path'] ?? null,
410407
true
411408
);
412409
$context['not_normalizable_value_exceptions'][] = $exception;
413410
}
414411
}
415412

416-
$context['deserialization_path'] = $objectDeserializationPath;
417-
418413
if ($missingConstructorArguments) {
419414
throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires the following parameters to be present : "$%s".', $class, implode('", "$', $missingConstructorArguments)), 0, null, $missingConstructorArguments, $class);
420415
}

0 commit comments

Comments
 (0)