-
-
Notifications
You must be signed in to change notification settings - Fork 224
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: Always unset node property, if set to null #4322
Conversation
See neos/neos-development-collection#4322 if this actually correct behavior or not
From the description and the code itself, I don't really understand this change. But I have the strong feeling that is should be backed by a test |
Yes i see, sorry for being so spare about the details. Id like to "quickly" chat with you about this to structure my mind - after that i could probably write it down more easily, and we could also discuss if my expectations are correct. |
Those quotes around "quickly" make me suspicious :) |
I added some thoughts to #4304 (comment) |
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.
looks good :) wonder why the stuff before was done ;)
Now i only have to come up with a test for this ;) (Thats why its WIP - and also need to rebase it) |
Neos.ContentRepository.Core/Classes/Infrastructure/Property/PropertyConverter.php
Outdated
Show resolved
Hide resolved
166c202
to
e4ebdee
Compare
e4ebdee
to
62ae5a4
Compare
As we discussed previously it is an implementation detail of the adapter to save null values to the database or not, thats why its a bit hard to come up with a test? And as everything passes that seems proof enough this refactoring is correct? |
Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/SerializedPropertyValue.php
Show resolved
Hide resolved
Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/SerializedPropertyValues.php
Outdated
Show resolved
Hide resolved
5eebe27
to
2e92b68
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.
Sorry for being complicated, but I dislike that one of the highest-level APIs now has this awkward withoutUnsets()
method.
I am probably missing something but I expected SerializedProperties
to be just that, a set of serialized properties. But that they would never contain any null
-values.
I.e. that we would filter them out at write time.
I know, that we need it to unset previously existing properties, but I thought that we could put that logic into PropertyValuesToWrite
rather than having something like Node->properties->serialized->withoutUnsets()
which does not make sense to me on the read side at all
Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/SerializedPropertyValue.php
Outdated
Show resolved
Hide resolved
Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/SerializedPropertyValue.php
Outdated
Show resolved
Hide resolved
We discussed to introduce a Additionally we briefly discussed that a property converter for the properties should probably never return |
721fb45
to
7403660
Compare
So i also just wrote a database migration that will update the events. Adding a php compatibility layer would just permanently introduce complexity and possibly bugs. The following things have to be migrated:
Here we just have to omit the null values because its a new node either way:
Also the basically impossible |
fc4299e
to
eb854f7
Compare
And make node get property throw if value deserializes to null.
During extending phpstan to more packages (#4650) the migration was dropped. The code had become already outdated by then as the api was changed a lot. This service should function as boilerplate for new migrations.
After #4405 a lot of things changed.
in the past the job ran sometimes for 6 hours, which is a waste of resources.
295d0d2
to
81d53b6
Compare
As discussed here #4322 (comment) this _can_ likely happen when entity privileges are used.
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.
Cool, fine by me now, shall I hit merge?
(I guess we agreed in the weekyl this is fine) |
Yes i even did some additional testing that the command payload is also correctly migrated and a workspace with migrated changes can be merged. Test cases:
Each of the scenarios worked when being published after switching the branch and applying the |
Neos.Demo followup neos/Neos.Demo#191 |
As discussed here neos/neos-development-collection#4322 (comment) this _can_ likely happen when entity privileges are used.
Previously we made a distinction between unsetting a node property and setting it to null on the write side.
There was setting to null
SerializedPropertyValues::fromArray(['tagName' => new SerializedPropertyValue(null, 'string')])
and unsetSerializedPropertyValues::fromArray(['tagName' => null])
Unsetting a property would only be possible via php api by creating a custom
SerializedPropertyValues
.The read site treats it the same and returns true in hasProperty only if there is a non null value in the database.
As discussed with @bwaidelich
Previously if a property tagName was set to
null
the
NodePropertiesWereSet
event would containand the properties of the node in the projection as well
which this change the the
NodePropertiesWereSet
event would contain:and the properties of the node in the projection would show no hint of this property.
Our logic to decide between unsetting properties and setting them to null was spread through a lot of classes and is a sheer wonder that it worked :D Now with the instruction of the
UnsetPropertyValue
, it is much more obvious how the behaviour works.solves: #4467
Important
This change is breaking to your existing content repository data. To migrate your events please execute:
otherwise you will face this error
SerializedPropertyValue::__construct(): Argument #1 ($value) must be of type ArrayObject|array|string|int|float|bool, null given