Fixed a problem when displaying the New Image Gallery.
authorNicholas Pisarro, Jr <npassoc@users.mediawiki.org>
Tue, 7 Dec 2004 13:10:56 +0000 (13:10 +0000)
committerNicholas Pisarro, Jr <npassoc@users.mediawiki.org>
Tue, 7 Dec 2004 13:10:56 +0000 (13:10 +0000)
Check to make sure a valid name object is returned by "Title".
This may occur if a record is not valid in the DB.

includes/SpecialNewimages.php

index 9d0d51b..4ea315b 100644 (file)
@@ -84,11 +84,15 @@ function wfSpecialNewimages() {
                $ut = $s->img_user_text;
 
                $nt = Title::newFromText( $name, NS_IMAGE );
-               $img = Image::newFromTitle( $nt );
-               $ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
-
-               $gallery->add( $img, $ul.'<br /><i>'.$wgLang->timeanddate( $s->img_timestamp, true ).'</i><br />' );
-               $i++;
+               
+               # We may not get an object back from Title if there is name problem.
+               if ( is_object($nt) ) {
+                       $img = Image::newFromTitle( $nt );
+                       $ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
+       
+                       $gallery->add( $img, $ul.'<br /><i>'.$wgLang->timeanddate( $s->img_timestamp, true ).'</i><br />' );
+                       $i++;
+               }
        }
        $wgOut->addHTML( $gallery->toHTML() );
        $dbr->freeResult( $res );