Skip to content
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 #3723

Draft
wants to merge 2 commits into
base: 9.0
Choose a base branch
from

Conversation

mhsdesign
Copy link
Member

Ports neos/neos-development-collection#4638 to the Neos Ui, as the class was moved in Neos 9.

What I did

How I did it

How to verify it

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
@github-actions github-actions bot added Bug Label to mark the change as bugfix 9.0 labels Feb 17, 2024
if (
$propertyValue instanceof \JsonSerializable
// todo maybe combine them for performance with a static `isDenormalizable` utility.
&& (new ValueObjectArrayDenormalizer())->supportsDenormalization([], $propertyValue::class)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and neos/flow-development-collection#2766 seems to be missing as a feature for the new cr...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
9.0 Bug Label to mark the change as bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant