From 98a79c1bfdc6f45fb4df7866bd897ec48946bff1 Mon Sep 17 00:00:00 2001 From: catch Date: Tue, 7 Mar 2023 15:56:22 +0000 Subject: [PATCH] Issue #3323380 by amateescu, smustgrave: Allow switching to any workspace in CLI requests (cherry picked from commit 40c86d902cbf5e1877d040baa255851a975d8893) --- core/modules/workspaces/src/WorkspaceManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/modules/workspaces/src/WorkspaceManager.php b/core/modules/workspaces/src/WorkspaceManager.php index f97ff343cb4..fdb47d6973a 100644 --- a/core/modules/workspaces/src/WorkspaceManager.php +++ b/core/modules/workspaces/src/WorkspaceManager.php @@ -240,8 +240,8 @@ class WorkspaceManager implements WorkspaceManagerInterface { */ protected function doSwitchWorkspace($workspace) { // If the current user doesn't have access to view the workspace, they - // shouldn't be allowed to switch to it. - if ($workspace && !$workspace->access('view')) { + // shouldn't be allowed to switch to it, except in CLI processes. + if ($workspace && PHP_SAPI !== 'cli' && !$workspace->access('view')) { $this->logger->error('Denied access to view workspace %workspace_label for user %uid', [ '%workspace_label' => $workspace->label(), '%uid' => $this->currentUser->id(),