Merge "Add oldRev parameter to DiffRevisionTools hook"
[lhc/web/wiklou.git] / includes / media / Bitmap.php
index 13849f4..7f108c8 100644 (file)
@@ -67,7 +67,7 @@ class BitmapHandler extends ImageHandler {
 
                        if ( $srcWidth * $srcHeight > $wgMaxImageArea
                                && !( $image->getMimeType() == 'image/jpeg'
-                               && self::getScalerType( false, false ) == 'im' )
+                                       && self::getScalerType( false, false ) == 'im' )
                        ) {
                                # Only ImageMagick can efficiently downsize jpg images without loading
                                # the entire file in memory
@@ -187,7 +187,9 @@ class BitmapHandler extends ImageHandler {
                                        wfHostname(), $image->getName() ) );
 
                        return new MediaTransformError( 'thumbnail_error',
-                               $scalerParams['clientWidth'], $scalerParams['clientHeight'] );
+                               $scalerParams['clientWidth'], $scalerParams['clientHeight'],
+                               wfMessage( 'filemissing' )->text()
+                       );
                }
 
                # Try a hook
@@ -227,7 +229,9 @@ class BitmapHandler extends ImageHandler {
                } elseif ( $removed ) {
                        # Thumbnail was zero-byte and had to be removed
                        return new MediaTransformError( 'thumbnail_error',
-                               $scalerParams['clientWidth'], $scalerParams['clientHeight'] );
+                               $scalerParams['clientWidth'], $scalerParams['clientHeight'],
+                               wfMessage( 'unknown-error' )->text()
+                       );
                } elseif ( $mto ) {
                        return $mto;
                } else {
@@ -382,7 +386,7 @@ class BitmapHandler extends ImageHandler {
                if ( $retval !== 0 ) {
                        $this->logErrorForExternalProcess( $retval, $err, $cmd );
 
-                       return $this->getMediaTransformError( $params, $err );
+                       return $this->getMediaTransformError( $params, "$err\nError code: $retval" );
                }
 
                return false; # No error
@@ -753,6 +757,21 @@ class BitmapHandler extends ImageHandler {
                }
        }
 
+       /**
+        * @see $wgEnableAutoRotation
+        * @return bool Whether auto rotation is enabled
+        */
+       public static function autoRotateEnabled() {
+               global $wgEnableAutoRotation;
+
+               if ( $wgEnableAutoRotation === null ) {
+                       // Only enable auto-rotation when the bitmap handler can rotate
+                       $wgEnableAutoRotation = BitmapHandler::canRotate();
+               }
+
+               return $wgEnableAutoRotation;
+       }
+
        /**
         * @param File $file
         * @param array $params Rotate parameters.