Deprecate wrapper SVGMetadataExtractor::getMetadata

Use SVGReader->getMetadata() directly. Also rename the test,
because it covers the implementation and not the wrapper.

Change-Id: I61565c6aadc6d1c1e942b9bc4555ef4aeb09e5d8
This commit is contained in:
Umherirrender 2019-03-30 21:14:52 +01:00 committed by James D. Forrester
parent b5630dc0e1
commit 2086b8a407
5 changed files with 21 additions and 6 deletions

View file

@ -414,6 +414,8 @@ because of Phabricator reports.
* The use of $wgProxyList with IP addresses in the array keys, deprecated in
1.30, was removed. Instead, $wgProxyList should be an array with IP addresses
as the values, or a string path to a file containing one IP address per line.
* SVGMetadataExtractor::getMetadata has been deprecated. Instead, you should
use SVGReader->getMetadata() directly.
=== Other changes in 1.34 ===
* …

View file

@ -27,9 +27,17 @@
/**
* @ingroup Media
* @deprecated since 1.34
*/
class SVGMetadataExtractor {
static function getMetadata( $filename ) {
/**
* @param string $filename
* @return array
* @deprecated since 1.34, use SVGReader->getMetadata() directly
*/
public static function getMetadata( $filename ) {
wfDeprecated( __METHOD__, '1.34' );
$svg = new SVGReader( $filename );
return $svg->getMetadata();

View file

@ -438,8 +438,10 @@ class SvgHandler extends ImageHandler {
*/
public function getMetadata( $file, $filename ) {
$metadata = [ 'version' => self::SVG_METADATA_VERSION ];
try {
$metadata += SVGMetadataExtractor::getMetadata( $filename );
$svgReader = new SVGReader( $filename );
$metadata += $svgReader->getMetadata();
} catch ( Exception $e ) { // @todo SVG specific exceptions
// File not found, broken, etc.
$metadata['error'] = [

View file

@ -437,7 +437,8 @@ class ResourceLoaderImage {
file_put_contents( $tempFilenameSvg, $svg );
$metadata = SVGMetadataExtractor::getMetadata( $tempFilenameSvg );
$svgReader = new SVGReader( $tempFilenameSvg );
$metadata = $svgReader->getMetadata();
if ( !isset( $metadata['width'] ) || !isset( $metadata['height'] ) ) {
unlink( $tempFilenameSvg );
return false;

View file

@ -2,9 +2,9 @@
/**
* @group Media
* @covers SVGMetadataExtractor
* @covers SVGReader
*/
class SVGMetadataExtractorTest extends \MediaWikiIntegrationTestCase {
class SVGReaderTest extends \MediaWikiIntegrationTestCase {
/**
* @dataProvider provideSvgFiles
@ -34,7 +34,9 @@ class SVGMetadataExtractorTest extends \MediaWikiIntegrationTestCase {
function assertMetadata( $infile, $expected ) {
try {
$data = SVGMetadataExtractor::getMetadata( $infile );
$svgReader = new SVGReader( $infile );
$data = $svgReader->getMetadata();
$this->assertEquals( $expected, $data, 'SVG metadata extraction test' );
} catch ( MWException $e ) {
if ( $expected === false ) {