Commit b6890803 authored by alexpott's avatar alexpott
Browse files

Issue #2942497 by scott_euser, timmillwood, malcomio, Berdir: Using content...

Issue #2942497 by scott_euser, timmillwood, malcomio, Berdir: Using content moderation block in preview mode causes EntityStorageException
parent 3840ad24
...@@ -269,6 +269,9 @@ public function entityView(array &$build, EntityInterface $entity, EntityViewDis ...@@ -269,6 +269,9 @@ public function entityView(array &$build, EntityInterface $entity, EntityViewDis
if (!$this->moderationInfo->isModeratedEntity($entity)) { if (!$this->moderationInfo->isModeratedEntity($entity)) {
return; return;
} }
if (isset($entity->in_preview) && $entity->in_preview) {
return;
}
// If the component is not defined for this display, we have nothing to do. // If the component is not defined for this display, we have nothing to do.
if (!$display->getComponent('content_moderation_control')) { if (!$display->getComponent('content_moderation_control')) {
return; return;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use Drupal\Core\Entity\Entity\EntityFormDisplay; use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\workflows\Entity\Workflow; use Drupal\workflows\Entity\Workflow;
use Drupal\Core\Url;
/** /**
* Tests the moderation form, specifically on nodes. * Tests the moderation form, specifically on nodes.
...@@ -80,6 +81,21 @@ public function testModerationForm() { ...@@ -80,6 +81,21 @@ public function testModerationForm() {
$this->assertResponse(200); $this->assertResponse(200);
$this->assertField('edit-new-state', 'The node view page has a moderation form.'); $this->assertField('edit-new-state', 'The node view page has a moderation form.');
// Preview the draft.
$this->drupalPostForm($edit_path, [
'body[0][value]' => 'Second version of the content.',
'moderation_state[0][state]' => 'draft',
], t('Preview'));
// The preview view should not have a moderation form.
$preview_url = Url::fromRoute('entity.node.preview', [
'node_preview' => $node->uuid(),
'view_mode_id' => 'full',
]);
$this->assertResponse(200);
$this->assertUrl($preview_url);
$this->assertNoField('edit-new-state', 'The node preview page has no moderation form.');
// The latest version page should not show, because there is still no // The latest version page should not show, because there is still no
// pending revision. // pending revision.
$this->drupalGet($latest_version_path); $this->drupalGet($latest_version_path);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment