Fixed fatal error when getLocalCopy() fails
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 20 Nov 2013 21:37:16 +0000 (13:37 -0800)
committerTim Starling <tstarling@wikimedia.org>
Mon, 2 Dec 2013 03:19:17 +0000 (03:19 +0000)
bug: 40166
Change-Id: Ibfcddc1a9c05fad4ac0b51a5a046d1ffaeb49db8

includes/upload/UploadBase.php

index 183e7f3..17d8895 100644 (file)
@@ -250,7 +250,7 @@ abstract class UploadBase {
 
        /**
         * @param string $srcPath the source path
-        * @return string the real path if it was a virtual URL
+        * @return string|bool the real path if it was a virtual URL Returns false on failure
         */
        function getRealPath( $srcPath ) {
                wfProfileIn( __METHOD__ );
@@ -259,12 +259,15 @@ abstract class UploadBase {
                        // @todo just make uploads work with storage paths
                        // UploadFromStash loads files via virtual URLs
                        $tmpFile = $repo->getLocalCopy( $srcPath );
-                       $tmpFile->bind( $this ); // keep alive with $this
-                       wfProfileOut( __METHOD__ );
-                       return $tmpFile->getPath();
+                       if ( $tmpFile ) {
+                               $tmpFile->bind( $this ); // keep alive with $this
+                       }
+                       $path = $tmpFile ? $tmpFile->getPath() : false;
+               } else {
+                       $path = $srcPath;
                }
                wfProfileOut( __METHOD__ );
-               return $srcPath;
+               return $path;
        }
 
        /**