Issue #2326727 by swentel: Fixed Delete tempstore entry of preview in submit.

8.0.x
webchick 2014-08-25 21:29:34 -07:00
parent f941bebbd6
commit bfcd644b4a
2 changed files with 12 additions and 3 deletions

View File

@ -97,9 +97,6 @@ class NodeForm extends ContentEntityForm {
$form_state['rebuild'] = TRUE;
$this->entity = $preview['controller']->getEntity();
unset($this->entity->in_preview);
// Remove the entry from the temp store.
$store->delete($uuid);
}
/** @var \Drupal\node\NodeInterface $node */
@ -500,6 +497,12 @@ class NodeForm extends ContentEntityForm {
else {
$form_state->setRedirect('<front>');
}
// Remove the preview entry from the temp store, if any.
$store = $this->tempStoreFactory->get('node_preview');
if ($store->get($node->uuid())) {
$store->delete($node->uuid());
}
}
else {
// In the unlikely case something went wrong on save, the node will be

View File

@ -145,6 +145,12 @@ class PagePreviewTest extends NodeTestBase {
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
$this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
// 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], 'Term field displayed.');
// Save the node.
$this->drupalPostForm('node/add/page', $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit[$title_key]);