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.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

alexpott created an issue. See original summary.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.