diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 42d968d..caf16d7 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -3313,13 +3313,20 @@ function _node_query_node_access_alter($query, $type) { // in a separate db_and() object and then at the end add it to the query. $entity_conditions = db_and(); } + + // Do not allow node queries to JOIN to node more than once. That is a + // recipe for fail. + $tables_used = array(); foreach ($tables as $nalias => $tableinfo) { $table = $tableinfo['table']; - if (!($table instanceof SelectInterface) && $table == $base_table) { + if (!($table instanceof SelectInterface) && $table == $base_table && !isset($tables_used[$table])) { // Set the subquery. $subquery = db_select('node_access', 'na') ->fields('na', array('nid')); + // Ensure we do not double-join to a table. + $tables_used[$table] = $table; + $grant_conditions = db_or(); // If any grant exists for the specified user, then user has access // to the node for the specified operation.