-
-
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: Handle nodes with missing UriPathSegments in uriPathProjection #5412
base: 9.0
Are you sure you want to change the base?
BUGFIX: Handle nodes with missing UriPathSegments in uriPathProjection #5412
Conversation
Since "" is treated as the uriPath for a site node this causes confusion if it is projected for a document in cases where one was created without an uriPathSegment which may happen for tethered nodes. Resolves: neos#5412
43fdcb5
to
107b282
Compare
…gments The testcase verifies that the nodeAggregateId is used as fallback in case no uriPathSegment was set and that this can be overwritten afterwards of a proper uriPathSegment is set later. Relates: neos#5413
Since "" is treated as the uriPath for a site node this causes confusion if it is projected for a document in cases where one was created without an uriPathSegment which may happen for tethered nodes. Resolves: neos#5412
107b282
to
dd3ff9d
Compare
a16aeb8
to
d81eb9f
Compare
I wonder wether the site node detection that is currently done in handCreateNodeAggregateWith is wise because a |
9abce68
to
d9772d3
Compare
Since "" is treated as the uriPath for a site node this causes confusion if it is projected for a document in cases where one was created without an uriPathSegment which may happen for tethered nodes. Resolves: neos#5412
…vior The projection detects site nodes that should have an empty path by verifying that the parent is a root node and they have a nodeName.
d9772d3
to
64d52a7
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.
I don't fully understand, why some seemingly unrelated tests needed adjustments, but the change itself makes sense to me, thanks!
The definition of site node (with path „“) used in the uriPathProjection is that it is a child of a rootNode and has a nodeName. The adjusted tests only worked in the past because an empty uriPathSegment was treated implicitly like a site node. Since we now have fallback for empty uriPathSegments the tests that relied on that now need a proper site Node. |
@@ -209,7 +209,7 @@ private function whenNodeAggregateWithNodeWasCreated(NodeAggregateWithNodeWasCre | |||
} | |||
|
|||
$propertyValues = $event->initialPropertyValues->getPlainValues(); | |||
$uriPathSegment = $propertyValues['uriPathSegment'] ?? ''; | |||
$uriPathSegment = $propertyValues['uriPathSegment'] ?? $event->nodeAggregateId->value; |
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.
we discussed an alternative in line 273 but it doesnt really work :D
$uriPath = $this->nodeTypeManager->getNodeType($parentNode->getNodeTypeName())?->isOfType(NodeTypeNameFactory::NAME_SITE)
? $uriPathSegment
: $parentNode->getUriPath() . '/' . $uriPathSegment;
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.
Still think resilience against missing uri path segments is better than adding an even tighter bond to the Neos NodeTypes. Even if this would work ;-)
The fallback way makes uriPathes more like a soft concern (which it is technically anyways) and allows routing of documents in cases where it is missing for any reason.
Only thing that would speak against that would be a case where the node-identifier based fallback does harm anything but i do not see a way for this to happen.
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.
It would preferably not necessary to use the node identifier here as that would now lead to odd uris containing a uuid which is not humanreadable. But then again - hey - at least there is an uri now and it can be edited and changes are picked up. Alternatively i suggested using the NodeName which is definitely available as a first choice over the node aggregate id as this will be kindof readable but to be honest this is such an edgecase it might not be worth discussing over this tiny detail.
A total alternative direction would be to introduce some kind of special path segment in the projection which says "hey" im just a placeholder please dont route me. But we agreed its more important to have an actual uri first than to have no uri until the reaction fixes it.
This whole issue shows that the node creation dialog of the ui is actually missing an important feature: To allow to specify the initial properties of the tethered nodes ... and fun fact the Neos ESCR core api cannot do this at the current point - there is no "initial node properties for tethered node" option, which we might yet have to introduce.
Either way - even with the thought out creation dialog extension we cant ensure that the uriPathSegment is set always (well we could via command hooks - but do we want to? related: #4581).
So it definitely makes sense to build the projection a little more forgiving.
Note that there are some more inconsistencies we found like that an empty (""
) uriPathSegment
on creation does not yet replaced with the node aggregate id to avoid problems like this.
And also the projection does not consider the case when the property is manually set to empty (""
) or unset via propertyValuesToUnset
.
Line 537 in b1168c4
$uriPathSegments[array_key_last($uriPathSegments)] = $newPropertyValues['uriPathSegment']; |
Technically we would need to adopt and enforce the same behaviour as started with this pr: use the node aggregate id as fallback. Currently we dont do so and run in odd states. Either way this cleanup will be out of scope of this current bugfix and might not even be that critical as the Neos Ui regularly prevents the uripath segment to be unset or empty.
We can always fix that later in the future and advice affected users to replay.
9208c23
to
195af38
Compare
eca5d6b
to
ff41831
Compare
…` and unsetting of `uriPathSegment`
ff41831
to
215c884
Compare
@mhsdesign adjusted the code to handle "" as uriPathSegments and also later setting of uriPathSegments to "" or null. The general the rule for the uriPathSegment is now |
Use nodeAggregateId as fallback for missing uriPathSegments in uriPathProjection.
This is necessary as the fallback to "" can create empty pathes for documents without uriPathSegment which is later on confused with root urls of the site. Falling back to the nodeAggregate id which is by definition unique and url-safe ensures that all documents get a valid url by the projection that can be adjusted later.
Empty uriPathSegments are usually avoided by validation and autocreation from the title but those mechanisms do not work for tethered nodes. This is even more problematic as this cannot be fixed later since the full uriPath is only created oCreate and laster on only the last segment of the path is adjusted without ever reevaluating the parentPath.
In addition this pr adds a nodeName to the site node in multiple test cases as this is actually required and only worked in the past because the empty uriPathSegment behaved like a site node.
Resolves: #5413
Upgrade instructions
Review instructions
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions