diff options
author | David Rothstein <drothstein@gmail.com> | 2012-07-29 16:32:53 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2012-07-29 16:32:53 -0400 |
commit | bada57662c3bf6f2aa1cb1cc899abc98506a4679 (patch) | |
tree | bb9f0b59388d21851e87183eadf30e10ea62b6ea /modules/node/node.module | |
parent | 331a3756c369eb4f08272a7a5721a13fd841dfae (diff) | |
download | brdo-bada57662c3bf6f2aa1cb1cc899abc98506a4679.tar.gz brdo-bada57662c3bf6f2aa1cb1cc899abc98506a4679.tar.bz2 |
Issue #1571104 by BTMash, Dave.Ingram, mradcliffe, Damien Tournoud, sun, lliss, tim.plunkett | lkiss80: Fixed Can't access non-node entities with EntityFieldQuery.
Diffstat (limited to 'modules/node/node.module')
-rw-r--r-- | modules/node/node.module | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/modules/node/node.module b/modules/node/node.module index 71ea3b923..264816c00 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -3273,8 +3273,9 @@ function _node_query_node_access_alter($query, $type) { // @endcode // // So instead of directly adding to the query object, we need to collect - // in a separate db_and() object and then at the end add it to the query. - $entity_conditions = db_and(); + // all of the node access conditions in a separate db_and() object and + // then add it to the query at the end. + $node_conditions = db_and(); } foreach ($tables as $nalias => $tableinfo) { $table = $tableinfo['table']; @@ -3308,16 +3309,24 @@ function _node_query_node_access_alter($query, $type) { $field = 'entity_id'; } $subquery->where("$nalias.$field = na.nid"); - $query->exists($subquery); + + // For an entity query, attach the subquery to entity conditions. + if ($type == 'entity') { + $node_conditions->exists($subquery); + } + // Otherwise attach it to the node query itself. + else { + $query->exists($subquery); + } } } if ($type == 'entity' && count($subquery->conditions())) { // All the node access conditions are only for field values belonging to // nodes. - $entity_conditions->condition("$base_alias.entity_type", 'node'); + $node_conditions->condition("$base_alias.entity_type", 'node'); $or = db_or(); - $or->condition($entity_conditions); + $or->condition($node_conditions); // If the field value belongs to a non-node entity type then this function // does not do anything with it. $or->condition("$base_alias.entity_type", 'node', '<>'); |