diff --git a/core/modules/content_moderation/src/EntityTypeInfo.php b/core/modules/content_moderation/src/EntityTypeInfo.php index 00ddda2dfcda086c2b5acd46ba6576332cabbc9e..f073e25a389eaada15928c9fd4933aaf9983d7e0 100644 --- a/core/modules/content_moderation/src/EntityTypeInfo.php +++ b/core/modules/content_moderation/src/EntityTypeInfo.php @@ -133,7 +133,14 @@ public function entityTypeAlter(array &$entity_types) { // entity type needs to be excluded for now. // @todo Enable moderation for path aliases after they become publishable // in https://www.drupal.org/project/drupal/issues/3007669. - if ($entity_type->isRevisionable() && !$entity_type->isInternal() && $entity_type_id !== 'path_alias') { + // Workspace entities can not be moderated because they use string IDs. + // @see \Drupal\content_moderation\Entity\ContentModerationState::baseFieldDefinitions() + // where the target entity ID is defined as an integer. + $entity_type_to_exclude = [ + 'path_alias', + 'workspace', + ]; + if ($entity_type->isRevisionable() && !$entity_type->isInternal() && !in_array($entity_type_id, $entity_type_to_exclude)) { $entity_types[$entity_type_id] = $this->addModerationToEntityType($entity_type); } } diff --git a/core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php b/core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php index 17eba99f7c7d96d2b8bbf929a7d09271e8db48da..79cf23286c454de3b2b0e254543fadce7ce05e1e 100644 --- a/core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php @@ -49,6 +49,18 @@ protected function setUp(): void { $this->switchToWorkspace('stage'); } + /** + * Tests that the 'workspace' entity type can not be moderated. + * + * @see \Drupal\workspaces\EntityTypeInfo::entityTypeAlter() + */ + public function testWorkspaceEntityTypeModeration() { + /** @var \Drupal\content_moderation\ModerationInformationInterface $moderation_info */ + $moderation_info = \Drupal::service('content_moderation.moderation_information'); + $entity_type = \Drupal::entityTypeManager()->getDefinition('workspace'); + $this->assertFalse($moderation_info->canModerateEntitiesOfEntityType($entity_type)); + } + /** * Tests the integration between Content Moderation and Workspaces. *