Skip to content

Conversation

alanpoulain
Copy link
Member

@alanpoulain alanpoulain commented Sep 22, 2022

Supersedes #4363.

Fixes an issue with the use of EMPTY_ARRAY_AS_OBJECT and PRESERVE_EMPTY_OBJECTS in the serialization context.

Since the CollectionNormalizer was taking over the serialization of all iterables, the Symfony serializer was not called when normalizing a "raw" collection.

Adding a better supports method fixes the issue.
The supports method is not cacheable anymore since it relies on the context.

@alanpoulain alanpoulain force-pushed the fix/empty-array-as-object branch from 5544a4a to c87c1b7 Compare September 22, 2022 10:13
@alanpoulain alanpoulain force-pushed the fix/empty-array-as-object branch 3 times, most recently from 5303b84 to d0880b3 Compare September 22, 2022 10:35
Fixes an issue with the use of `EMPTY_ARRAY_AS_OBJECT` and
`PRESERVE_EMPTY_OBJECTS` in the serialization context.
Since the CollectionNormalizer was taking over the serialization
of all iterables, the Symfony serializer was not
called when normalizing a "raw" collection.
Adding a better supports method fixes the issue.
The supports method is not cacheable anymore since it relies on the context.
@alanpoulain alanpoulain force-pushed the fix/empty-array-as-object branch from d0880b3 to 469d907 Compare September 22, 2022 10:37
@soyuka soyuka merged commit 08450c2 into api-platform:3.0 Sep 29, 2022
soyuka added a commit to soyuka/core that referenced this pull request Oct 27, 2022
soyuka added a commit to soyuka/core that referenced this pull request Nov 9, 2022
soyuka added a commit to soyuka/core that referenced this pull request Nov 9, 2022
soyuka added a commit that referenced this pull request Nov 12, 2022
* fix(serializer): empty object as array with supports cache

reverts #4999

* fix issue when empty operation

* revert 08450c2

* review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants