Commit 44c06728 authored by Dries's avatar Dries
Browse files

- Patch #352093 by catch: avoid unnecessary SQL query on front page when no...

- Patch #352093 by catch: avoid unnecessary SQL query on front page when no node access modules are enabled.
parent a0472857
...@@ -2303,21 +2303,27 @@ function node_access_view_all_nodes() { ...@@ -2303,21 +2303,27 @@ function node_access_view_all_nodes() {
static $access; static $access;
if (!isset($access)) { if (!isset($access)) {
$grants = array(); // If no modules implement the node access system, access is always true.
foreach (node_access_grants('view') as $realm => $gids) { if (!module_implements('node_grants')) {
foreach ($gids as $gid) { $access = TRUE;
$grants[] = "(gid = $gid AND realm = '$realm')";
}
} }
else {
$grants = array();
foreach (node_access_grants('view') as $realm => $gids) {
foreach ($gids as $gid) {
$grants[] = "(gid = $gid AND realm = '$realm')";
}
}
$grants_sql = ''; $grants_sql = '';
if (count($grants)) { if (count($grants)) {
$grants_sql = 'AND (' . implode(' OR ', $grants) . ')'; $grants_sql = 'AND (' . implode(' OR ', $grants) . ')';
} }
$sql = "SELECT COUNT(*) FROM {node_access} WHERE nid = 0 $grants_sql AND grant_view >= 1"; $sql = "SELECT COUNT(*) FROM {node_access} WHERE nid = 0 $grants_sql AND grant_view >= 1";
$result = db_query($sql); $result = db_query($sql);
$access = db_result($result); $access = db_result($result);
}
} }
return $access; return $access;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment