diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 162ba1b..3b01308 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -83,17 +83,15 @@ public function form(array $form, FormStateInterface $form_state) { if ($preview = $store->get($uuid)) { /** @var $preview \Drupal\Core\Form\FormStateInterface */ - $form_state = $preview; + $form_state->setFormState($preview->getCacheableArray()); // Rebuild the form. $form_state->setRebuild(); $this->entity = $preview->getFormObject()->getEntity(); $this->entity->in_preview = NULL; - // Remove the stale temp store entry for existing nodes. - if (!$this->entity->isNew()) { - $store->delete($uuid); - } + // Remove the stale temp store entry. + $store->delete($uuid); $this->hasBeenPreviewed = TRUE; } diff --git a/core/modules/node/src/Tests/PagePreviewTest.php b/core/modules/node/src/Tests/PagePreviewTest.php index 2975954..5cbb242 100644 --- a/core/modules/node/src/Tests/PagePreviewTest.php +++ b/core/modules/node/src/Tests/PagePreviewTest.php @@ -178,13 +178,7 @@ function testPagePreview() { $this->assertText($edit[$body_key], 'Body displayed.'); $this->assertText($edit[$term_key], 'Term displayed.'); $this->assertLink(t('Back to content editing')); - - // Assert the content is kept when reloading the page. - $this->drupalGet('node/add/page', array('query' => array('uuid' => $uuid))); - $this->assertFieldByName($title_key, $edit[$title_key], 'Title field displayed.'); - $this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.'); - $this->assertFieldByName($term_key, $edit[$term_key] . ' (' . $this->term->id() . ')', 'Term field displayed.'); - + // Save the node. $this->drupalPostForm('node/add/page', $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit[$title_key]);