diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index e63cafd..7fb987e 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -16,7 +16,7 @@ * * @ingroup entity_api */ -abstract class ContentEntityBase extends Entity implements \IteratorAggregate, ContentEntityInterface, OriginalRevisionIdInterface { +abstract class ContentEntityBase extends Entity implements \IteratorAggregate, ContentEntityInterface { /** * Status code identifying a removed translation. @@ -163,7 +163,7 @@ protected $validationRequired = FALSE; /** - * The original revision id before the new revision was set. + * The original revision ID before the new revision was set. * * @var int */ @@ -237,9 +237,11 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans } } } - // Store the original revision identfier the entity has been loaded with to - // keep it safe from changes. - $this->originalRevisionId = $this->getRevisionId(); + if ($this->getEntityType()->isRevisionable()) { + // Store the original revision ID the entity has been loaded with to + // keep it safe from changes. + $this->originalRevisionId = $this->getRevisionId(); + } } /** @@ -273,6 +275,8 @@ public function setNewRevision($value = TRUE) { throw new \LogicException("Entity type {$this->getEntityTypeId()} does not support revisions."); } + $this->originalRevisionId = $this->getRevisionId(); + if ($value && !$this->newRevision) { // When saving a new revision, set any existing revision ID to NULL so as // to ensure that a new revision will actually be created. @@ -301,13 +305,6 @@ public function getOriginalRevisionId() { /** * {@inheritdoc} */ - public function resetOriginalRevisionId() { - $this->originalRevisionId = $this->getRevisionId(); - } - - /** - * {@inheritdoc} - */ public function isNewRevision() { return $this->newRevision || ($this->getEntityType()->hasKey('revision') && !$this->getRevisionId()); } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityInterface.php b/core/lib/Drupal/Core/Entity/ContentEntityInterface.php index 0c3f04b..684aaa7 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityInterface.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityInterface.php @@ -53,4 +53,13 @@ public function setRevisionTranslationAffected($affected); */ public function isRevisionTranslationAffected(); + /** + * Gets the original revision identifier of the entity. + * + * @return int + * The original revision identifier of the entity, or NULL if the entity + * does not have a revision identifier. + */ + public function getOriginalRevisionId(); + } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index ef936cc..afdce40 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -305,9 +305,6 @@ protected function doPostSave(EntityInterface $entity, $update) { // The revision is stored, it should no longer be marked as new now. if ($this->entityType->isRevisionable()) { - if ($entity instanceof OriginalRevisionIdInterface) { - $entity->resetOriginalRevisionId(); - } $entity->setNewRevision(FALSE); } }