=== modified file 'modules/node/node.module' --- modules/node/node.module 2010-08-11 21:05:18 +0000 +++ modules/node/node.module 2010-11-12 06:56:33 +0000 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 @@ -2018,16 +2058,24 @@ 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)) { + $rights[$account->uid][$node->nid][$op] = FALSE; return FALSE; } if (user_access('administer nodes', $account)) { + $rights[$account->uid][$node->nid][$op] = TRUE; return TRUE; } if (!user_access('access content', $account)) { + $rights[$account->uid][$node->nid][$op] = FALSE; return FALSE; } @@ -2039,6 +2087,9 @@ } $access = module_invoke($module, 'access', $op, $node, $account); if (!is_null($access)) { + if (isset($node->nid)) { + $rights[$account->uid][$node->nid][$op] = $access; + } return $access; } @@ -2059,11 +2110,13 @@ $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); - return (bool) db_result($result); + $rights[$account->uid][$node->nid][$op] = (bool) db_result($result); + return $rights[$account->uid][$node->nid][$op]; } // Let authors view their own nodes. if ($op == 'view' && $account->uid == $node->uid && $account->uid != 0) { + $rights[$account->uid][$node->nid][$op] = TRUE; return TRUE; }