diff --git a/core/modules/content_moderation/src/EntityOperations.php b/core/modules/content_moderation/src/EntityOperations.php index 5c8d5c0f08..d33f9ed30a 100644 --- a/core/modules/content_moderation/src/EntityOperations.php +++ b/core/modules/content_moderation/src/EntityOperations.php @@ -235,8 +235,7 @@ public function entityView(array &$build, EntityInterface $entity, EntityViewDis if (!$this->moderationInfo->isLatestRevision($entity)) { return; } - /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ - if ($entity->isDefaultRevision()) { + if ($this->moderationInfo->isLiveRevision($entity)) { return; } diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php index 3e4199154f..9cf92ba4dd 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php @@ -43,6 +43,12 @@ public function testModerationForm() { $this->assertTrue($this->adminUser->hasPermission('edit any moderated_content content')); + // The canonical view should have a moderation form, because it is not the + // live revision. + $this->drupalGet($canonical_path); + $this->assertResponse(200); + $this->assertField('edit-new-state', 'The node view page has a moderation form.'); + // The latest version page should not show, because there is no forward // revision. $this->drupalGet($latest_version_path); @@ -53,6 +59,12 @@ public function testModerationForm() { 'body[0][value]' => 'Second version of the content.', ], t('Save and Create New Draft')); + // The canonical view should have a moderation form, because it is not the + // live revision. + $this->drupalGet($canonical_path); + $this->assertResponse(200); + $this->assertField('edit-new-state', 'The node view page has a moderation form.'); + // The latest version page should not show, because there is still no // forward revision. $this->drupalGet($latest_version_path); @@ -64,10 +76,10 @@ public function testModerationForm() { ], t('Save and Publish')); // The published view should not have a moderation form, because it is the - // default revision. + // live revision. $this->drupalGet($canonical_path); $this->assertResponse(200); - $this->assertNoText('Status', 'The node view page has no moderation form.'); + $this->assertNoField('edit-new-state', 'The node view page has no moderation form.'); // The latest version page should not show, because there is still no // forward revision. @@ -80,16 +92,16 @@ public function testModerationForm() { ], t('Save and Create New Draft')); // The published view should not have a moderation form, because it is the - // default revision. + // live revision. $this->drupalGet($canonical_path); $this->assertResponse(200); - $this->assertNoText('Status', 'The node view page has no moderation form.'); + $this->assertNoField('edit-new-state', 'The node view page has no moderation form.'); // The latest version page should show the moderation form and have "Draft" // status, because the forward revision is in "Draft". $this->drupalGet($latest_version_path); $this->assertResponse(200); - $this->assertText('Status', 'Form text found on the latest-version page.'); + $this->assertField('edit-new-state', 'The latest-version page has a moderation form.'); $this->assertText('Draft', 'Correct status found on the latest-version page.'); // Submit the moderation form to change status to published.