Mercurial > hg > isophonics-drupal-site
diff core/modules/content_moderation/src/ModerationInformation.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | 1fec387a4317 |
line wrap: on
line diff
--- a/core/modules/content_moderation/src/ModerationInformation.php Fri Feb 23 15:51:18 2018 +0000 +++ b/core/modules/content_moderation/src/ModerationInformation.php Fri Feb 23 15:52:07 2018 +0000 @@ -84,14 +84,15 @@ */ public function getLatestRevisionId($entity_type_id, $entity_id) { if ($storage = $this->entityTypeManager->getStorage($entity_type_id)) { - $revision_ids = $storage->getQuery() - ->allRevisions() + $result = $storage->getQuery() + ->latestRevision() ->condition($this->entityTypeManager->getDefinition($entity_type_id)->getKey('id'), $entity_id) - ->sort($this->entityTypeManager->getDefinition($entity_type_id)->getKey('revision'), 'DESC') - ->range(0, 1) + // No access check is performed here since this is an API function and + // should return the same ID regardless of the current user. + ->accessCheck(FALSE) ->execute(); - if ($revision_ids) { - return array_keys($revision_ids)[0]; + if ($result) { + return key($result); } } } @@ -101,13 +102,15 @@ */ public function getDefaultRevisionId($entity_type_id, $entity_id) { if ($storage = $this->entityTypeManager->getStorage($entity_type_id)) { - $revision_ids = $storage->getQuery() + $result = $storage->getQuery() + ->currentRevision() ->condition($this->entityTypeManager->getDefinition($entity_type_id)->getKey('id'), $entity_id) - ->sort($this->entityTypeManager->getDefinition($entity_type_id)->getKey('revision'), 'DESC') - ->range(0, 1) + // No access check is performed here since this is an API function and + // should return the same ID regardless of the current user. + ->accessCheck(FALSE) ->execute(); - if ($revision_ids) { - return array_keys($revision_ids)[0]; + if ($result) { + return key($result); } } }