diff --git a/core/modules/content_moderation/src/EntityOperations.php b/core/modules/content_moderation/src/EntityOperations.php index 5c8d5c0f08720451630ac2f6e19af9064e75898e..d33f9ed30ae62175c3a3d8e46c96b14803e56907 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 3e4199154f051175a66db5219cc3f7f8defeb8b9..9cf92ba4dd478e2d17a36f8f010dca505e9c566e 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.