-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Doctrine Collections should be an array #37041
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
Comments
You should not expose |
@soyuka this also affected us somehow when orm paginator from api-platform returned zero results we started to get an empty object instead of empty array (for an application/json request). |
I'd like to reproduce this @norkunas because it is indeed a bad behavior. I still believe that #36601 is legit or we should rollback this which actually causes the issue in the first place with |
I agree that merged PR is a good one, but then api-platform should do the work to serialize paginator as empty array :) |
@soyuka it's BC! And this is unexpected behavior and completely unusable in real world. for example:
In symfony 4.4.8 it's works as expected. DoctrineCollections should be implement JsonSerializable. But without it this change breaks a lot of production code. |
What works as expected? Because normalizing an empty
|
Does #37049 fix the issue? |
Indeed, having the |
@xabbuh Yes, it works. |
IMHO we should explicitly whitelist the old behavior for ArrayObject and instances of Doctrine Collections because they are designed to store lists (not maps) and it makes sense to always serialize them as JSON arrays (not objects). |
… empty array objects (xabbuh) This PR was merged into the 4.4 branch. Discussion ---------- [Serializer] take into account the context when preserving empty array objects | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #37041 | License | MIT | Doc PR | Commits ------- 98fff21 take into account the context when preserving empty array objects
Symfony version(s) affected: 4.4.9
Description
After this change #36601 empty Doctrine Collections became objects instead of empty arrays
How to reproduce
The text was updated successfully, but these errors were encountered: