Skip to content

Commit

Permalink
BUGFIX: Avoid toooo random uri-paths segments like `65d0ba5d8f4593-93…
Browse files Browse the repository at this point in the history
…420885`

As with #3515 the `nodeName` will be null, so we dont need to use it for generating the uripath
  • Loading branch information
mhsdesign committed Mar 2, 2024
1 parent 860e9d1 commit eec2840
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,16 @@ public function handle(NodeCreationCommands $commands, NodeCreationElements $ele
// if specified, the uriPathSegment equals the title
$uriPathSegment = $elements->get('title');

// otherwise, we fall back to the node name
if ($uriPathSegment === null && $commands->first->nodeName !== null) {
$uriPathSegment = $commands->first->nodeName->value;
}

// if not empty, we transliterate the uriPathSegment according to the language of the new node
if ($uriPathSegment !== null && $uriPathSegment !== '') {
$uriPathSegment = $this->transliterateText(
$commands->first->originDimensionSpacePoint->toDimensionSpacePoint(),
$uriPathSegment
);
} else {
// todo in case the title is missing dont set it to something random like 65d0ba5d8f4593-93420885
// but use the node label name instead like in 8.3. The problem is with two nodes on the same level.
// alternatively we set it to a random string
$uriPathSegment = uniqid('', true);
// alternatively we set it to a random string like `document-blog-022`
$nodeTypeSuffix = explode(':', $commands->first->nodeTypeName->value)[1] ?? '';
$uriPathSegment = sprintf('%s-%03d', $nodeTypeSuffix, random_int(0, 999));
}
$uriPathSegment = Transliterator::urlize($uriPathSegment);
$propertyValues = $commands->first->initialPropertyValues->withValue('uriPathSegment', $uriPathSegment);
Expand Down

0 comments on commit eec2840

Please sign in to comment.