Postgres cannot take a null value when checking against an integer, such as looking for the latest image in a gallery when there are no images in the gallery. This problem can be traced to line 378 in image.module with the line $albums[$i]->latest = node_load(array('nid' => $last->nid));

A check to see if there is even an image returned should be done to make sure there are no errors in Postgres. I propose the following to replace that line:

if (isset($last->nid)) {
  $albums[$i]->latest = node_load(array('nid' => $last->nid));
}

I have tested it on a prototype site running under Postgres and have no problems so far and it fixes the problem.

CommentFileSizeAuthor
#1 image_3.patch1.56 KBjoe@www.joepilot.net

Comments

joe@www.joepilot.net’s picture

StatusFileSize
new1.56 KB

I found that Postgres was throwing a bunch of errors because of db_rewrite_query adding DISTINCTS to the query. db_rewrite_query was also causing errors when viewing the albums. The order of the INNER JOIN in the query caused a relation that was referenced to not exist. The attached patch fixes that as well as the previously mentioned problems.

drewish’s picture

Status: Needs review » Fixed

that's not a valid patch so it's hard to compare to the current code but i checked and it looks like all the queries are correct now.

Anonymous’s picture

Status: Fixed » Closed (fixed)