Skip to content

[Serializer] Return an ArrayObject for empty collection objects when PRESERVE_EMPTY_OBJECTS is set #42730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2021

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

In #42619, we tried adding a BC layer for this behavior change, but when reviewing #42699, I figured out there is no possible BC layer: userland implementations (eg an entity returning an empty doctrine collection) won't extend ArrayObject because we ask them to do so.

I therefor propose to return an ArrayObject as of 5.4, relying on the intuition that this should not have much BC impact in practice.

/cc @lyrixx

Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

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

👍🏼

@lyrixx
Copy link
Member

lyrixx commented Aug 25, 2021

CHANGELOG.md must be updated

@nicolas-grekas nicolas-grekas changed the title [Serializer] Always return an ArrayObject for empty collection objects [Serializer] Return an ArrayObject for empty collection objects when PRESERVE_EMPTY_OBJECTS is set Aug 25, 2021
@nicolas-grekas
Copy link
Member Author

CHANGELOG updated

@fabpot
Copy link
Member

fabpot commented Aug 25, 2021

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 2310fc8 into symfony:5.4 Aug 25, 2021
@nicolas-grekas nicolas-grekas deleted the ser-fix branch August 25, 2021 16:16
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