-
-
Notifications
You must be signed in to change notification settings - Fork 135
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: findNodeToEdit() checks if the node belongs to the correct site #3796
Conversation
…ect site Fixes neos#3795 Neos uses shared sessions when working with multiple sites on different domains. This fix ensures that we do not try to open a lastVisitedNode within a site the node does not belong to.
@@ -224,7 +224,7 @@ protected function findNodeToEdit(): ?NodeInterface | |||
$reflectionMethod->setAccessible(true); | |||
$node = $reflectionMethod->invoke($this->backendRedirectionService, $siteNode->getContext()->getWorkspaceName()); | |||
|
|||
if ($node === null) { | |||
if ($node === null || !str_starts_with($node->findNodePath()->jsonSerialize(), $siteNode->findNodePath()->jsonSerialize())) { |
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.
hmm we absolutely try to NOT to any string logic on the paths as this might be really fragile and with Neos 9 is no longer possible.
So really we want to fetch the node's side node and check if the site node equals $siteNode
Buuutt the proposed solution is slightly faster and doenst require any sql queries AND the last visited node feature was removed with Neos 9 meaning that this will not need to be 9.0 compatible.
Under these circumstances im willing to +1 this hack :D
Still one more thing, lets use the native methods:
if ($node === null || !str_starts_with($node->findNodePath()->jsonSerialize(), $siteNode->findNodePath()->jsonSerialize())) { | |
if ($node === null || !str_starts_with($node->getPath(), $siteNode->getPath())) { |
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 objections to that :D
Just applied your proposal, thank you very much for the feedback 👍
Co-authored-by: Marc Henry Schultz <[email protected]>
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.
As written here #3796 (comment)
thanks!
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.
Thx! Fine by reading
Fixes #3795
Neos uses shared sessions when working with multiple sites on different domains. This fix ensures that we do not try to open a lastVisitedNode within a site the node does not belong to.
What I did
Added a check to findNodeToEdit() that ensures the found node (from lastVisitedNode) belongs to the currently opened site.
How I did it
The check confirms that the found node is within the site node's sub-tree by comparing the node path.
How to verify it
Check the issue for step-by-step instructions on how to reproduce the bug. With this fix, the bug no longer occurs (instead of a rendering error, the backend displays the site node). Remembering the last visited node within the same site still works.