From c74f65a9681cffed8b43fbf83888d7f1b8f00d5b Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 27 May 2003 06:55:20 +0000 Subject: - Bugfix: assure that taxonomy_term_node_counts() only takes published nodes into account. Patch by Moshe. --- modules/taxonomy.module | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules/taxonomy.module') diff --git a/modules/taxonomy.module b/modules/taxonomy.module index c6d9f8103..70da7475c 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -501,17 +501,17 @@ function taxonomy_get_synonym_root($term) { return db_fetch_object(db_query("SELECT * FROM term_synonym s, term_data t WHERE t.tid = s.tid AND s.name = '%s'", $term)); } -// given a term id, count number of nodes in it +// given a term id, count number of published nodes in it function taxonomy_term_count_nodes($tid, $type = 0) { static $count; 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 GROUP BY t.tid"); + $result = db_query("SELECT t.tid, COUNT(*) AS c FROM term_node t LEFT JOIN node n ON t.nid = n.nid WHERE n.status = 1 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.type = '%s' GROUP BY t.tid", $type); + $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); } while ($term = db_fetch_object($result)) { $count[$type][$term->tid] = $term->c; -- cgit v1.2.3