diff --git a/includes/callback_node_access.inc b/includes/callback_node_access.inc index 2db6eeb..9357cc9 100644 --- a/includes/callback_node_access.inc +++ b/includes/callback_node_access.inc @@ -38,20 +38,14 @@ class SearchApiAlterNodeAccess extends SearchApiAbstractAlterCallback { * {@inheritdoc} */ public function alterItems(array &$items) { - static $implements_node_grants; - - if (!isset($implements_node_grants)) { - // Check if there are any modules that implement hook_node_grants. - $implements_node_grants = count(module_implements('node_grants')); - } - + // Check if there are any modules that implement hook_node_grants. + $implements_node_grants = (bool) module_implements('node_grants'); foreach ($items as $id => $item) { $node = $this->getNode($item); // Check implemented node_grants. if ($implements_node_grants) { // Get node access grants. - $result = db_query('SELECT * FROM {node_access} WHERE (nid = 0 OR nid = :nid) AND grant_view = 1', array(':nid' => $node->nid)); - + $result = db_query('SELECT realm, gid FROM {node_access} WHERE (nid = 0 OR nid = :nid) AND grant_view = 1', array(':nid' => $node->nid)); // Store all grants together with their realms in the item. foreach ($result as $grant) { $items[$id]->search_api_access_node[] = "node_access_{$grant->realm}:{$grant->gid}";