From c86bd584fdeb6ebf3570c8b33ba5d83b6911c098 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:52:05 +0100 Subject: [PATCH] TASK: Do not try catch `countPendingWorkspaceChanges` ... because it would lead to hard to debug code and is not expected to fail --- Neos.Neos/Classes/Command/WorkspaceCommandController.php | 8 ++------ .../Classes/Controller/WorkspaceController.php | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Neos.Neos/Classes/Command/WorkspaceCommandController.php b/Neos.Neos/Classes/Command/WorkspaceCommandController.php index 5e58e39f5a5..ddd62e7a8b3 100644 --- a/Neos.Neos/Classes/Command/WorkspaceCommandController.php +++ b/Neos.Neos/Classes/Command/WorkspaceCommandController.php @@ -398,17 +398,13 @@ public function deleteCommand(string $workspace, bool $force = false, string $co if ($crWorkspace->hasPublishableChanges()) { if ($force === false) { - try { - $nodesCount = $this->workspacePublishingService->countPendingWorkspaceChanges($contentRepositoryId, $workspaceName); - } catch (\Exception) { - $nodesCount = 'NAN'; - } + $nodesCount = $this->workspacePublishingService->countPendingWorkspaceChanges($contentRepositoryId, $workspaceName); $this->outputLine( 'Did not delete workspace "%s" because it contains %s unpublished node(s).' . ' Use --force to delete it nevertheless.', [$workspaceName->value, $nodesCount] ); - $this->quit(5); + $this->quit(4); } $this->workspacePublishingService->discardAllWorkspaceChanges($contentRepositoryId, $workspaceName); } diff --git a/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php b/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php index 1ba6afe6e20..dc1c0aa5bb0 100644 --- a/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php +++ b/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php @@ -374,14 +374,10 @@ public function deleteAction(WorkspaceName $workspaceName): void } if ($workspace->hasPublishableChanges()) { - try { - $nodesCount = $this->workspacePublishingService->countPendingWorkspaceChanges($contentRepositoryId, $workspaceName); - } catch (\Exception) { - $nodesCount = null; - } + $nodesCount = $this->workspacePublishingService->countPendingWorkspaceChanges($contentRepositoryId, $workspaceName); $message = $this->translator->translateById( 'workspaces.workspaceCannotBeDeletedBecauseOfUnpublishedNodes', - [$workspaceMetadata->title->value, $nodesCount ?? 'NAN'], + [$workspaceMetadata->title->value, $nodesCount], $nodesCount, null, 'Main',