abstract class TransformationalImageHandler extends ImageHandler {
/**
* @param File $image
- * @param array $params Transform parameters. Entries with the keys 'width'
+ * @param array &$params Transform parameters. Entries with the keys 'width'
* and 'height' are the respective screen width and height, while the keys
* 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions.
* @return bool
&& $scalerParams['physicalHeight'] == $scalerParams['srcHeight']
&& !isset( $scalerParams['quality'] )
) {
-
# normaliseParams (or the user) wants us to return the unscaled image
wfDebug( __METHOD__ . ": returning unscaled image\n" );
return new MediaTransformError( 'thumbnail_error',
$scalerParams['clientWidth'], $scalerParams['clientHeight'],
- wfMessage( 'filemissing' )->text()
+ wfMessage( 'filemissing' )
);
}
# Try a hook. Called "Bitmap" for historical reasons.
- /** @var $mto MediaTransformOutput */
+ /** @var MediaTransformOutput $mto */
$mto = null;
Hooks::run( 'BitmapHandlerTransform', [ $this, $image, &$scalerParams, &$mto ] );
if ( !is_null( $mto ) ) {
# Thumbnail was zero-byte and had to be removed
return new MediaTransformError( 'thumbnail_error',
$scalerParams['clientWidth'], $scalerParams['clientHeight'],
- wfMessage( 'unknown-error' )->text()
+ wfMessage( 'unknown-error' )
);
} elseif ( $mto ) {
return $mto;
*/
protected function getMagickVersion() {
$cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
+ $method = __METHOD__;
return $cache->getWithSetCallback(
'imagemagick-version',
$cache::TTL_HOUR,
- function () {
+ function () use ( $method ) {
global $wgImageMagickConvertCommand;
$cmd = wfEscapeShellArg( $wgImageMagickConvertCommand ) . ' -version';
- wfDebug( __METHOD__ . ": Running convert -version\n" );
+ wfDebug( $method . ": Running convert -version\n" );
$retval = '';
- $return = wfShellExec( $cmd, $retval );
+ $return = wfShellExecWithStderr( $cmd, $retval );
$x = preg_match(
'/Version: ImageMagick ([0-9]*\.[0-9]*\.[0-9]*)/', $return, $matches
);
if ( $x != 1 ) {
- wfDebug( __METHOD__ . ": ImageMagick version check failed\n" );
+ wfDebug( $method . ": ImageMagick version check failed\n" );
return false;
}
* @param array $params Rotate parameters.
* 'rotation' clockwise rotation in degrees, allowed are multiples of 90
* @since 1.24 Is non-static. From 1.21 it was static
- * @return bool
+ * @return bool|MediaTransformError
*/
public function rotate( $file, $params ) {
return new MediaTransformError( 'thumbnail_error', 0, 0,
- get_class( $this ) . ' rotation not implemented' );
+ static::class . ' rotation not implemented' );
}
/**
* Runs the 'BitmapHandlerCheckImageArea' hook.
*
* @param File $file
- * @param array $params
+ * @param array &$params
* @return bool
* @since 1.25
*/