From 01cdee5ffd21216859ef501e0887e027b21f682c Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Thu, 19 Jan 2017 11:49:55 -0800 Subject: [PATCH] Special:Upload should not crash on failing previews A thumbnail transformation can fail, but the preview on Special:Upload was not accounting for failed previews and caused a stacktrace on accessing getUrl on 'false'. Bug: T155771 Change-Id: Iff3a2ae3512a34a2d2efb981b7ea85da71aaf637 --- includes/specials/SpecialUpload.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 8b8e514ac0..c5a1f27073 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -1090,12 +1090,14 @@ class UploadForm extends HTMLForm { global $wgContLang; $mto = $file->transform( [ 'width' => 120 ] ); - $this->addHeaderText( - '
' . - Html::element( 'img', [ - 'src' => $mto->getUrl(), - 'class' => 'thumbimage', - ] ) . '
', 'description' ); + if ( $mto ) { + $this->addHeaderText( + '
' . + Html::element( 'img', [ + 'src' => $mto->getUrl(), + 'class' => 'thumbimage', + ] ) . '
', 'description' ); + } } } -- 2.20.1