[FileRepo] Tweaked transformErrorOutput() to allow more useful error output (like...
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 15 Mar 2012 20:37:58 +0000 (20:37 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 15 Mar 2012 20:37:58 +0000 (20:37 +0000)
includes/filerepo/file/File.php

index 543f23f..5e3763c 100644 (file)
@@ -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" => "<br/>"
                }
        }
 
@@ -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 );
                                }
                        }