diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index d7c03ba7a5..457e546e5d 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -791,40 +791,38 @@ public function save(EntityInterface $entity) { * {@inheritdoc} */ public function restore(EntityInterface $entity) { - // Allow code to run before saving. - $entity->preSave($this); - $this->invokeFieldMethod('preSave', $entity); - $transaction = $this->database->startTransaction(); try { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ + // Allow code to run before saving. + $entity->preSave($this); + $this->invokeFieldMethod('preSave', $entity); - // Insert the entity data in the base table only for default revisions. + // Insert the entity data in the base and data tables only for default + // revisions. if ($entity->isDefaultRevision()) { $record = $this->mapToStorageRecord($entity->getUntranslated(), $this->baseTable); $this->database ->insert($this->baseTable) ->fields((array) $record) ->execute(); + + if ($this->dataTable) { + $this->saveToSharedTables($entity); + } } - // Insert the entity data in the revision table. + // Insert the entity data in the revision and revision data tables. if ($this->revisionTable) { $record = $this->mapToStorageRecord($entity->getUntranslated(), $this->revisionTable); $this->database ->insert($this->revisionTable) ->fields((array) $record) ->execute(); - } - // Insert the entity data in the data table only for default revisions. - if ($this->dataTable && $entity->isDefaultRevision()) { - $this->saveToSharedTables($entity); - } - - // Insert the entity data in the revision data table. - if ($this->revisionDataTable) { - $this->saveToSharedTables($entity, $this->revisionDataTable); + if ($this->revisionDataTable) { + $this->saveToSharedTables($entity, $this->revisionDataTable); + } } // Insert the entity data in the dedicated tables.