Problem/Motivation
Using \Drupal\Core\Entity\Query\QueryInterface::latestRevision() to mark a query as only for the latest revision was slow prior to #2950869: Entity queries querying the latest revision very slow with lots of revisions. The most common use-case is the query in \Drupal\Core\Entity\ContentEntityStorageBase::getLatestRevisionId(). This could be further improved by doing something like:
$result = $this->getQuery()
->allRevisions()
->condition($this->entityType->getKey('id'), $entity_id)
->range(0, 1)
->sort($this->entityType->getKey('revision'), 'DESC')
->accessCheck(FALSE)
->execute();
However \Drupal\workspaces\EntityQuery\QueryTrait::prepare() very much treats the call to ->latestRevision() as API. We could do something like we did in #3045177: Entity queries for latest revisions should return the latest workspace-specific revisions and add metadata to the query to help workspaces.
Comments