From 52d9dd1b01029ff4cbd4a72af29ddfa4be889954 Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Mon, 15 Nov 2004 10:00:50 +0000 Subject: [PATCH] - Patch #11977 by matteo: taxonomy_term_count() did not take node-level permissions into account and could return an incorrect number. --- modules/taxonomy.module | 4 ++-- modules/taxonomy/taxonomy.module | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/taxonomy.module b/modules/taxonomy.module index ec883830d2a1..503449daa754 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -642,10 +642,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 INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 GROUP BY t.tid'); + $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'); } else { - $result = db_query("SELECT t.tid, COUNT(*) AS c FROM {term_node} t, {node} n WHERE t.nid = n.nid AND n.status = 1 AND n.type = '%s' GROUP BY t.tid", $type); + $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); } 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 ec883830d2a1..503449daa754 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -642,10 +642,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 INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 GROUP BY t.tid'); + $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'); } else { - $result = db_query("SELECT t.tid, COUNT(*) AS c FROM {term_node} t, {node} n WHERE t.nid = n.nid AND n.status = 1 AND n.type = '%s' GROUP BY t.tid", $type); + $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); } while ($term = db_fetch_object($result)) { $count[$type][$term->tid] = $term->c; -- GitLab