Fix SVG metadata handler by changing offset from -1 to 0
authorBrian Wolff <bawolff+wn@gmail.com>
Fri, 11 Jan 2019 00:08:07 +0000 (00:08 +0000)
committerBrian Wolff <bawolff+wn@gmail.com>
Fri, 11 Jan 2019 00:08:07 +0000 (00:08 +0000)
Starting in php 7.1, negative offsets are supported in
file_get_contents. Previously they were not (and in fact, the
php docs said -1 was the default value for the offset if unspecified).

The result of this, is starting in php 7.1, MediaWiki could not determine
the aspect ratio of SVG files that were larger than 256kb.

Follows up e6de99be

Bug: T213501
Change-Id: I565e51cd8131542b9a70da49e9cc36c5594ecda3

includes/media/SVGMetadataExtractor.php

index ca398ff..f8b0c3c 100644 (file)
@@ -74,7 +74,7 @@ class SVGReader {
 
                if ( $size > $wgSVGMetadataCutoff ) {
                        $this->debug( "SVG is $size bytes, which is bigger than $wgSVGMetadataCutoff. Truncating." );
-                       $contents = file_get_contents( $source, false, null, -1, $wgSVGMetadataCutoff );
+                       $contents = file_get_contents( $source, false, null, 0, $wgSVGMetadataCutoff );
                        if ( $contents === false ) {
                                throw new MWException( 'Error reading SVG file.' );
                        }