diff --git a/src/Plugin/BaseUpdateRunner.php b/src/Plugin/BaseUpdateRunner.php index d748848..481e666 100644 --- a/src/Plugin/BaseUpdateRunner.php +++ b/src/Plugin/BaseUpdateRunner.php @@ -159,8 +159,10 @@ abstract class BaseUpdateRunner extends PluginBase implements UpdateRunnerInterf if ($field_ids = $this->getReferencingFieldIds()) { $entity_storage = $this->entityTypeManager->getStorage($this->updateEntityType()); foreach ($field_ids as $field_id) { - - $query = $entity_storage->getQuery('AND')->accessCheck(TRUE); + $query = $entity_storage->getQuery('AND'); + // Disable accces checks to find all revisions. + // See https://www.drupal.org/node/2872239. + $query->accessCheck(FALSE); $this->addActiveUpdateConditions($query, "$field_id.entity."); $entity_ids += $query->execute(); } diff --git a/src/Plugin/UpdateRunner/EmbeddedUpdateRunner.php b/src/Plugin/UpdateRunner/EmbeddedUpdateRunner.php index 5cd5740..a59a167 100644 --- a/src/Plugin/UpdateRunner/EmbeddedUpdateRunner.php +++ b/src/Plugin/UpdateRunner/EmbeddedUpdateRunner.php @@ -195,7 +195,9 @@ class EmbeddedUpdateRunner extends BaseUpdateRunner implements EntityMonitorUpda $type = $entity->getEntityType(); $query = $this->entityTypeManager->getStorage($entity->getEntityTypeId()) ->getQuery() - ->accessCheck(TRUE); + // Disable accces checks to find all revisions. + // See https://www.drupal.org/node/2872239. + ->accessCheck(FALSE); $query->allRevisions() ->condition($type->getKey('id'), $entity->id()) ->condition($type->getKey('revision'), $entity->getRevisionId(), '<') diff --git a/src/Plugin/UpdateRunner/LatestRevisionUpdateRunner.php b/src/Plugin/UpdateRunner/LatestRevisionUpdateRunner.php index 5d7c8ed..8e5f1ac 100644 --- a/src/Plugin/UpdateRunner/LatestRevisionUpdateRunner.php +++ b/src/Plugin/UpdateRunner/LatestRevisionUpdateRunner.php @@ -46,7 +46,9 @@ class LatestRevisionUpdateRunner extends EmbeddedUpdateRunner { if ($all_ready_update_ids) { foreach ($field_ids as $field_id) { $query = $entity_storage->getQuery('AND') - ->accessCheck(TRUE); + // Disable accces checks to find all revisions. + // See https://www.drupal.org/node/2872239. + ->accessCheck(FALSE); $query->condition("$field_id.target_id", $all_ready_update_ids, 'IN'); $query->allRevisions(); diff --git a/src/UpdateUtils.php b/src/UpdateUtils.php index 0223457..bfd8a2d 100644 --- a/src/UpdateUtils.php +++ b/src/UpdateUtils.php @@ -129,11 +129,13 @@ class UpdateUtils implements UpdateUtilsInterface { public function getLatestRevisionId($entity_type_id, $entity_id) { if ($storage = $this->entityTypeManager->getStorage($entity_type_id)) { $revision_ids = $storage->getQuery() - ->accessCheck(TRUE) + // Disable accces checks to find all revisions. + // See https://www.drupal.org/node/2872239. + ->accessCheck(FALSE) ->allRevisions() ->condition($this->entityTypeManager->getDefinition($entity_type_id)->getKey('id'), $entity_id) ->sort($this->entityTypeManager->getDefinition($entity_type_id)->getKey('revision'), 'DESC') - ->pager(1) + ->range(0, 1) ->execute(); if ($revision_ids) { $revision_id = array_keys($revision_ids)[0]; @@ -204,10 +206,13 @@ class UpdateUtils implements UpdateUtilsInterface { $query = $storage->getQuery()->accessCheck(TRUE); $type = $entity->getEntityType(); $query->allRevisions() + // Disable accces checks to find all revisions. + // See https://www.drupal.org/node/2872239. + ->accessCheck(FALSE) ->condition($type->getKey('id'), $entity->id()) ->condition($type->getKey('revision'), $entity->getRevisionId(), '<') ->sort($type->getKey('revision'), 'DESC') - ->pager(1); + ->range(0, 1); $revision_ids = $query->execute(); if ($revision_ids) { $revision_id = array_keys($revision_ids)[0];