Closed (fixed)
Project:
Taxonomy Image
Version:
5.x-1.0-beta1
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
26 Jan 2008 at 11:51 UTC
Updated:
20 Feb 2008 at 18:12 UTC
Using PostGres DB I'm getting an SQL error during the taxonomy_image_display() function requests.
This is due to an erroneous sql query on several lines of code in the function with queries lik this:
db_query('SELECT i.path, d.name FROM {term_image} i INNER JOIN {term_data} d WHERE i.tid = d.tid AND i.tid = %d', $tid)
the code should look something like this:
<?php
function taxonomy_image_display($tid, $tags = NULL) {
global $user;
static $image = array();
if (user_access('access taxonomy images') &&
!$user->taxonomy_image_disable_images) {
// do lookup, return full display path
if (!$image[$tid]->url) {
if ($image[$tid] = db_fetch_object(db_query('SELECT i.path, d.name FROM {term_image} i INNER JOIN {term_data} d ON i.tid = d.tid AND i.tid = %d', $tid))) {
$image[$tid]->url = file_create_url($image[$tid]->path);
}
else if (variable_get('taxonomy_image_recursive', 0)) {
// walk up the taxonomy hierarchy and look for an image
$orig = $tid;
while ($parent = db_fetch_object(db_query('SELECT t.tid FROM {term_hierarchy} h, {term_data} t ON h.parent = t.tid AND h.tid = %d ORDER BY weight, name', $tid))) {
$tid = $parent->tid;
if ($image[$tid]->url) {
// we have already loaded this image from the database
$image[$orig] = $image[$tid];
break;
}
else if ($image[$tid] = db_fetch_object(db_query('SELECT i.path, d.name FROM {term_image} i INNER JOIN {term_data} d ON i.tid = d.tid AND i.tid = %d', $tid))) {
// we found a parent with a configured image, use it
$image[$tid]->url = file_create_url($image[$tid]->path);
$image[$orig] = $image[$tid];
break;
}
}
}
}
...
/Sten
Comments
Comment #1
nancydruI'm not sure why this is working with MySql either; it is improperly constructed.
@stenjo: I'm not a PostgreSql user, but I actually prefer "... INNER JOIN ... USING(tid)..." Is that legal in PostgreSql? I've never had a complaint in any of my modules that use it.
Comment #2
nancydruAlso see http://drupal.org/node/34017
Comment #3
nancydruFix committed.
Comment #4
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.