(bug 48294) API: Fix chunk upload async mode
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 9 May 2013 22:09:20 +0000 (18:09 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 29 May 2013 17:32:09 +0000 (13:32 -0400)
I915c1678 fixed single-chunk chunked uploads for the common case, but
didn't store the data for async uploads under the correct filekey. This
fixes that.

Bug: 48294
Change-Id: Idbeab2fd0d801974b610198dcf02c81798f65a0d

RELEASE-NOTES-1.22
includes/api/ApiUpload.php

index a26c7d8..0708e6b 100644 (file)
@@ -115,6 +115,7 @@ production.
 * (bug 30213) JavaScript for search suggestions is now disabled when the API
   is disabled, and AJAX patrolling and watching are now disabled when use of
   the write API is not allowed.
+* (bug 48294) API: Fix chunk upload async mode.
 
 === API changes in 1.22 ===
 * (bug 46626) xmldoublequote parameter was removed. Because of a bug, the
index e04c762..8f71fbe 100644 (file)
@@ -216,27 +216,27 @@ class ApiUpload extends ApiBase {
                // Check we added the last chunk:
                if ( $this->mParams['offset'] + $chunkSize == $this->mParams['filesize'] ) {
                        if ( $this->mParams['async'] ) {
-                               $progress = UploadBase::getSessionStatus( $this->mParams['filekey'] );
+                               $progress = UploadBase::getSessionStatus( $filekey );
                                if ( $progress && $progress['result'] === 'Poll' ) {
                                        $this->dieUsage( "Chunk assembly already in progress.", 'stashfailed' );
                                }
                                UploadBase::setSessionStatus(
-                                       $this->mParams['filekey'],
+                                       $filekey,
                                        array( 'result' => 'Poll',
                                                'stage' => 'queued', 'status' => Status::newGood() )
                                );
                                $ok = JobQueueGroup::singleton()->push( new AssembleUploadChunksJob(
-                                       Title::makeTitle( NS_FILE, $this->mParams['filekey'] ),
+                                       Title::makeTitle( NS_FILE, $filekey ),
                                        array(
                                                'filename' => $this->mParams['filename'],
-                                               'filekey' => $this->mParams['filekey'],
+                                               'filekey' => $filekey,
                                                'session' => $this->getContext()->exportSession()
                                        )
                                ) );
                                if ( $ok ) {
                                        $result['result'] = 'Poll';
                                } else {
-                                       UploadBase::setSessionStatus( $this->mParams['filekey'], false );
+                                       UploadBase::setSessionStatus( $filekey, false );
                                        $this->dieUsage(
                                                "Failed to start AssembleUploadChunks.php", 'stashfailed' );
                                }