Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] Fix deserializing object collection properties#51369

Merged
nicolas-grekas merged 1 commit into
symfony:6.3from
X-Coder264:fix-deserializing-object-collection-properties
Aug 23, 2023
Merged

[Serializer] Fix deserializing object collection properties#51369
nicolas-grekas merged 1 commit into
symfony:6.3from
X-Coder264:fix-deserializing-object-collection-properties

Conversation

@X-Coder264
Copy link
Copy Markdown
Contributor

@X-Coder264 X-Coder264 commented Aug 12, 2023

Q A
Branch? 6.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #51261
License MIT
Doc PR -

On Symfony <= 6.2 serializer versions the supportsDenormalization was always called in \Symfony\Component\Serializer\Serializer::getDenormalizer.

When the getSupportedTypes logic was introduced for Symfony 6.3 serializer some if statement conditions were introduced and if they are true the supportsDenormalization logic is not called at all anymore. Those conditions currently prevent a legit use-case that worked prior to 6.3 from calling the supportsDenormalization method - the case being when the denormalizer is supposed to denormalize a collection/array of objects. This use-case still works even on the 6.3 serializer as long as the denormalizer does not implement the new getSupportedTypes method, but that is triggering a deprecation.

This PR aims to fix that so that denormalizing an array of objects still works even when using the new getSupportedTypes method in a denormalizer.

cc @tucksaun @nicolas-grekas

Copy link
Copy Markdown
Contributor

@andersmateusz andersmateusz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this on my local environment. Seems legit.

Comment thread src/Symfony/Component/Serializer/Serializer.php Outdated
@X-Coder264 X-Coder264 force-pushed the fix-deserializing-object-collection-properties branch from 7ad9e6e to 32dc134 Compare August 22, 2023 18:29
@nicolas-grekas
Copy link
Copy Markdown
Member

Thank you @X-Coder264.

@nicolas-grekas nicolas-grekas merged commit 469f1cc into symfony:6.3 Aug 23, 2023
@X-Coder264 X-Coder264 deleted the fix-deserializing-object-collection-properties branch August 23, 2023 10:15
@fabpot fabpot mentioned this pull request Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants