Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e4ada73

Browse filesBrowse files
bug #51456 [Serializer] Fix serialized name with groups during denormalization (mtarld)
This PR was merged into the 6.3 branch. Discussion ---------- [Serializer] Fix serialized name with groups during denormalization | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #51238 | License | MIT | Doc PR | Commits ------- 4539850 [Serializer] Fix serialized name with groups
2 parents ee534ea + 4539850 commit e4ada73
Copy full SHA for e4ada73

File tree

Expand file treeCollapse file tree

2 files changed

+7
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-3
lines changed

‎src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,14 @@ private function getCacheValueForAttributesMetadata(string $class, array $contex
127127
throw new LogicException(sprintf('Found SerializedName and SerializedPath annotations on property "%s" of class "%s".', $name, $class));
128128
}
129129

130-
$groups = $metadata->getGroups();
131-
if (!$groups && ($context[AbstractNormalizer::GROUPS] ?? [])) {
130+
$metadataGroups = $metadata->getGroups();
131+
$contextGroups = (array) ($context[AbstractNormalizer::GROUPS] ?? []);
132+
133+
if ($contextGroups && !$metadataGroups) {
132134
continue;
133135
}
134-
if ($groups && !array_intersect($groups, (array) ($context[AbstractNormalizer::GROUPS] ?? []))) {
136+
137+
if ($metadataGroups && !array_intersect($metadataGroups, $contextGroups) && !\in_array('*', $contextGroups, true)) {
135138
continue;
136139
}
137140

‎src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public static function attributeAndContextProvider()
149149
['buzForExport', 'buz', ['groups' => 'b']],
150150
['buz', 'buz', ['groups' => ['c']]],
151151
['buz', 'buz', []],
152+
['buzForExport', 'buz', ['groups' => ['*']]],
152153
];
153154
}
154155

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.