diff --git a/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php b/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php index 93c3450..76c042d 100644 --- a/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php +++ b/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php @@ -41,7 +41,7 @@ class EntityReferenceRevisionsItem extends EntityReferenceItem implements Option /** * Reference to the entity pointed to by this field. */ - protected $entity; + protected $entity_cache; /** * {@inheritdoc} @@ -213,15 +213,18 @@ class EntityReferenceRevisionsItem extends EntityReferenceItem implements Option if (isset($this->entity)) { return $this->entity; } + elseif (isset($this->entity_cache)) { + return $this->entity_cache; + } elseif (isset($this->target_id)) { $storage = \Drupal::entityTypeManager()->getStorage($this->getSetting('target_type')); // By default always load the default revision, so caches get used. - $this->entity = $storage->load($this->target_id); - if ($this->entity !== NULL && $this->entity->getRevisionId() != $this->revision_id) { + $this->entity_cache = $storage->load($this->target_id); + if ($this->entity_cache !== NULL && $this->entity_cache->getRevisionId() != $this->revision_id) { // A non-default revision is a referenced, so load this one. - $this->entity = $storage->loadRevision($this->revision_id); + $this->entity_cache = $storage->loadRevision($this->revision_id); } - return $this->entity; + return $this->entity_cache; } }