diff --git a/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Comment.php b/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Comment.php index cb93447..ec93709 100644 --- a/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Comment.php +++ b/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Comment.php @@ -33,16 +33,15 @@ public function entityFieldQueryAlter(SelectInterface $query) { // Adding the 'comment_access' tag is sadly insufficient for comments: core // requires us to also know about the concept of 'published' and // 'unpublished'. + $tables = $query->getTables(); + $base_table = $tables['base_table']['alias']; if (!user_access('administer comments')) { - $tables = $query->getTables(); - $query->condition(key($tables) . '.status', COMMENT_PUBLISHED); + $query->condition("$base_table.status", COMMENT_PUBLISHED); } // The Comment module doesn't implement any proper comment access, // and as a consequence doesn't make sure that comments cannot be viewed // when the user doesn't have access to the node. - $tables = $query->getTables(); - $base_table = key($tables); $node_alias = $query->innerJoin('node', 'n', '%alias.nid = ' . $base_table . '.nid'); // Pass the query to the node access control. $this->reAlterQuery($query, 'node_access', $node_alias); diff --git a/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/File.php b/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/File.php index 05e62ef..858645c 100644 --- a/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/File.php +++ b/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/File.php @@ -32,7 +32,7 @@ class File extends SelectionGeneric { public function entityFieldQueryAlter(SelectInterface $query) { // Core forces us to know about 'permanent' vs. 'temporary' files. $tables = $query->getTables(); - $base_table = key($tables); + $base_table = $tables['base_table']['alias']; $query->condition('status', FILE_STATUS_PERMANENT); // Access control to files is a very difficult business. For now, we are not diff --git a/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Node.php b/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Node.php index dc97ff0..b5dd021 100644 --- a/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Node.php +++ b/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Node.php @@ -37,7 +37,8 @@ public function entityFieldQueryAlter(SelectInterface $query) { // it is supposed to handle this check. if (!user_access('bypass node access') && !count(module_implements('node_grants'))) { $tables = $query->getTables(); - $query->condition(key($tables) . '.status', NODE_PUBLISHED); + $base_table = $tables['base_table']['alias']; + $query->condition("$base_table.status", NODE_PUBLISHED); } } } diff --git a/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Term.php b/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Term.php index 6fe925e..7b8cbc8 100644 --- a/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Term.php +++ b/core/modules/field/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/Term.php @@ -34,7 +34,7 @@ public function entityFieldQueryAlter(SelectInterface $query) { // and as a consequence doesn't make sure that taxonomy terms cannot be // viewed when the user doesn't have access to the vocabulary. $tables = $query->getTables(); - $base_table = key($tables); + $base_table = $tables['base_table']['alias']; $vocabulary_alias = $query->innerJoin('taxonomy_vocabulary', 'n', '%alias.vid = ' . $base_table . '.vid'); $query->addMetadata('base_table', $vocabulary_alias); // Pass the query to the taxonomy access control.