-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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 our terms of service and privacy 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
Conversation
05c76bb
to
8d2411b
Compare
8d2411b
to
1c979c0
Compare
1c979c0
to
e5c2029
Compare
Thank you @soyuka. |
@nicolas-grekas |
You should not expose ArrayCollection but use |
* Use symfony/serializer >=4.4.9-5.0.9 to fix issues symfony/symfony#34455 symfony/symfony#36601 * Lowest + legacy test suite missing git * fix Symfony 5 router generate with reference type
Today, using
PRESERVE_EMPTY_OBJECTS
(introduced in 4.0), the JSON serialization of:Outputs:
Instead of the expected:
This issue comes from the Serializer that transforms
Traversable
to an Array here. Also, theAbstractObjectNormalizer
doesn't support Traversable, but he allows to preserve empty objects.I propose this patch where the fix doesn't transform a
Traversable
to 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 attached other-fix.patch to see the alternative patch.