X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FQuery%2FSql%2FQuery.php;h=50b81bba91d358148fff24803d36d8e068fe1bdb;hp=cd245ef7b5284511a979f00ea05ef217b661783d;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php b/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php index cd245ef7b..50b81bba9 100644 --- a/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php +++ b/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php @@ -119,6 +119,14 @@ class Query extends QueryBase implements QueryInterface { // entity id. $this->sqlFields["base_table.$id_field"] = ['base_table', $id_field]; } + + // Add a self-join to the base revision table if we're querying only the + // latest revisions. + if ($this->latestRevision && $revision_field) { + $this->sqlQuery->leftJoin($base_table, 'base_table_2', "base_table.$id_field = base_table_2.$id_field AND base_table.$revision_field < base_table_2.$revision_field"); + $this->sqlQuery->isNull("base_table_2.$id_field"); + } + if ($this->accessCheck) { $this->sqlQuery->addTag($this->entityTypeId . '_access'); }