diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 4b420f7..aa7efd8 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -395,17 +395,6 @@ public function preSaveRevision(EntityStorageInterface $storage, \stdClass $reco /** * {@inheritdoc} */ - public function save() { - if ($this->getEntityType()->isRevisionable()) { - // Make sure the loaded revision id is set before saving. - $this->updateLoadedRevisionId(); - } - return parent::save(); - } - - /** - * {@inheritdoc} - */ public function validate() { $this->validated = TRUE; $violations = $this->getTypedData()->validate(); diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index fe25250..db73c6f 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -288,6 +288,13 @@ protected function doPreSave(EntityInterface $entity) { // Sync the changes made in the fields array to the internal values array. $entity->updateOriginalValues(); + if ($entity->getEntityType()->isRevisionable() && !$entity->isNew() && empty($entity->getLoadedRevisionId())) { + // Update the loaded revision id for rare special cases when no loaded + // revision is given when updating an existing entity. This for example + // happens when calling save() in hook_entity_insert(). + $entity->updateLoadedRevisionId(); + } + return parent::doPreSave($entity); }