From 034402b7a0fc208854179e514282fa4ed0330aed Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 10 Jul 2015 16:31:33 +0200 Subject: [PATCH] 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 --- includes/filerepo/FileRepo.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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; + } } } } -- 2.20.1