- Bugfix: assure that taxonomy_term_node_counts() only takes published nodes
into account. Patch by Moshe.4.2.x
parent
b9e8016fc1
commit
c74f65a968
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue