BUGFIX: Properly handle object identity DTOs in select box editor #3482
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes: #2553
The Problem
A node property value may be persisted as an object identity DTO:
If this is the case and the property is configured to be edited via select box, the persisted serialized object identity DTO is not recognized by the selectbox.
Reproduction
You'll need to prepare the following files:
[Insert Path To Package]/Configuration/NodeTypes.[Insert Some Content Node Type Name].yaml:
☝️ This one's to have an example with two select box editors covering both the single-select and the multi-select case. You may add this to any existing node type or create a new one (can be a document as well).
[Insert Path To Package]/Configuration/Settings.Neos.Neos.yaml:
☝️ This one's to achieve default type conversion and editor assignment for
Neos\Media\Domain\Model\Tag
and it's array counterpart. Funny side note: #2553 seems to suggest that this is actually supposed to be the default. During my research I was unable to confirm this, but it would make sense :)[Insert Path To Package]/Classes/Application/DataSource/TagDataSource.php:
☝️ This is the data source that provides our select boxes from above with options straight from the Media package's tag repository.
For reproduction, just add a node of the type from above and see what happens if you set the select box to a value and then reload.
The solution
It's a bit of a lazy solution, but I couldn't think of anything more sophisticated that wouldn't break the select box editor. The gist is: I added a function that pre-processes incoming select box editor values and converts any detected object identity DTO down to it's string-based identity.