Viewing an empty image gallery produces an SQL error. The following one-line patch fixes it.
--- orig/image/contrib/image_gallery/image_gallery.module 2007-08-22 13:39:45.000000000 -0400
+++ patched/image/contrib/image_gallery/image_gallery.module 2007-09-06 14:08:13.000000000 -0400
@@ -145,7 +145,7 @@
$tree = taxonomy_get_tree(_image_gallery_get_vid(), $galleries[$i]->tid, -1);
$descendant_tids = array_merge(array($galleries[$i]->tid), array_map('_taxonomy_get_tid_from_term', $tree));
$last = db_fetch_object(db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN (%s) AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), implode(',', $descendant_tids), 0, 1));
- $galleries[$i]->latest = node_load(array('nid' => $last->nid));
+ $galleries[$i]->latest = node_load(array('nid' => intval($last->nid)));
}
$images = array();
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | image_gallery_173592.patch | 1.08 KB | drewish |
| image_gallery_1.patch | 842 bytes | pillarsdotnet |
Comments
Comment #1
drewish commentedwhat's the error? it's a good habit to post those, it makes it easier for others with the same problem to search for and find your issue. is this related to: http://drupal.org/node/133044 ?
Comment #2
drewish commentedit might not be related. why not just check check
if ($last)rather than calling node load with a null that's been cast to 0... seems kind of wasteful.Comment #3
pillarsdotnet commentedThanks. The error was about a type mismatch and might occur only on Postgres; it referred to a bad WHERE n.nid='' clause because the db_fetch_object() call was returning array('nid' => '').
So here's a a re-patch according to your suggestion, but it's no longer a one-liner:
Well, it *could* be a one-liner, but I'd rather preserve existing code practice than stuff the whole if-block on a single line.
Comment #4
drewish commentedokay, i'd committed #133044 so i had to adjust this. i committed the attached patch to HEAD and DRUPAL-5.
Comment #5
(not verified) commented