Change method used for file_bits_per_channel in /test

Using MWProps will not raise an 'undefined index' notice and, if the
bitsdepth cannot be established, will return 0. This is way better than
returning the empty string or null, which cannot be treated as integers.

Bug: T218874
Change-Id: I2b585f3a2f257783c15f0fcdd2851f1e1ce4256b
This commit is contained in:
Daimona Eaytoy 2019-03-21 14:05:54 +01:00
parent edc35ede96
commit 45e84bad0e

View file

@ -2891,12 +2891,15 @@ class AbuseFilter {
$vars->setVar( 'file_mime', $file->getMimeType() );
$vars->setVar(
'file_mediatype',
MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer()
MediaWikiServices::getInstance()->getMimeAnalyzer()
->getMediaType( null, $file->getMimeType() )
);
$vars->setVar( 'file_width', $file->getWidth() );
$vars->setVar( 'file_height', $file->getHeight() );
$vars->setVar( 'file_bits_per_channel', $file->getImageSize( $file->getLocalRefPath() )['bits'] );
$mwProps = new MWFileProps( MediaWikiServices::getInstance()->getMimeAnalyzer() );
$bits = $mwProps->getPropsFromPath( $file->getLocalRefPath(), true )['bits'];
$vars->setVar( 'file_bits_per_channel', $bits );
return $vars;
}