Index: modules/node/node.module =================================================================== --- modules/node/node.module (revision 4057) +++ modules/node/node.module (working copy) @@ -2043,6 +2043,7 @@ */ function node_access($op, $node, $account = NULL) { global $user; + static $rights = array(); if (!$node || !in_array($op, array('view', 'update', 'delete', 'create'), TRUE)) { // If there was no node to check against, or the $op was not one of the @@ -2057,6 +2058,11 @@ if (empty($account)) { $account = $user; } + + // Return cached value if it exists. + if (isset($node->nid) && isset($rights[$account->uid][$node->nid][$op])) { + return $rights[$account->uid][$node->nid][$op]; + } // If the node is in a restricted format, disallow editing. if ($op == 'update' && !filter_access($node->format)) { return FALSE; @@ -2078,6 +2084,9 @@ } $access = module_invoke($module, 'access', $op, $node, $account); if (!is_null($access)) { + if (isset($node->nid)) { + $rights[$account->uid][$node->nid][$op] = $result; + } return $access; } @@ -2098,6 +2107,7 @@ $sql = "SELECT 1 FROM {node_access} WHERE (nid = 0 OR nid = %d) $grants_sql AND grant_$op >= 1"; $result = db_query_range($sql, $node->nid, 0, 1); + $rights[$account->uid][$node->nid][$op] = (bool) $result; return (bool) db_result($result); }