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

!!! TASK: 9.0 Set nodeName to null for regular created nodes #3515

Merged
merged 5 commits into from
Sep 29, 2023

Conversation

mhsdesign
Copy link
Member

@mhsdesign mhsdesign commented Jun 1, 2023

WAIT BEFORE MERGE OF #3569 - as some tests would be cool ;)

resolves #3605

The ui currently tries to generate random (not particular "safe" as in unique) nodeNames. We dont need that anymore and it should go.

Also we currently dont account for $node->nodeName being null. And we should better check for the classification #3515 (comment)
What I did

How I did it

How to verify it

@github-actions github-actions bot added Bug Label to mark the change as bugfix 9.0 labels Jun 1, 2023
@mhsdesign mhsdesign marked this pull request as draft June 2, 2023 07:07
@mhsdesign
Copy link
Member Author

mhsdesign commented Jun 2, 2023

Well this is not totally correct as a tethered
node is not guaranteed to have a nodeName (see command) why don’t we actually just check if the classification of the node is tethered?

@nezaniel
Copy link
Member

nezaniel commented Jun 2, 2023

Tethered nodes always have node names (see NodeCreation::createTetheredWithNode), so if a node does not it is guaranteed to not be tethered.
Tethered is also one of the classifications, so a tethered node will always be classified as tethered.

The difference is that the classification is projection state, e.g. if the node type configuration changed in the meantime, this information might be outdated, while asking the NodeTypeManager will be always in sync with the configuration - while not necessarily reflecting the content graph state.

That said I'd go with the classification as this is more consistent with the rest I suppose

@nezaniel
Copy link
Member

nezaniel commented Jun 2, 2023

As for the NodeInfoHelper: I think we should remove or at least deprecate the isAutocreated method and check the classification instead

@mhsdesign
Copy link
Member Author

Yeah its used once in the helper itself internal (to provide the info for the neos ui)

the other usage is:

if (NodeInfoHelper::isAutoCreated($node, $subgraph)) {

@mhsdesign mhsdesign force-pushed the bugfix/nodeInfoHelperIsAutoCreated branch from 4a22948 to c85c241 Compare September 1, 2023 20:32
@mhsdesign mhsdesign marked this pull request as ready for review September 1, 2023 20:34
@mhsdesign mhsdesign mentioned this pull request Sep 5, 2023
@mhsdesign mhsdesign changed the title BUGFIX: 9.0 NodeInfoHelper::isAutoCreated handle nodeName == null BUGFIX: 9.0 Handle nodeName == null and set nodeName to null for non auto created node's Sep 5, 2023
@bwaidelich
Copy link
Member

With this change applied, many more occurrences of {node.path} will lead to an exception. Are we aware of that fact and willing to ignore it? (not a rhetoric question)

@mhsdesign
Copy link
Member Author

Yes I thought that was the plan as discussed in the weeklies?
nodeName and path cannot be relied upon.

but we can discuss this of course again … @skurfuerst what do you say?

@bwaidelich
Copy link
Member

Yes I thought that was the plan as discussed in the weeklies?
nodeName and path cannot be relied upon.

IIRC we agreed that both are deprecated and that ContentSubgraphInterface::retrieveNodePath() can throw an exception. I don't want to restart that discussion.

My point was just to make aware that this change will increase the chances of exceptions at rendering time. Personally I'm fine with that because I try to avoid node paths already

@mhsdesign
Copy link
Member Author

mhsdesign commented Sep 23, 2023

Hmm. Legacy projects can be migrated and the path logic would still work for existing nodes because they have names of course. For newly created nodes the use of nodepath would partially break your website. But the adjustment here of the developer to migrate away from nodenames is critical as otherwise nodes created via a custom import won’t work in this universe and everyone would be forced again to fill the node name with random stuff. -> this is not what we want as otherwise we wouldn’t need to make the nodename nullable. (Especially true for open source packages using nodepath)

Additionally the nodepath was deprecated for ages (since neos 4 or 5?) and I think even announced at the con?

Another point is that the now removed todo in line 100 says that our current nodename generation logic is not safe. We would need to look in all dimensions and check if the nodename is already occupied. And I rather not have this logic in place.

I can imagine two things:

Don’t generate nodeNames from the ui(this pr)

or allow a flag to opt in the old behaviour-> it’s important to be opt in so the ecosystem will adjust to empty node names (or they could do it via aop)

@bwaidelich
Copy link
Member

Legacy projects can be migrated and the path logic would still work for existing nodes

Good point!

@mhsdesign
Copy link
Member Author

an hack for everyone to restore the old behavior - which is highly discouraged, would be to use aop (this might break at anytime):

@Flow\Around("Neos\Neos\Ui\Domain\Model\Changes\AbstractCreate->getName()")

return $original ?: uniqid('node-', false);

@mhsdesign
Copy link
Member Author

Aaaand much scarier than path might be if people rely on nodeName for anchor / id / fragment generation on a site.

But the same arguments apply here as above.

The other choice would be that we have to guarantee for nodeName to be set if the escr is used for the Neos.Neos cms.

@mhsdesign
Copy link
Member Author

mhsdesign commented Sep 23, 2023

The fact that nodeName will be nullable must have been also discussed ages ago ^^

the with 4.3 introduced \Neos\ContentRepository\Domain\Projection\Content\TraversableNodeInterface::getNodeName is nullable and the non-nullable original getName was deprecated.

see pr neos/neos-development-collection#2430

In theory people might not really have noticed this of course, and i assume no one currently handles the null case for getNodeName

@mhsdesign mhsdesign changed the title BUGFIX: 9.0 Handle nodeName == null and set nodeName to null for non auto created node's !!! TASK: 9.0 Set nodeName to null for regular created nodes Sep 26, 2023
@mhsdesign mhsdesign merged commit f095371 into 9.0 Sep 29, 2023
4 checks passed
@mhsdesign mhsdesign deleted the bugfix/nodeInfoHelperIsAutoCreated branch September 29, 2023 10:33
mhsdesign added a commit that referenced this pull request Mar 12, 2024
…420885`

As with #3515 the `nodeName` will be null, so we dont need to use it for generating the uripath
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.

9.0 When creating new nodes set nodeName to null instead of random stuff
4 participants