Made sure MediaTransformOutput::getLocalCopyPath handles storage paths.
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 27 Mar 2013 19:48:08 +0000 (12:48 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 27 Mar 2013 19:48:14 +0000 (12:48 -0700)
* Storage paths are passed in for several cases in File::transform().

Change-Id: I61a4058b80a37f36b78e2dfe62ffdf6f73e6f41e

includes/filerepo/file/File.php
includes/media/MediaTransformOutput.php

index 5eff954..d72755a 100644 (file)
@@ -910,8 +910,7 @@ abstract class File {
                                                // XXX: Pass in the storage path even though we are not rendering anything
                                                // and the path is supposed to be an FS path. This is due to getScalerType()
                                                // getting called on the path and clobbering $thumb->getUrl() if it's false.
-                                               $thumb = $handler->getTransform(
-                                                       $this, $thumbPath, $thumbUrl, $params );
+                                               $thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
                                                $thumb->setStoragePath( $thumbPath );
                                                break;
                                        }
index 1f95bc3..1c2dfdd 100644 (file)
@@ -151,7 +151,12 @@ abstract class MediaTransformOutput {
                if ( $this->isError() ) {
                        return false;
                } elseif ( $this->path === null ) {
-                       return $this->file->getLocalRefPath();
+                       return $this->file->getLocalRefPath(); // assume thumb was not scaled
+               } elseif ( FileBackend::isStoragePath( $this->path ) ) {
+                       $be = $this->file->getRepo()->getBackend();
+                       // The temp file will be process cached by FileBackend
+                       $fsFile = $be->getLocalReference( array( 'src' => $this->path ) );
+                       return $fsFile ? $fsFile->getPath() : false;
                } else {
                        return $this->path; // may return false
                }