Closed (fixed)
Project:
autocategorise
Version:
6.x-1.3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Mar 2009 at 06:11 UTC
Updated:
30 Apr 2009 at 10:15 UTC
If you look closely at the function below, the SQL statement is run even when count($terms) is 0 and thus $where_tids and $where_nid are still NULL. You should move the db_query() call inside the if(count($terms)) block. (One line before where it is now.)
//remove terms from this vocab either for one or for all nodes
function autocategorise_clear_terms($vid, $nid = 'nid') {
//get a list of all the tids in this vocab
$terms = taxonomy_get_tree($vid);
if (count($terms)) {
foreach ($terms as $term) {
$where_tids[] = 'tid = '.$term->tid;
}
$where_tids = implode (' OR ', $where_tids);
if (is_numeric($nid)) {
$where_nid = ' nid =' . $nid;
} else {
$where_nid = '1=1';
}
}
db_query('DELETE FROM {term_node} WHERE (' . $where_tids . ') AND ' . $where_nid);
}
Thank you.
Alexis Wilke
Comments
Comment #1
matslats commentedThanks