Skip to content

Commit b1098f8

Browse files
Merge branch '3.4' into 4.4
* 3.4: [PropertyAccess] fix tests [WebProfilerBundle] fix test remove assertions that can never be reached [PropertyAccess] Improve message of unitialized property in php 7.4 [HttpFoundation] Fixed session migration with custom cookie lifetime [Serializer] Remove unused variable Allow URL-encoded special characters in basic auth part of URLs [Serializer] Fix unitialized properties (from PHP 7.4.2) when serializing context for the cache key [Validator] Add missing Ukrainian and Russian translations No need to reconnect the bags to the session Support for Content Security Policy style-src-elem and script-src-elem in WebProfiler [PropertyInfo][ReflectionExtractor] Check the array mutator prefixes last when the property is singular
2 parents 2a508a5 + 8e02b98 commit b1098f8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Normalizer/AbstractObjectNormalizer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ private function validateAndDenormalize(string $currentClass, string $attribute,
482482
*/
483483
protected function denormalizeParameter(\ReflectionClass $class, \ReflectionParameter $parameter, $parameterName, $parameterData, array $context, $format = null)
484484
{
485-
if (null === $this->propertyTypeExtractor || null === $types = $this->propertyTypeExtractor->getTypes($class->getName(), $parameterName)) {
485+
if (null === $this->propertyTypeExtractor || null === $this->propertyTypeExtractor->getTypes($class->getName(), $parameterName)) {
486486
return parent::denormalizeParameter($class, $parameter, $parameterName, $parameterData, $context, $format);
487487
}
488488

@@ -617,6 +617,7 @@ private function getCacheKey(?string $format, array $context)
617617
unset($context[$key]);
618618
}
619619
unset($context[self::EXCLUDE_FROM_CACHE_KEY]);
620+
unset($context[self::OBJECT_TO_POPULATE]);
620621
unset($context['cache_key']); // avoid artificially different keys
621622

622623
try {

Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ public function testDenormalizeStringCollectionDecodedFromXmlWithTwoChildren()
174174
$this->assertEquals('bar', $stringCollection->children[1]);
175175
}
176176

177+
public function testDenormalizeNotSerializableObjectToPopulate()
178+
{
179+
$normalizer = new AbstractObjectNormalizerDummy();
180+
$normalizedData = $normalizer->denormalize(['foo' => 'foo'], Dummy::class, null, [AbstractObjectNormalizer::OBJECT_TO_POPULATE => new NotSerializable()]);
181+
182+
$this->assertSame('foo', $normalizedData->foo);
183+
}
184+
177185
private function getDenormalizerForStringCollection()
178186
{
179187
$extractor = $this->getMockBuilder(PhpDocExtractor::class)->getMock();
@@ -448,3 +456,15 @@ public function setSerializer(SerializerInterface $serializer)
448456
$this->serializer = $serializer;
449457
}
450458
}
459+
460+
class NotSerializable
461+
{
462+
public function __sleep()
463+
{
464+
if (class_exists(\Error::class)) {
465+
throw new \Error('not serializable');
466+
}
467+
468+
throw new \Exception('not serializable');
469+
}
470+
}

0 commit comments

Comments
 (0)