Merge "(bug 43661) Added test for special link trail case"
[lhc/web/wiklou.git] / includes / upload / UploadFromStash.php
index d5cce14..71ee96b 100644 (file)
@@ -62,8 +62,6 @@ class UploadFromStash extends UploadBase {
 
                        $this->stash = new UploadStash( $this->repo, $this->user );
                }
-
-               return true;
        }
 
        /**
@@ -91,7 +89,7 @@ class UploadFromStash extends UploadBase {
         * @param $key string
         * @param $name string
         */
-       public function initialize( $key, $name = 'upload_file' ) {
+       public function initialize( $key, $name = 'upload_file', $initTempFile = true ) {
                /**
                 * Confirming a temporarily stashed upload.
                 * We don't want path names to be forged, so we keep
@@ -100,7 +98,7 @@ class UploadFromStash extends UploadBase {
                 */
                $metadata = $this->stash->getMetadata( $key );
                $this->initializePathInfo( $name,
-                       $this->getRealPath ( $metadata['us_path'] ),
+                       $initTempFile ? $this->getRealPath( $metadata['us_path'] ) : false,
                        $metadata['us_size'],
                        false
                );
@@ -131,6 +129,14 @@ class UploadFromStash extends UploadBase {
                return $this->mSourceType;
        }
 
+       /**
+        * Get the base 36 SHA1 of the file
+        * @return string
+        */
+       protected function getTempFileSha1Base36() {
+               return $this->mFileProps['sha1'];
+       }
+
        /**
         * File has been previously verified so no need to do so again.
         *
@@ -143,12 +149,13 @@ class UploadFromStash extends UploadBase {
        /**
         * Stash the file.
         *
+        * @param $user User
         * @return UploadStashFile
         */
-       public function stashFile() {
+       public function stashFile( User $user = null ) {
                // replace mLocalFile with an instance of UploadStashFile, which adds some methods
                // that are useful for stashed files.
-               $this->mLocalFile = parent::stashFile();
+               $this->mLocalFile = parent::stashFile( $user );
                return $this->mLocalFile;
        }