Using Views Bulk Operations, I was assigning nodes (in bulk) to various terms. I was getting a bunch of errors from term_node_count_count_nodes() as VBO was passing BLANK terms.
Short story ... instead of producing an erroneous list like (45,,113) and chucking an error, using my "workaround" you can guard against people passing blank $tids into the term_node_count_count_nodes() function.
File: term_count.module
Line 103,104:
$tids_list = implode(',', $terms);
$tids_list = rtrim($tids_list, ',');
should be changed to:
$tids_cache=array();
foreach($terms as $tid){if($tid) $tids_cache[]=$tid;}
$tids_list = implode(',',$tids_cache);
Not really a bug with the module ... just a bit of defensive coding that fixes an error I was having.
One day I'll learn how to roll a patch. Hope I made sense.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | term_node_count-560172-1.patch | 542 bytes | agileware |
Comments
Comment #1
agileware commentedHere is a patch that should fix this.
I would classify it as a bug because it is a problem with the code that causes an error.
An example of this error for people who are trying to find a solution for this problem is:
Comment #2
alexku commentedI think the real problem is on line 168: if ($key != 'tags')
From the PHP manual: If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically.
try: var_dump(0 != 'tags'); and you will get 0 in the result
So the solution would be: if ($key !== 'tags')
Spent few hours trying to understand what is wrong with my code before noticing this little bug :)
Comment #3
Pls commentedI might make a patch from alexku comments this week. Let's test it before patch. Thanks.
Comment #4
YK85 commentedsubscribing