Monday 11 June 2007

Tagadelic patch

We've noticed that there's a small bug in the Tagadelic module for Drupal.

It doesn't pay attention to the status of nodes. ie: it uses unpublished content for its calculations.

Here's a patch to remedy that:
--- tagadelic.module.old        2007-06-10 17:55:54.980771815 +0100 
+++ tagadelic.module    2007-06-10 18:03:32.950326194 +0100 
@@ -211,7 +211,7 @@
    if (!is_array($vids) || count($vids) == 0) {
      return array();
    }
-  $result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size); 
+  $result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid INNER JOIN {node} nod ON n.nid = nod.nid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') AND nod.status = 1 GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size);
     return tagadelic_build_weighted_tags($result, $steps);  
}

No comments:

Post a Comment