-
Notifications
You must be signed in to change notification settings - Fork 3
IBX-9678: JsonSerializableNormalizer return type mismatch causing 500 error #160
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
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's an overkill but it would be great to have an integration test with a bit more complicated case, like object that uses MoneyObjecy, please see https://github.com/ibexa/rest/blob/main/tests/integration/Serializer/SerializerTest.php
Maybe you could add another case there and use TestDataObject with MoneyObject.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, whole JsonSerializableNormalizer class can be removed, as Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer already exists.
☝️ all we need to take care is to properly register this as a service (under a non-class id, with class declared, if using YAML service files) to the correct serializers.
bebc091 to
2aecebc
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA Approved.
I checked the REST action on the API orders and confirmed that the 500 error in the console is no longer occurring.



Edit from @konradoboza:
It seems, Symfony 7+ has its own counterpart for
JsonSerializableNormalizer, removed our implementation.Description:
JsonSerializableNormalizer is hint typed to return string but we also normalize objects like
Money/Moneythat return an array. If we try to create an order through API on latest Ibexa 5.0 the order would get created but on the return we would get an 500 error. I have changed the hint type to cover array as well.I have also added a test to cover this scenario. Rest package doest not uses
moneyphp/moneypackage anywhere directly so instead of adding a dependency I have created a dummy object with minimal implementation to simulate the behavior of real Money object that returns an array.Discovered while testing https://github.com/ibexa/order-management/pull/137 on 5.0
For QA:
Documentation: