Ran into a problem on a custom page module I wrote + taxonomy block, where taxonomy block wasn't returning any tids, so was having an sql query error.
I patched taxonomy_block to have a sizeof($tids) check before the sql query and rendering the block...
query: SELECT DISTINCT(n.nid), n.title, n.body FROM term_node t INNER JOIN node n ON t.nid = n.nid WHERE t.tid IN () AND n.status = 1 ORDER BY sticky DESC, created DESC LIMIT 8 in /var/www/domains/p/post.thing.net/public_html/drupal-4.6.0/includes/database.mysql.inc on line 66.
you will find the patch inline, and the custom module I was having the problem with attached.
diff -ub output...
--- taxonomy_block/taxonomy_block.module 2005-03-03 13:02:40.000000000 -0500
+++ taxonomy_block.rev/taxonomy_block.module 2005-04-27 18:08:19.521437000 -0400
@@ -228,7 +228,8 @@
}
}
- $nodes = db_query(db_rewrite_sql('SELECT DISTINCT(n.nid), n.title, n.body FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE t.tid IN (%s) AND n.status = 1 ORDER BY sticky DESC, created DESC LIMIT %d'), implode($tids, ','), $result->length);
+ if (sizeof($tids)) {
+ $nodes = db_query(db_rewrite_sql('SELECT DISTINCT(n.nid), n.title, n.body FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE t.tid IN (%s) AND n.status = 1 ORDER BY n.sticky DESC, created DESC LIMIT %d'), implode($tids, ','), $result->length);
$block['subject'] = $result->name;
@@ -250,6 +251,11 @@
else {
return null;
}
+
+ }
+ else {
+ return null;
+ }
}
/**
| Comment | File | Size | Author |
|---|---|---|---|
| mostrecent-4.6.0.tar.gz | 10 KB | dopry |
Comments
Comment #1
dopry commentedoops... not sure that the n.sticky update to the sql auery should be there....
Comment #2
dopry commenteddiscovered cause... taxonomy block referencing deleted taxonomy term
Comment #3
crunchywelch commentedshould be fixed now in any case, $tids is declared an array first to prevent an error on implode()
Comment #4
crunchywelch commented