ApiUpload: Raise an error on attempts to async-upload a POSTed file
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 26 Jan 2017 17:26:38 +0000 (12:26 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Thu, 26 Jan 2017 17:26:38 +0000 (12:26 -0500)
"Upload from stash" and "Upload from POST" use the same code path via
ApiUpload::performUpload(). It looks like when a31d0f8edd implemented
"async upload from stash", it was overlooked that someone might attempt
to do an unsupported "async upload from POST".

Bug: T156365
Change-Id: I6d207270af490cfc59d994a22a6406df45a9f6a2

includes/api/ApiUpload.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json

index 6b38302..af3fff6 100644 (file)
@@ -494,6 +494,13 @@ class ApiUpload extends ApiBase {
                                $this->mParams['filekey'], $this->mParams['filename'], !$this->mParams['async']
                        );
                } elseif ( isset( $this->mParams['file'] ) ) {
+                       // Can't async upload directly from a POSTed file, we'd have to
+                       // stash the file and then queue the publish job. The user should
+                       // just submit the two API queries to perform those two steps.
+                       if ( $this->mParams['async'] ) {
+                               $this->dieWithError( 'apierror-cannot-async-upload-file' );
+                       }
+
                        $this->mUpload = new UploadFromFile();
                        $this->mUpload->initialize(
                                $this->mParams['filename'],
index c1fefd6..c7fea8b 100644 (file)
        "apierror-blockedfrommail": "You have been blocked from sending email.",
        "apierror-blocked": "You have been blocked from editing.",
        "apierror-botsnotsupported": "This interface is not supported for bots.",
+       "apierror-cannot-async-upload-file": "The parameters <var>async</var> and <var>file</var> cannot be combined. If you want asynchronous processing of your uploaded file, first upload it to stash (using the <var>stash</var> parameter) and then publish the stashed file asynchronously (using <var>filekey</var> and <var>async</var>).",
        "apierror-cannotreauthenticate": "This action is not available as your identity cannot be verified.",
        "apierror-cannotviewtitle": "You are not allowed to view $1.",
        "apierror-cantblock-email": "You don't have permission to block users from sending email through the wiki.",
index ef2ba8f..e6ee8d4 100644 (file)
        "apierror-blockedfrommail": "{{doc-apierror}}",
        "apierror-blocked": "{{doc-apierror}}",
        "apierror-botsnotsupported": "{{doc-apierror}}",
+       "apierror-cannot-async-upload-file": "{{doc-apierror}}",
        "apierror-cannotreauthenticate": "{{doc-apierror}}",
        "apierror-cannotviewtitle": "{{doc-apierror}}\n\nParameters:\n* $1 - Title.",
        "apierror-cantblock-email": "{{doc-apierror}}",