Don't get local file copies for svg/djvu files unless needed.
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 17 Aug 2012 03:23:37 +0000 (20:23 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 17 Aug 2012 03:28:28 +0000 (20:28 -0700)
Change-Id: I80e9cc98ba78effba120d84c5f2edca0b547b61a

includes/media/DjVu.php
includes/media/SVG.php

index ed38bd1..7ee93a1 100644 (file)
@@ -146,7 +146,6 @@ class DjVuHandler extends ImageHandler {
                }
                $width = $params['width'];
                $height = $params['height'];
-               $srcPath = $image->getLocalRefPath();
                $page = $params['page'];
                if ( $page > $this->pageCount( $image ) ) {
                        return new MediaTransformError( 'thumbnail_error', $width, $height, wfMsg( 'djvu_page_error' ) );
@@ -160,6 +159,7 @@ class DjVuHandler extends ImageHandler {
                        return new MediaTransformError( 'thumbnail_error', $width, $height, wfMsg( 'thumbnail_dest_directory' ) );
                }
 
+               $srcPath = $image->getLocalRefPath();
                # Use a subshell (brackets) to aggregate stderr from both pipeline commands
                # before redirecting it to the overall stdout. This works in both Linux and Windows XP.
                $cmd = '(' . wfEscapeShellArg( $wgDjvuRenderer ) . " -format=ppm -page={$page}" .
index 9c8fc5e..9846c71 100644 (file)
@@ -108,7 +108,6 @@ class SvgHandler extends ImageHandler {
                $clientHeight = $params['height'];
                $physicalWidth = $params['physicalWidth'];
                $physicalHeight = $params['physicalHeight'];
-               $srcPath = $image->getLocalRefPath();
 
                if ( $flags & self::TRANSFORM_LATER ) {
                        return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
@@ -119,6 +118,7 @@ class SvgHandler extends ImageHandler {
                                wfMsg( 'thumbnail_dest_directory' ) );
                }
 
+               $srcPath = $image->getLocalRefPath();
                $status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight );
                if( $status === true ) {
                        return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );