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

BUGFIX: findNodeToEdit() checks if the node belongs to the correct site #3796

Merged
merged 2 commits into from
Jun 19, 2024

Conversation

bbehrendt-mm
Copy link
Contributor

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.

…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.
@github-actions github-actions bot added Bug Label to mark the change as bugfix 8.3 labels Jun 1, 2024
@@ -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())) {
Copy link
Member

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:

Suggested change
if ($node === null || !str_starts_with($node->findNodePath()->jsonSerialize(), $siteNode->findNodePath()->jsonSerialize())) {
if ($node === null || !str_starts_with($node->getPath(), $siteNode->getPath())) {

Copy link
Contributor Author

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 👍

Copy link
Member

@mhsdesign mhsdesign left a 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!

Copy link
Member

@Sebobo Sebobo left a 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

@mhsdesign mhsdesign merged commit 9badb26 into neos:8.3 Jun 19, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.3 Bug Label to mark the change as bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants