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

nancydru’s picture

Title: Error fetching image » PostgreSql Error fetching image

I'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.

nancydru’s picture

nancydru’s picture

Assigned: Unassigned » nancydru
Status: Active » Fixed

Fix committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.