Fixed BadMethodCallException in FileRepo for bad titles
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 9 Jul 2015 22:59:48 +0000 (15:59 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 9 Jul 2015 22:59:48 +0000 (15:59 -0700)
* Fixes regression from 7508b86ad3

Change-Id: I60c106b5b27db067b1884af95f5fb74a0a682a9a

includes/filerepo/FileRepo.php

index e66fdaf..5bac289 100644 (file)
@@ -431,7 +431,9 @@ class FileRepo {
                # Now try an old version of the file
                if ( $time !== false ) {
                        $img = $this->newFile( $title, $time );
-                       $img->load( $flags );
+                       if ( $img ) {
+                               $img->load( $flags );
+                       }
                        if ( $img && $img->exists() ) {
                                if ( !$img->isDeleted( File::DELETED_FILE ) ) {
                                        return $img; // always OK
@@ -452,10 +454,10 @@ class FileRepo {
                $redir = $this->checkRedirect( $title );
                if ( $redir && $title->getNamespace() == NS_FILE ) {
                        $img = $this->newFile( $redir );
-                       $img->load( $flags );
                        if ( !$img ) {
                                return false;
                        }
+                       $img->load( $flags );
                        if ( $img->exists() ) {
                                $img->redirectedFrom( $title->getDBkey() );