diff --git a/core/modules/content_moderation/src/Entity/ModerationState.php b/core/modules/content_moderation/src/Entity/ModerationState.php index 4d1158a..0522e7d 100644 --- a/core/modules/content_moderation/src/Entity/ModerationState.php +++ b/core/modules/content_moderation/src/Entity/ModerationState.php @@ -36,6 +36,7 @@ * "id", * "label", * "published", + * "default_revision", * "weight", * }, * ) diff --git a/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php b/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php index 6b97d99..a89b725 100644 --- a/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php +++ b/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php @@ -91,13 +91,15 @@ public function convert($value, $definition, $name, array $defaults) { if ($entity && $this->moderationInformation->isModeratableEntity($entity) && !$this->moderationInformation->isLatestRevision($entity)) { $entity_type_id = $this->getEntityTypeFromDefaults($definition, $name, $defaults); $latest_revision = $this->moderationInformation->getLatestRevision($entity_type_id, $value); - if ($latest_revision->isRevisionTranslationAffected()) { - $entity = $latest_revision; - } + // If the entity type is translatable, ensure we return the proper // translation object for the current context. - if ($entity instanceof EntityInterface && $entity instanceof TranslatableInterface) { - $entity = $this->entityManager->getTranslationFromContext($entity, NULL, array('operation' => 'entity_upcast')); + if ($latest_revision instanceof EntityInterface && $entity instanceof TranslatableInterface) { + $latest_revision = $this->entityManager->getTranslationFromContext($latest_revision, NULL, array('operation' => 'entity_upcast')); + } + + if ($latest_revision->isRevisionTranslationAffected()) { + $entity = $latest_revision; } } diff --git a/core/modules/content_moderation/src/Tests/ModerationLocaleTest.php b/core/modules/content_moderation/src/Tests/ModerationLocaleTest.php index 2af08be..3d585ab 100644 --- a/core/modules/content_moderation/src/Tests/ModerationLocaleTest.php +++ b/core/modules/content_moderation/src/Tests/ModerationLocaleTest.php @@ -139,8 +139,7 @@ public function testTranslateModeratedContent() { $this->assertEqual($english_node->moderation_state->target_id, 'draft'); $this->assertFalse($english_node->isPublished()); - // Now check that we can create a new draft of the translation and then - // publish it. + // Now check that we can create a new draft of the translation. $edit = [ 'title[0][value]' => 'New draft of translated node', ]; diff --git a/core/modules/content_moderation/src/Tests/ModerationStateStatesTest.php b/core/modules/content_moderation/src/Tests/ModerationStateStatesTest.php index 6ec8d4e..1b394f9 100644 --- a/core/modules/content_moderation/src/Tests/ModerationStateStatesTest.php +++ b/core/modules/content_moderation/src/Tests/ModerationStateStatesTest.php @@ -46,7 +46,7 @@ public function testStateAdministration() { $this->assertLink('Add Moderation state'); $this->assertText('Draft'); // Edit the draft. - $this->clickLink('Edit', 1); + $this->clickLink('Edit', 0); $this->assertFieldByName('label', 'Draft'); $this->assertNoFieldChecked('edit-published'); $this->drupalPostForm(NULL, [