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
BUGFIX: Neos Ui JSON serializable property values #4638
Conversation
i will move this over to the neos ui instead and target 9.0 for now one needs to implement an toArray type converter for the value object: https://github.com/sitegeist/Sitegeist.Archaeopteryx/blob/9322b9cb8e4824bcaf7aaa247c23b1244a2f1167/Classes/LinkToArrayForNeosUiConverter.php |
4932c75
to
b264abb
Compare
Edit: As this service still resides in Neos 8.3 in Neos.Neos and will only be moved in Neos 9 to the ui, i were able to fix it here, even-though its considered ui matter. Once this is merged i will open a dedicated pr in Neos.Ui |
Wait why do we need to move it to the UI? Just because the UI is the only place using it? Seems like a very sensible thing to have in any neos also for custom caching or node relation implementations? |
Actually it resides in Neos 9 in the ui already: https://github.com/neos/neos-ui/blob/d581ba73e41d335cb7cb6dc443de9e7dfe1783ba/Classes/Domain/Service/NodePropertyConverterService.php#L218
... i like to have this code encapsulated in the Neos ui.
no one shall use this code ^^ |
im not entirely sure i get you point and understand ... |
I thought the whole property (un)serialize thing could be helpful outside of UI context as well but if we strive to use the serialized properties directly I guess that is fine too... so nvm |
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.
Fine by 👀, 💬 , and me knowing the topic beforehand
Neos.Neos/Classes/Service/Mapping/NodePropertyConverterService.php
Outdated
Show resolved
Hide resolved
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.
I think this needs a lot of dedicated serialize/deserialize tests and also a before after comparison, because I am not sure about some cases people could already have right now (DateTime being one of those). Also we force DateTime to be in UTC (or rather server TZ) atm, so this would no longer be the case.
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.
Nod, nod this seems sensible then :)
This bugfix will make use of the \JsonSerializable interface instead directly when serializing properties for the neos ui. With neos/flow-development-collection#2762 native support for vo's in `flow_json_array` was introduced. That also allows value object support for node properties, as they can be stored directly the node properties flow_json_array. Unfortunately the property serialisation for the NeosUi does NOT use the expected `\JsonSerializable::jsonSerialize` but the property mapper and the `ArrayFromObjectConverter` for object types to get an array that will be json encoded. This works mostly fine but in some cases it fails: - when your `fromArray` fields and property names values dont match - when a "object" subtypes the object mapper is no convertable like the `GuzzleHttp\Psr7\Uri`: ``` Too few arguments to function GuzzleHttp\Psr7\Uri::isAbsolute(), 0 passed in /core/neos-manufacture-highest/Packages/Framework/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php on line 151 and exactly 1 expected ``` Current workarounds are aop: https://github.com/sitegeist/Sitegeist.InspectorGadget/blob/78f5f4a206287b1c4bedf5cb88582ed51cb4a311/Classes/Infrastructure/NodeInfo/NodeInfoPostProcessingAspect.php#L17 Or to use a dumb property mapper: https://github.com/sitegeist/Sitegeist.Archaeopteryx/blob/9322b9cb8e4824bcaf7aaa247c23b1244a2f1167/Classes/LinkToArrayForNeosUiConverter.php#L12C16-L12C78
0cccdff
to
eada1db
Compare
Ports neos/neos-development-collection#4638 to the Neos Ui, as the class was moved in Neos 9. Original commit message: This bugfix will make use of the \JsonSerializable interface instead directly when serializing properties for the neos ui. With neos/flow-development-collection#2762 native support for vo's in `flow_json_array` was introduced. That also allows value object support for node properties, as they can be stored directly the node properties flow_json_array. Unfortunately the property serialisation for the NeosUi does NOT use the expected `\JsonSerializable::jsonSerialize` but the property mapper and the `ArrayFromObjectConverter` for object types to get an array that will be json encoded. This works mostly fine but in some cases it fails: - when your `fromArray` fields and property names values dont match - when a "object" subtypes the object mapper is no convertable like the `GuzzleHttp\Psr7\Uri`: ``` Too few arguments to function GuzzleHttp\Psr7\Uri::isAbsolute(), 0 passed in /core/neos-manufacture-highest/Packages/Framework/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php on line 151 and exactly 1 expected ``` Current workarounds are aop: https://github.com/sitegeist/Sitegeist.InspectorGadget/blob/78f5f4a206287b1c4bedf5cb88582ed51cb4a311/Classes/Infrastructure/NodeInfo/NodeInfoPostProcessingAspect.php#L17 Or to use a dumb property mapper: https://github.com/sitegeist/Sitegeist.Archaeopteryx/blob/9322b9cb8e4824bcaf7aaa247c23b1244a2f1167/Classes/LinkToArrayForNeosUiConverter.php#L12C16-L12C78
This bugfix will make use of the
\JsonSerializable
interface instead directly when serializing properties for the neos ui.With neos/flow-development-collection#2762 native support for vo's in
flow_json_array
was introduced.That also allows value object support for node properties, as they can be stored directly the node properties flow_json_array.
Unfortunately the property serialisation for the NeosUi does NOT use the expected
\JsonSerializable::jsonSerialize
but the property mapper and theArrayFromObjectConverter
for object types to get an array that will be json encoded.This works mostly fine but in some cases it fails:
fromArray
fields and property names values dont matchGuzzleHttp\Psr7\Uri
:Current workarounds are aop:
https://github.com/sitegeist/Sitegeist.InspectorGadget/blob/78f5f4a206287b1c4bedf5cb88582ed51cb4a311/Classes/Infrastructure/NodeInfo/NodeInfoPostProcessingAspect.php#L17
Or to use a dumb property mapper:
https://github.com/sitegeist/Sitegeist.Archaeopteryx/blob/9322b9cb8e4824bcaf7aaa247c23b1244a2f1167/Classes/LinkToArrayForNeosUiConverter.php#L12C16-L12C78
Upgrade instructions
Review instructions
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions