From 68f90f00300fce40a9c89ef72cdf9a525313809e Mon Sep 17 00:00:00 2001 From: Paula Kallert Date: Tue, 23 Jul 2024 16:33:14 +0200 Subject: [PATCH 1/4] Fix: Switch workspace --- .../Classes/Feature/WorkspaceCommandHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php index 1e96149f95f..d35b648df90 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php +++ b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php @@ -962,7 +962,7 @@ private function requireNonCircularRelationBetweenWorkspaces(Workspace $workspac } $nextBaseWorkspace = $baseWorkspace; - while ($nextBaseWorkspace->baseWorkspaceName !== null) { + while ($nextBaseWorkspace->baseWorkspaceName->value !== 'live') { if ($workspace->workspaceName->equals($nextBaseWorkspace->baseWorkspaceName)) { throw new CircularRelationBetweenWorkspacesException(sprintf('The workspace "%s" is already on the path of the target workspace "%s".', $workspace->workspaceName->value, $baseWorkspace->workspaceName->value)); } From a14ffe991468fccde05460cd7d9160cccb34562d Mon Sep 17 00:00:00 2001 From: Paula Kallert Date: Tue, 23 Jul 2024 17:08:10 +0200 Subject: [PATCH 2/4] Feature: Also check for isLive --- .../Classes/Feature/WorkspaceCommandHandler.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php index d35b648df90..34696bd2959 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php +++ b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php @@ -960,13 +960,18 @@ private function requireNonCircularRelationBetweenWorkspaces(Workspace $workspac if ($workspace->workspaceName->equals($baseWorkspace->workspaceName)) { throw new BaseWorkspaceEqualsWorkspaceException(sprintf('The base workspace of the target must be different from the given workspace "%s".', $workspace->workspaceName->value)); } - + $count = 1; $nextBaseWorkspace = $baseWorkspace; - while ($nextBaseWorkspace->baseWorkspaceName->value !== 'live') { + while (!is_null($nextBaseWorkspace->baseWorkspaceName) && !$nextBaseWorkspace->baseWorkspaceName->isLive()) { if ($workspace->workspaceName->equals($nextBaseWorkspace->baseWorkspaceName)) { throw new CircularRelationBetweenWorkspacesException(sprintf('The workspace "%s" is already on the path of the target workspace "%s".', $workspace->workspaceName->value, $baseWorkspace->workspaceName->value)); } $nextBaseWorkspace = $this->requireBaseWorkspace($workspace, $workspaceFinder); + $count++; + if($count == 5){ + die(); + } + var_dump($nextBaseWorkspace->baseWorkspaceName); } } From 7e5338f512771a498f3548a52dffcfcfbcc41300 Mon Sep 17 00:00:00 2001 From: Paula Kallert Date: Tue, 23 Jul 2024 17:09:14 +0200 Subject: [PATCH 3/4] Feature: Remove debug output --- .../Classes/Feature/WorkspaceCommandHandler.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php index 34696bd2959..77e1a5be1d1 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php +++ b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php @@ -960,18 +960,12 @@ private function requireNonCircularRelationBetweenWorkspaces(Workspace $workspac if ($workspace->workspaceName->equals($baseWorkspace->workspaceName)) { throw new BaseWorkspaceEqualsWorkspaceException(sprintf('The base workspace of the target must be different from the given workspace "%s".', $workspace->workspaceName->value)); } - $count = 1; $nextBaseWorkspace = $baseWorkspace; while (!is_null($nextBaseWorkspace->baseWorkspaceName) && !$nextBaseWorkspace->baseWorkspaceName->isLive()) { if ($workspace->workspaceName->equals($nextBaseWorkspace->baseWorkspaceName)) { throw new CircularRelationBetweenWorkspacesException(sprintf('The workspace "%s" is already on the path of the target workspace "%s".', $workspace->workspaceName->value, $baseWorkspace->workspaceName->value)); } $nextBaseWorkspace = $this->requireBaseWorkspace($workspace, $workspaceFinder); - $count++; - if($count == 5){ - die(); - } - var_dump($nextBaseWorkspace->baseWorkspaceName); } } From 3472c61802d9ef89b44387bbacc8297949243b5b Mon Sep 17 00:00:00 2001 From: Paula Kallert Date: Tue, 23 Jul 2024 22:46:37 +0200 Subject: [PATCH 4/4] Feature: use nextBaseWorkspace in while loop --- .../Classes/Feature/WorkspaceCommandHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php index 77e1a5be1d1..3789512c04d 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php +++ b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php @@ -961,11 +961,11 @@ private function requireNonCircularRelationBetweenWorkspaces(Workspace $workspac throw new BaseWorkspaceEqualsWorkspaceException(sprintf('The base workspace of the target must be different from the given workspace "%s".', $workspace->workspaceName->value)); } $nextBaseWorkspace = $baseWorkspace; - while (!is_null($nextBaseWorkspace->baseWorkspaceName) && !$nextBaseWorkspace->baseWorkspaceName->isLive()) { + while (!is_null($nextBaseWorkspace->baseWorkspaceName)) { if ($workspace->workspaceName->equals($nextBaseWorkspace->baseWorkspaceName)) { throw new CircularRelationBetweenWorkspacesException(sprintf('The workspace "%s" is already on the path of the target workspace "%s".', $workspace->workspaceName->value, $baseWorkspace->workspaceName->value)); } - $nextBaseWorkspace = $this->requireBaseWorkspace($workspace, $workspaceFinder); + $nextBaseWorkspace = $this->requireBaseWorkspace($nextBaseWorkspace, $workspaceFinder); } }