diff --git a/core/modules/workspaces/src/EntityAccess.php b/core/modules/workspaces/src/EntityAccess.php index 4d7461a9b0..d74456d435 100644 --- a/core/modules/workspaces/src/EntityAccess.php +++ b/core/modules/workspaces/src/EntityAccess.php @@ -91,7 +91,7 @@ public function entityOperationAccess(EntityInterface $entity, $operation, Accou } // Prevent the deletion of entities with a published default revision. - if ($operation === 'delete') { + if ($operation === 'delete' && $this->workspaceManager->hasActiveWorkspace()) { $active_workspace = $this->workspaceManager->getActiveWorkspace(); $is_deletable = $this->workspaceAssociation->isEntityDeletable($entity, $active_workspace); diff --git a/core/modules/workspaces/src/EntityOperations.php b/core/modules/workspaces/src/EntityOperations.php index 39f9f7c936..e9bb068c80 100644 --- a/core/modules/workspaces/src/EntityOperations.php +++ b/core/modules/workspaces/src/EntityOperations.php @@ -235,7 +235,7 @@ public function entityPredelete(EntityInterface $entity) { // support for workspaces, or if the entity has a published default // revision. $active_workspace = $this->workspaceManager->getActiveWorkspace(); - if (!$this->workspaceManager->isEntityTypeSupported($entity_type) || !$this->workspaceAssociation->isEntityDeletable($entity, $active_workspace)) { + if (!$this->workspaceManager->isEntityTypeSupported($entity_type) || ($active_workspace && !$this->workspaceAssociation->isEntityDeletable($entity, $active_workspace))) { throw new \RuntimeException('This entity can only be deleted in the Live workspace.'); } } @@ -276,7 +276,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, $f // Prevent entities from being deleted in a workspace if they have a // published default revision. $active_workspace = $this->workspaceManager->getActiveWorkspace(); - if ($form_state->getFormObject()->getOperation() === 'delete' && !$this->workspaceAssociation->isEntityDeletable($entity, $active_workspace)) { + if ($form_state->getFormObject()->getOperation() === 'delete' && $active_workspace && !$this->workspaceAssociation->isEntityDeletable($entity, $active_workspace)) { $form['#markup'] = $this->t('This @entity_type_label can only be deleted in the Live workspace.', [ '@entity_type_label' => $entity->getEntityType()->getSingularLabel(), ]);