Code to get last uploaded image breaks on subalbums

Blazer0x

Joined: 2005-10-17
Posts: 12
Posted: Thu, 2006-02-09 20:20

I'm using Gallery 1.x, and I'm using the attached "lastimage.php" script, which pulls and displays the LAST UPLOADED IMAGE.

I use it for "moblogging", and it displays the last picture I sent from my cellphone in the sidebar of my site.

This script works great, except if I create any galleries that have a nested (sub-gallery) gallery, it breaks with the error "Call to a member function on a non-object".

If I add some debug print statements, I can see that it breaks upon checking the gallery that has a sub gallery.

If anyone has any idea how to correct the problem (Other than using Gallery2 instead), it would be much appreciated.

AttachmentSize
lastimage.php.txt5.95 KB
 
Blazer0x

Joined: 2005-10-17
Posts: 12
Posted: Thu, 2006-02-09 20:38

I should probably mention the exact error that gets generated:
PHP Fatal error: Call to a member function on a non-object in /www/apps/gallery/classes/AlbumItem.php on line 58

Line 58 of AlbumItem.php is part of the setUploadDate function, and is shown as the last line of the code snippet below

 function setUploadDate($uploadDate="") { //upload date should only be set at file upload time.
                global $gallery;

                if ($uploadDate) { // set the upload time from the time provided
                        $this->uploadDate = $uploadDate;
                } else { // if nothing is passed in, get the upload time from the file creation time
                        $dir = $gallery->album->getAlbumDir();
 
ckdake
ckdake's picture

Joined: 2004-02-18
Posts: 2258
Posted: Fri, 2006-02-10 05:33

See if you can narrow it down to if $gallery is null or $gallery->album is null