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

BUG: Cannot unset defaultValue via CreateNodeAggregateWithNode::$initialPropertyValues #5154

Open
mhsdesign opened this issue Jun 21, 2024 · 4 comments
Labels

Comments

@mhsdesign
Copy link
Member

While the change #4322 improved the unset handling of properties a lot, it introduced a regression.

Using the following NodeType

'Flowpack.NodeTemplates:Content.Properties':
  properties:
    unsetValueWithDefault:
      defaultValue: true
      type: boolean

and creating it but using

PropertyValuesToWrite::fromArray(["unsetValueWithDefault" => null])

would originally set unsetValueWithDefault to NULL in the database. This was the behaviour in Neos 8.3 and Neos 9 before the mentioned change. Now when fetching the nodes properties we get the following result - the default value is still present:

-        "unsetValueWithDefault": null
+        "unsetValueWithDefault": true

The reason for that is that we filter out the unsets when creating a node (under the impression that no one would do this ^^):

A workaround for now is to followup with a SetNodeProperties command

@mhsdesign mhsdesign added the 9.0 label Jun 21, 2024
@kitsunet
Copy link
Member

nvm deleted my previous comment I thought unsetsValueWithDefault is a feature here^^ Still seems right behavior?

@mhsdesign
Copy link
Member Author

Hmmm i dont think its right if a followup SetNodeProperties can unset that property like i did here: (because i had to precise tests 😂 and couldnt let it slip)

https://github.com/Flowpack/Flowpack.NodeTemplates/blob/4d1ccfa71674054fe2189d2e984a8c86609d3491/Classes/Domain/NodeCreation/NodeCreationService.php#L81-L92

@kitsunet
Copy link
Member

Wait what? I don't think you should be able to unset default values, you can overwrite them with other values but not remove them?

@mhsdesign
Copy link
Member Author

😂 hahah yes sounds legit ... i just wondered a year ago what the behaviour might be and observed that its possible and put it in stone via the node template tests :D
I guess there might be people relying on this ... eg setting an text field back to empty (which is null effectively by the neos ui)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants