From: Florian Date: Fri, 10 Jul 2015 14:31:33 +0000 (+0200) Subject: Don't try to call load() on non-object X-Git-Tag: 1.31.0-rc.0~10818 X-Git-Url: http://git.cyclocoop.org/wiki/Target_page?a=commitdiff_plain;h=034402b7a0fc208854179e514282fa4ed0330aed;p=lhc%2Fweb%2Fwiklou.git Don't try to call load() on non-object FileRepo::newFile() can return null or false, in addition to a File object. Calling load() on the returned value in FileRepo::findFile() can result in an exception. Prevent this with an additional check after FileRepo::newFile() was called. Follow up: I1aa4b096c0cad5f5ca34321cc897019005c53a76 Follow up: I60c106b5b27db067b1884af95f5fb74a0a682a9a Bug: T105497 Change-Id: Iabdae8fd960d19a467dc08a193228978575017ce --- diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 5bac289da9..82bbd76995 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -433,16 +433,16 @@ class FileRepo { $img = $this->newFile( $title, $time ); if ( $img ) { $img->load( $flags ); - } - if ( $img && $img->exists() ) { - if ( !$img->isDeleted( File::DELETED_FILE ) ) { - return $img; // always OK - } elseif ( !empty( $options['private'] ) && - $img->userCan( File::DELETED_FILE, - $options['private'] instanceof User ? $options['private'] : null - ) - ) { - return $img; + if ( $img->exists() ) { + if ( !$img->isDeleted( File::DELETED_FILE ) ) { + return $img; // always OK + } elseif ( !empty( $options['private'] ) && + $img->userCan( File::DELETED_FILE, + $options['private'] instanceof User ? $options['private'] : null + ) + ) { + return $img; + } } } }