Skip to content

Commit d7e6148

Browse files
bug #59367 [PropertyInfo] Make sure that SerializerExtractor returns null for invalid class metadata (wuchen90)
This PR was merged into the 6.4 branch. Discussion ---------- [PropertyInfo] Make sure that SerializerExtractor returns null for invalid class metadata | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | License | MIT When we try to call `getProperties` with a classname that doesn't exist, the classMetadataFactory will break. In this case, this method should return `null` in order to fallback to other instances of `PropertyListExtractorInterface` in case we're accessing this `getProperties` method with `\Symfony\Component\PropertyInfo\PropertyInfoExtractor`. Commits ------- 7bc832e fix(property-info): make sure that SerializerExtractor returns null for invalid class metadata
2 parents d6fa9a8 + 7bc832e commit d7e6148

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getProperties(string $class, array $context = []): ?array
3434
return null;
3535
}
3636

37-
if (!$this->classMetadataFactory->getMetadataFor($class)) {
37+
if (!$this->classMetadataFactory->hasMetadataFor($class)) {
3838
return null;
3939
}
4040

src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,9 @@ public function testGetPropertiesWithAnyGroup()
5555
{
5656
$this->assertSame(['analyses', 'feet'], $this->extractor->getProperties(AdderRemoverDummy::class, ['serializer_groups' => null]));
5757
}
58+
59+
public function testGetPropertiesWithNonExistentClassReturnsNull()
60+
{
61+
$this->assertSame(null, $this->extractor->getProperties('NonExistent'));
62+
}
5863
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy