diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-11-29 12:52:44 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-11-29 12:52:44 +0000 |
commit | e7ce1e3ccb7dce31aa9f4ecdaa66f9c1d3953e8c (patch) | |
tree | d53d5f063c93bc39c7d7faf9795f15b786be772d | |
parent | b83b34018f38006c7a099e8d6f9853a23ffc8633 (diff) | |
download | brdo-e7ce1e3ccb7dce31aa9f4ecdaa66f9c1d3953e8c.tar.gz brdo-e7ce1e3ccb7dce31aa9f4ecdaa66f9c1d3953e8c.tar.bz2 |
- Patch #11977 by matteo: added extra DISTINCT()s to two SQL queries to make them work with node-level permissions.
-rw-r--r-- | modules/taxonomy.module | 4 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 05068c0f5..c231a327d 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -646,10 +646,10 @@ function taxonomy_term_count_nodes($tid, $type = 0) { if (!isset($count[$type])) { // $type == 0 always evaluates true is $type is a string if (is_numeric($type)) { - $result = db_query('SELECT t.tid, COUNT(*) AS c FROM {term_node} t '. node_access_join_sql() .'INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND '. node_access_where_sql() .'GROUP BY t.tid'); + $result = db_query('SELECT t.tid, COUNT(DISTINCT(n.nid)) AS c FROM {term_node} t '. node_access_join_sql() .'INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND '. node_access_where_sql() .'GROUP BY t.tid'); } else { - $result = db_query("SELECT t.tid, COUNT(*) AS c FROM {term_node} t, {node} n ". node_access_join_sql() ." WHERE t.nid = n.nid AND n.status = 1 AND n.type = '%s' AND ". node_access_where_sql() ." GROUP BY t.tid", $type); + $result = db_query("SELECT t.tid, COUNT(DISTINCT(n.nid)) AS c FROM {term_node} t, {node} n ". node_access_join_sql() ." WHERE t.nid = n.nid AND n.status = 1 AND n.type = '%s' AND ". node_access_where_sql() ." GROUP BY t.tid", $type); } while ($term = db_fetch_object($result)) { $count[$type][$term->tid] = $term->c; diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 05068c0f5..c231a327d 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -646,10 +646,10 @@ function taxonomy_term_count_nodes($tid, $type = 0) { if (!isset($count[$type])) { // $type == 0 always evaluates true is $type is a string if (is_numeric($type)) { - $result = db_query('SELECT t.tid, COUNT(*) AS c FROM {term_node} t '. node_access_join_sql() .'INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND '. node_access_where_sql() .'GROUP BY t.tid'); + $result = db_query('SELECT t.tid, COUNT(DISTINCT(n.nid)) AS c FROM {term_node} t '. node_access_join_sql() .'INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND '. node_access_where_sql() .'GROUP BY t.tid'); } else { - $result = db_query("SELECT t.tid, COUNT(*) AS c FROM {term_node} t, {node} n ". node_access_join_sql() ." WHERE t.nid = n.nid AND n.status = 1 AND n.type = '%s' AND ". node_access_where_sql() ." GROUP BY t.tid", $type); + $result = db_query("SELECT t.tid, COUNT(DISTINCT(n.nid)) AS c FROM {term_node} t, {node} n ". node_access_join_sql() ." WHERE t.nid = n.nid AND n.status = 1 AND n.type = '%s' AND ". node_access_where_sql() ." GROUP BY t.tid", $type); } while ($term = db_fetch_object($result)) { $count[$type][$term->tid] = $term->c; |