X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderImage.php;h=c6e345f52b4b1e969d8335f219b668eca3bb4510;hb=d84967d9cccc33c84587f5b9f6dab86b7043a4f6;hp=6788c6f577e9127acb8643490c5b88659fcafca1;hpb=eca35903a2390bf7eb503fa0ede6a76ce556dc55;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index 6788c6f577..c6e345f52b 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -200,18 +200,22 @@ class ResourceLoaderImage { $format = $context->getFormat(); } + $path = $this->getPath( $context ); if ( $this->getExtension() !== 'svg' ) { - return file_get_contents( $this->getPath( $context ) ); + return file_get_contents( $path ); } if ( $variant && isset( $this->variants[$variant] ) ) { $data = $this->variantize( $this->variants[$variant], $context ); } else { - $data = file_get_contents( $this->getPath( $context ) ); + $data = file_get_contents( $path ); } if ( $format === 'rasterized' ) { $data = $this->rasterize( $data ); + if ( !$data ) { + wfDebugLog( 'ResourceLoaderImage', __METHOD__ . " failed to rasterize for $path" ); + } } return $data; @@ -307,7 +311,8 @@ class ResourceLoaderImage { $svg = $this->massageSvgPathdata( $svg ); - if ( $wgSVGConverter === 'rsvg' ) { + // Sometimes this might be 'rsvg-secure'. Long as it's rsvg. + if ( strpos( $wgSVGConverter, 'rsvg' ) === 0 ) { $command = 'rsvg-convert'; if ( $wgSVGConverterPath ) { $command = wfEscapeShellArg( "$wgSVGConverterPath/" ) . $command; @@ -339,16 +344,19 @@ class ResourceLoaderImage { $metadata = SVGMetadataExtractor::getMetadata( $tempFilenameSvg ); if ( !isset( $metadata['width'] ) || !isset( $metadata['height'] ) ) { + unlink( $tempFilenameSvg ); return false; } $handler = new SvgHandler; - $handler->rasterize( $tempFilenameSvg, $tempFilenamePng, $metadata['width'], $metadata['height'] ); - - $png = file_get_contents( $tempFilenamePng ); - + $res = $handler->rasterize( $tempFilenameSvg, $tempFilenamePng, $metadata['width'], $metadata['height'] ); unlink( $tempFilenameSvg ); - unlink( $tempFilenamePng ); + + $png = null; + if ( $res === true ) { + $png = file_get_contents( $tempFilenamePng ); + unlink( $tempFilenamePng ); + } return $png ?: false; }