From 20cba799d7145be5b729828d0902f27b1da31a79 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 15 Mar 2012 20:37:58 +0000 Subject: [PATCH] [FileRepo] Tweaked transformErrorOutput() to allow more useful error output (like backend errors) for problems moving thumbnails into storage. --- includes/filerepo/file/File.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 543f23fc83..5e3763cd41 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -760,16 +760,27 @@ abstract class File { * @param $thumbUrl string Thumbnail URL * @param $params Array * @param $flags integer + * @param $status Status Optional status object to use for errors * @return MediaTransformOutput */ - protected function transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags ) { + protected function transformErrorOutput( + $thumbPath, $thumbUrl, $params, $flags, Status $status = null + ) { global $wgIgnoreImageErrors; if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) { return $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params ); } else { + $badStatus = Status::newFatal( 'thumbnail-dest-create' ); + if ( $status ) { // additional, more detailed errors + $badStatus->merge( $status ); + } + $err = array(); + foreach ( $badStatus->getErrorsArray() as $item ) { + $err[] = wfMsg( $item[0], array_slice( $item, 1 ) ); + } return new MediaTransformError( 'thumbnail_error', - $params['width'], 0, wfMsg( 'thumbnail-dest-create' ) ); + $params['width'], 0, implode( "\n", $err ) ); // MTO does "\n" => "
" } } @@ -875,7 +886,8 @@ abstract class File { if ( $status->isOK() ) { $thumb->setStoragePath( $thumbPath ); } else { - $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags ); + $thumb = $this->transformErrorOutput( + $thumbPath, $thumbUrl, $params, $flags, $status ); } } -- 2.20.1