Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Serializer] do not transform empty \Traversable to Array#36601
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[Serializer] do not transform empty \Traversable to Array#36601
Uh oh!
There was an error while loading.Please reload this page.
Conversation
05c76bb to8d2411bCompare8d2411b to1c979c0CompareUh oh!
There was an error while loading.Please reload this page.
1c979c0 toe5c2029Comparenicolas-grekas commentedMay 1, 2020
Thank you@soyuka. |
Gemorroj commentedJun 1, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas |
soyuka commentedJun 1, 2020
You should not expose ArrayCollection but use |
Plopix commentedJun 2, 2020
* Use symfony/serializer >=4.4.9-5.0.9 to fix issuessymfony/symfony#34455symfony/symfony#36601* Lowest + legacy test suite missing git* fix Symfony 5 router generate with reference type
Uh oh!
There was an error while loading.Please reload this page.
Today, using
PRESERVE_EMPTY_OBJECTS(introduced in 4.0), the JSON serialization of:Outputs:
{"foo":[],"bar":["notempty"],"baz":{"nested":[]}}Instead of the expected:
{"foo":{},"bar":["notempty"],"baz":{"nested":{}}}This issue comes from the Serializer that transforms
Traversableto an Arrayhere. Also, theAbstractObjectNormalizerdoesn't support Traversable, but he allows to preserve empty objects.I propose this patch where the fix doesn't transform a
Traversableto an Array. I see another way to patch this in which we could allow empty Traversable in theAbstractObjectNormalizer(not sure it's better though). See attachedother-fix.patch to see the alternative patch.