UploadBase: Set mFileSize, if given, even if mTempPath is unknown
authorBartosz Dziewoński <matma.rex@gmail.com>
Sun, 20 Mar 2016 07:24:29 +0000 (08:24 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sun, 20 Mar 2016 07:24:29 +0000 (08:24 +0100)
When uploading a file from stash using the action=upload API, with
async=1, UploadFromStash is initialized without initializing a temp
file. dcb5ec5cbf92b9a07f0776b9c194183a13400193 accidentally made it so
that the given file size is ignored if there's no path. This caused
validity checks to fail (because mFileSize is null) and action=upload
to also fail with cryptic 'emptyfile' warning.

This made it impossible to upload files bigger than 10 MB using
UploadWizard, as it uses the async mode for them.

Bug: T130238
Change-Id: Ie35a66a565a370fe9adc66d5fee0866c4d51470e

includes/upload/UploadBase.php

index fb25249..9d7b294 100644 (file)
@@ -241,12 +241,14 @@ abstract class UploadBase {
         */
        protected function setTempFile( $tempPath, $fileSize = null ) {
                $this->mTempPath = $tempPath;
+               $this->mFileSize = $fileSize ?: null;
                if ( strlen( $this->mTempPath ) && file_exists( $this->mTempPath ) ) {
                        $this->tempFileObj = new TempFSFile( $this->mTempPath );
-                       $this->mFileSize = $fileSize ?: filesize( $this->mTempPath );
+                       if ( !$fileSize ) {
+                               $this->mFileSize = filesize( $this->mTempPath );
+                       }
                } else {
                        $this->tempFileObj = null;
-                       $this->mFileSize = null;
                }
        }