-
-
Notifications
You must be signed in to change notification settings - Fork 223
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: Restore Neos.Neos:NodeUri
, neos:link.node
and LinkingService
#4886
Conversation
54ebe9f
to
0b311df
Compare
Converts legacy paths like "/absolute/path", "~/site-relative/path" and "~" to the corresponding AbsoluteNodePath depending on the passed base node. The following syntax is not implemented and handled here: - node:// - /<Neos.Neos:Sites>/my-site/main - some/relative/path Also while legacy and previously allowed, node path traversal like ./neos/info or ../foo/../../bar is not handled.
Previously the `linkedNode` would contain the node the shortcut points to actually. But as this is not the Neos 8.3 behaviour and introduces complexity that should be handled by the uri builder it will be removed again.
0b311df
to
509ea9a
Compare
Previously it was a union of `[a-z0-9-]+` and a UUID pattern, but the character set already covers the UUID case
Neos.Neos:NodeUri
, neos:link.node
and LinkingService
Another point is, should we actually introduce support again for these legacy path syntax when the most prominent places flow query, and many places in the configuration doesnt allow it? So having this runtime magic here for
see also: neos/rector#24 |
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.
No +1 yet, because I failed to review this properly..
Just a little, half unrelated, comment.
Also I wonder: Is this behavior tested somehow?
needed in preparation for #4886
was my last todo:) i introduced a test for 8.3, upmerged that and adjusted it here. |
Will be re-enabled with #4886
needed in preparation for neos/neos-development-collection#4886
Will be re-enabled with neos/neos-development-collection#4886
That was also not in 8.3 supported in the linking service or Neos.Neos:NodeUri
This syntax is not required here
regarding #4886 (comment) I also remember why i deprecated so definitely merge ready // cc @kitsunet |
I'll take a last look tomorrow/later and merge |
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.
The one comment about reusing the regex from basti seems like a good idea but by no means a blocker, thanks, this looks very ncie.
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; | ||
use Neos\Flow\Annotations as Flow; | ||
|
||
final class NodeAddressNormalizer |
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 think this is the wrong name still ... maybe NodePathResolver::resolveNodeAddressFromPath
or NodePathUtitlity::retrieveNodeAddressByPath
idont know ...
or does *Normalizer fit the usecase here?
cc @kitsunet
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.
Yeah I definitely don't like Normalizer here, more like Converter or Resolver given that the method is named resolve...?
Do we want this @internal
to avoid people using it (as we probably don't want to keep this forever)?
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.
Jup, added internal and renamed it to NodePathResolver::resolveNodeAddressByPath
... the normalise naming was stolen from 8.3 but doesnt fit anymore ^^
…uri builder behaviour This was accidentally wrongly migrated. Regarding > Why do we evaluate the hidden state here? We dont do it in the new uri builder. We dont evaluate the hidden state in the new uri builder because we only have the node address at hand. The 8.3 logic ``` $action = $node->getContext()->getWorkspace()->isPublicWorkspace() && !$node->isHidden() ? 'show' : 'preview'; ``` Ensured if youre routing to a hidden live node then a preview uri will be built. This is mostly unlikely going to happen and building the preview uri in this case is possibly not even the desired behaviour One exception, in the Neos.Ui requires this behaviour: neos/neos-ui#3867
public function tryResolveLegacyPathSyntaxToAbsoluteNodePath( | ||
string $path, | ||
Node $baseNode | ||
): ?AbsoluteNodePath { |
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 understand the return type. This can either return an AbsoluteNodePath
or lead to an exception or it returns null
. What is the meaning of null
and is that a good abstraction? Maybe we can at least add some @return
doc comment explaining the ambiguity?
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.
Ah I see, in the usages you do
tryResolveLegacyPathSyntaxToAbsoluteNodePath($path, ..) ?? $path
wouldn't it make things easier to have some
$absoluteNodePath = AbsoluteNodePath::tryFromString($path);
if ($absoluteNodePath !== null) {
return $absoluteNodePath;
}
at the beginning of this method and get rid of the nullable return type?
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.
youre right to point this out:) I forgot to write down my line of thought here.
The idea is to separate the legacy behaviour from the more future proof, so we can later just remove the dependency to tryResolveLegacyPathSyntaxToAbsoluteNodePath
... calling AbsoluteNodePath::tryFromString
would not be enough as the relative base node behaviour would also need to be handled ...
its a little odd but its all @internal
so maybe keep it this way?
Alternatively this could be the api:
public function preprocessLegacyPathSyntax(
string $path,
Node $baseNode
): string;
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.
its a little weird but for now well keep it okay its internal :)
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.
thank you for the review though ❤️ though now its time to tag the beta:)
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'm absolutely fine with being overruled, but it's a bit demotivating if all my comments are just disregarded. You could have at least added the @return
doc comment.
Anyways, not a big deal in this case of course
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.
you are right @bwaidelich we had a short call about it, and decided this is ultimately throw away code and we shouldn't bikeshed about it and instead get the beta out. The doc comment would definitely not hurt though.
SORRY! ❤️wasn't meant to ignore you just to get the topic off of our (collective) heads, we discussed the other options but didn't see any single one that was much more pretty and therefore worth changing to.
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.
no worries, no need to be sorry. But thanks for the explanation!
Resolves: #4524
Related: #4552
For linking to nodes in Neos (via
Neos.Neos:NodeUri
,neos:link.node
orneos:uri.node
) following logic will apply for Neos 9:If a node is passed as string the base node is required.
Following string syntax is allowed:
/<Neos.Neos:Sites>/my-site/main
some/relative/path
Only allowed in Fluid:
node://my-node-identifier
Deprecated syntax:
/sites/site/absolute/path
~/site-relative/path
~
Not supported syntax:
./neos/info
../foo/../../bar
Changes:
Neos.Neos:NodeUri
which requires thebaseNodeName
to be set (9.0Neos.Neos:NodeUri
relative uris? #4524).Neos.Neos:NodeUri
will like the fluid viewhelpers now also accept thenode://my-id
syntax\Neos\Neos\TYPO3CR\NeosNodeService::normalizePath
the new utility\Neos\Neos\Utility\LegacyNodePathNormalizer::tryResolveLegacyPathSyntaxToAbsoluteNodePath
will handle the legacy path syntax/../
via 8.3's\Neos\ContentRepository\Domain\Utility\NodePaths::replaceRelativePathElements
we now correctly document that this syntax is not allowed and throw an descriptive error (previouslyNodePath::fromString
would have thrown an error as the node name pattern is not supporting dots).baseNodeName
/ the documentNode to resolve string nodesneos:link.node
) will initialise thelinkedNode
variable as the shortcut itself and NOT resolve it. This is the same behaviour in Neos 8.3. Previously shortcut resolving was once earlier part of the uri builder meaning thelinkedNode
was the actual shortcut, but as Neos 8.3 didnt feature this, we wont need to fix this for fluid.resolveNodeAddressFromPath
was extracted into\Neos\Neos\Utility\NodeAddressNormalizer::resolveNodeAddressFromPath
LinkingService
was marked as deprecated and now uses theLinkHelper
where possibleLinkHelper
was simplified to fully work on psrgetScheme
andgetHost
instead of regex\Neos\Neos\Fusion\Helper\LinkHelper::resolveNodeUri
was marked as deprecated as its not usable from within fusion, and it requires theLinkingService
node
to null in the fluid viewhelpers and fusion will not lead to link generation of thebaseNodeName
/ the documentNode but an exceptionPATTERN_SUPPORTED_URIS
in convert uris was simplified as it was previously a union but the character set already matches uuidsLeft open points:
NodeAddressNormalizer
LinkingService::createSiteUri
LinkingService
? We dont do it in the new uri builderreturn $this->newLinkHelper->hasSupportedScheme($uri);
in theLinkingService
and add rector migration?Neos.Neos:NodeUri
Upgrade instructions
Review instructions
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions