summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-12-29 21:51:26 +0000
committerDries Buytaert <dries@buytaert.net>2008-12-29 21:51:26 +0000
commit44c0672806bfe6e1535a4f1d3fddd8d4626af4ee (patch)
tree1d87d5c51334b91116ae52fcdee74ecaa5c02fa8
parenta04728577f34b98936c53799ccf1f2aaf7f3ff03 (diff)
downloadbrdo-44c0672806bfe6e1535a4f1d3fddd8d4626af4ee.tar.gz
brdo-44c0672806bfe6e1535a4f1d3fddd8d4626af4ee.tar.bz2
- Patch #352093 by catch: avoid unnecessary SQL query on front page when no node access modules are enabled.
-rw-r--r--modules/node/node.module30
1 files changed, 18 insertions, 12 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index db7871d49..adb807437 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -2303,21 +2303,27 @@ function node_access_view_all_nodes() {
static $access;
if (!isset($access)) {
- $grants = array();
- foreach (node_access_grants('view') as $realm => $gids) {
- foreach ($gids as $gid) {
- $grants[] = "(gid = $gid AND realm = '$realm')";
- }
+ // If no modules implement the node access system, access is always true.
+ if (!module_implements('node_grants')) {
+ $access = TRUE;
}
+ else {
+ $grants = array();
+ foreach (node_access_grants('view') as $realm => $gids) {
+ foreach ($gids as $gid) {
+ $grants[] = "(gid = $gid AND realm = '$realm')";
+ }
+ }
- $grants_sql = '';
- if (count($grants)) {
- $grants_sql = 'AND (' . implode(' OR ', $grants) . ')';
- }
+ $grants_sql = '';
+ if (count($grants)) {
+ $grants_sql = 'AND (' . implode(' OR ', $grants) . ')';
+ }
- $sql = "SELECT COUNT(*) FROM {node_access} WHERE nid = 0 $grants_sql AND grant_view >= 1";
- $result = db_query($sql);
- $access = db_result($result);
+ $sql = "SELECT COUNT(*) FROM {node_access} WHERE nid = 0 $grants_sql AND grant_view >= 1";
+ $result = db_query($sql);
+ $access = db_result($result);
+ }
}
return $access;