From 10011fb587aab06da50e8d58321cdec9deffab39 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sat, 29 Jun 2024 10:10:07 +0200 Subject: [PATCH] WIP: Assert that write side does not operate on fake workspace names --- .../Classes/CommandHandlingDependencies.php | 4 ++++ .../Classes/Feature/WorkspaceCommandHandler.php | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Neos.ContentRepository.Core/Classes/CommandHandlingDependencies.php b/Neos.ContentRepository.Core/Classes/CommandHandlingDependencies.php index 53a5c282b5c..0763a5dcade 100644 --- a/Neos.ContentRepository.Core/Classes/CommandHandlingDependencies.php +++ b/Neos.ContentRepository.Core/Classes/CommandHandlingDependencies.php @@ -65,6 +65,10 @@ public function getContentGraph(WorkspaceName $workspaceName): ContentGraphInter return $this->overridenContentGraphInstances[$workspaceName->value]; } + if ($workspaceName->isReferencingUnusedContentStream()) { + throw new \RuntimeException(sprintf('Expected actual workspace name. Got a workspace name referencing an unused content stream: "%s" instead.', $workspaceName->getReferencingUnusedContentStreamId()->value), 1719648458); + } + return $this->contentRepository->getContentGraph($workspaceName); } diff --git a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php index 1e96149f95f..1a03137b377 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php +++ b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php @@ -900,6 +900,10 @@ private function handleChangeWorkspaceOwner( private function requireWorkspaceToNotExist(WorkspaceName $workspaceName, CommandHandlingDependencies $commandHandlingDependencies): void { + if ($workspaceName->isReferencingUnusedContentStream()) { + throw new \RuntimeException(sprintf('Expected actual workspace name. Got a workspace name referencing an unused content stream: "%s" instead.', $workspaceName->getReferencingUnusedContentStreamId()->value), 1719648458); + } + try { $commandHandlingDependencies->getContentGraph($workspaceName); } catch (WorkspaceDoesNotExist) { @@ -918,6 +922,10 @@ private function requireWorkspaceToNotExist(WorkspaceName $workspaceName, Comman */ private function requireWorkspace(WorkspaceName $workspaceName, WorkspaceFinder $workspaceFinder): Workspace { + if ($workspaceName->isReferencingUnusedContentStream()) { + throw new \RuntimeException(sprintf('Expected actual workspace name. Got a workspace name referencing an unused content stream: "%s" instead.', $workspaceName->getReferencingUnusedContentStreamId()->value), 1719648458); + } + $workspace = $workspaceFinder->findOneByName($workspaceName); if (is_null($workspace)) { throw WorkspaceDoesNotExist::butWasSupposedTo($workspaceName);