function ContentEntityStorageBase::loadRevisionUnchanged

Loads an unchanged entity by revision ID from the database.

@todo Remove this method once we have a reliable way to retrieve the unchanged revision from the entity object.

Parameters

int $revision_id: The revision ID of the entity to load.

Return value

\Drupal\Core\Entity\EntityInterface|null The unchanged entity, or NULL if the entity cannot be loaded.

Overrides RevisionableStorageInterface::loadRevisionUnchanged

1 call to ContentEntityStorageBase::loadRevisionUnchanged()
ContentEntityStorageBase::doPreSave in core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
Performs presave entity processing.

File

core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php, line 780

Class

ContentEntityStorageBase
Base class for content entity storage handlers.

Namespace

Drupal\Core\Entity

Code

public function loadRevisionUnchanged($revision_id) : ?EntityInterface {
  // Load the revision by ignoring the static entity revision cache.
  $revision_ids = [
    $revision_id,
  ];
  $revisions = $this->getFromPersistentRevisionCache($revision_ids);
  if ($revisions) {
    $revision = $revisions[$revision_id];
    $entities = [
      $revision->id() => $revision,
    ];
    $this->postLoad($entities);
  }
  else {
    $this->ignoreStaticRevisionCache = TRUE;
    $revision = $this->loadRevision($revision_id);
    $this->ignoreStaticRevisionCache = FALSE;
  }
  return $revision;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.