Remove putrid remains of $wgAllowAsyncCopyUploads
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 21 Jan 2016 22:45:10 +0000 (23:45 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 22 Jan 2016 00:18:25 +0000 (00:18 +0000)
None of this works and it's been long begging for a mercy kill.
All it does is waste contributor time on updating deprecations
in the dead code. I imagine we wouldn't reuse much of this
code if we're ever going to reimplement it.

Bug: T119336
Change-Id: Ibd26a4bea621857aac77823017e9be9b7dc52cca

13 files changed:
RELEASE-NOTES-1.27
autoload.php
includes/DefaultSettings.php
includes/api/ApiUpload.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json
includes/jobqueue/jobs/UploadFromUrlJob.php [deleted file]
includes/upload/UploadFromUrl.php
languages/i18n/en.json
languages/i18n/qqq.json
maintenance/dictionary/mediawiki.dic
tests/phpunit/includes/api/ApiUploadTest.php
tests/phpunit/includes/upload/UploadFromUrlTest.php

index def80ea..7d7825d 100644 (file)
@@ -86,6 +86,8 @@ production.
   auto-creation when 'createaccount' is not granted to all users.
 * Deprecated AuthPluginAutoCreate hook in favor of LocalUserCreated.
 * Most cookie-handling methods in User are deprecated.
+* $wgAllowAsyncCopyUploads and $CopyUploadAsyncTimeout were removed. This was an
+  experimental feature that has never worked.
 
 === New features in 1.27 ===
 * $wgDataCenterId and $wgDataCenterRoles where added, which will serve as
@@ -183,6 +185,7 @@ production.
 * action=login transparently allows login using bot passwords. Clients should
   merely need to change the username and password used after setting up a bot
   password.
+* action=upload no longer understands statuskey, asyncdownload or leavemessage.
 
 === Action API internal changes in 1.27 ===
 * ApiQueryORM removed.
index 24a4d72..26b6598 100644 (file)
@@ -1338,7 +1338,6 @@ $wgAutoloadLocalClasses = array(
        'UploadFromFile' => __DIR__ . '/includes/upload/UploadFromFile.php',
        'UploadFromStash' => __DIR__ . '/includes/upload/UploadFromStash.php',
        'UploadFromUrl' => __DIR__ . '/includes/upload/UploadFromUrl.php',
-       'UploadFromUrlJob' => __DIR__ . '/includes/jobqueue/jobs/UploadFromUrlJob.php',
        'UploadLogFormatter' => __DIR__ . '/includes/logging/UploadLogFormatter.php',
        'UploadSourceAdapter' => __DIR__ . '/includes/import/UploadSourceAdapter.php',
        'UploadSourceField' => __DIR__ . '/includes/specials/SpecialUpload.php',
index 9e945ea..a22a29d 100644 (file)
@@ -661,12 +661,6 @@ $wgCacheSharedUploads = true;
  */
 $wgAllowCopyUploads = false;
 
-/**
- * Allow asynchronous copy uploads.
- * This feature is experimental and broken as of r81612.
- */
-$wgAllowAsyncCopyUploads = false;
-
 /**
  * A list of domains copy uploads can come from
  *
@@ -697,17 +691,6 @@ $wgCopyUploadProxy = false;
  */
 $wgCopyUploadTimeout = false;
 
-/**
- * Different timeout for upload by url when run as a background job
- * This could be useful since when fetching large files via job queue,
- * you may want a different timeout, especially because there is no
- * http request being kept alive.
- *
- * false means fallback to $wgCopyUploadTimeout.
- * @since 1.22
- */
-$wgCopyUploadAsyncTimeout = false;
-
 /**
  * Max size for uploads, in bytes. If not set to an array, applies to all
  * uploads. If set to an array, per upload type maximums can be set, using the
@@ -6908,7 +6891,6 @@ $wgJobClasses = array(
        'sendMail' => 'EmaillingJob',
        'enotifNotify' => 'EnotifNotifyJob',
        'fixDoubleRedirect' => 'DoubleRedirectJob',
-       'uploadFromUrl' => 'UploadFromUrlJob',
        'AssembleUploadChunks' => 'AssembleUploadChunksJob',
        'PublishStashedFile' => 'PublishStashedFileJob',
        'ThumbnailRender' => 'ThumbnailRenderJob',
index e76b365..82f66a8 100644 (file)
@@ -382,7 +382,7 @@ class ApiUpload extends ApiBase {
                // chunk or one and only one of the following parameters is needed
                if ( !$this->mParams['chunk'] ) {
                        $this->requireOnlyOneParameter( $this->mParams,
-                               'filekey', 'file', 'url', 'statuskey' );
+                               'filekey', 'file', 'url' );
                }
 
                // Status report for "upload to stash"/"upload from stash"
@@ -402,23 +402,6 @@ class ApiUpload extends ApiBase {
                        return false;
                }
 
-               if ( $this->mParams['statuskey'] ) {
-                       $this->checkAsyncDownloadEnabled();
-
-                       // Status request for an async upload
-                       $sessionData = UploadFromUrlJob::getSessionData( $this->mParams['statuskey'] );
-                       if ( !isset( $sessionData['result'] ) ) {
-                               $this->dieUsage( 'No result in session data', 'missingresult' );
-                       }
-                       if ( $sessionData['result'] == 'Warning' ) {
-                               $sessionData['warnings'] = $this->transformWarnings( $sessionData['warnings'] );
-                               $sessionData['sessionkey'] = $this->mParams['statuskey'];
-                       }
-                       $this->getResult()->addValue( null, $this->getModuleName(), $sessionData );
-
-                       return false;
-               }
-
                // The following modules all require the filename parameter to be set
                if ( is_null( $this->mParams['filename'] ) ) {
                        $this->dieUsageMsg( array( 'missingparam', 'filename' ) );
@@ -481,24 +464,9 @@ class ApiUpload extends ApiBase {
                                $this->dieUsageMsg( 'copyuploadbadurl' );
                        }
 
-                       $async = false;
-                       if ( $this->mParams['asyncdownload'] ) {
-                               $this->checkAsyncDownloadEnabled();
-
-                               if ( $this->mParams['leavemessage'] && !$this->mParams['ignorewarnings'] ) {
-                                       $this->dieUsage( 'Using leavemessage without ignorewarnings is not supported',
-                                               'missing-ignorewarnings' );
-                               }
-
-                               if ( $this->mParams['leavemessage'] ) {
-                                       $async = 'async-leavemessage';
-                               } else {
-                                       $async = 'async';
-                               }
-                       }
                        $this->mUpload = new UploadFromUrl;
                        $this->mUpload->initialize( $this->mParams['filename'],
-                               $this->mParams['url'], $async );
+                               $this->mParams['url'] );
                }
 
                return true;
@@ -766,16 +734,6 @@ class ApiUpload extends ApiBase {
 
                        if ( !$status->isGood() ) {
                                $error = $status->getErrorsArray();
-
-                               if ( count( $error ) == 1 && $error[0][0] == 'async' ) {
-                                       // The upload can not be performed right now, because the user
-                                       // requested so
-                                       return array(
-                                               'result' => 'Queued',
-                                               'statuskey' => $error[0][1],
-                                       );
-                               }
-
                                ApiResult::setIndexedTagName( $error, 'error' );
                                $this->dieUsage( 'An internal error occurred', 'internal-error', 0, $error );
                        }
@@ -790,15 +748,6 @@ class ApiUpload extends ApiBase {
                return $result;
        }
 
-       /**
-        * Checks if asynchronous copy uploads are enabled and throws an error if they are not.
-        */
-       protected function checkAsyncDownloadEnabled() {
-               if ( !$this->getConfig()->get( 'AllowAsyncCopyUploads' ) ) {
-                       $this->dieUsage( 'Asynchronous copy uploads disabled', 'asynccopyuploaddisabled' );
-               }
-       }
-
        public function mustBePosted() {
                return true;
        }
@@ -855,9 +804,6 @@ class ApiUpload extends ApiBase {
                        ),
 
                        'async' => false,
-                       'asyncdownload' => false,
-                       'leavemessage' => false,
-                       'statuskey' => null,
                        'checkstatus' => false,
                );
 
index 2fb9a50..177f746 100644 (file)
        "apihelp-upload-param-offset": "Offset of chunk in bytes.",
        "apihelp-upload-param-chunk": "Chunk contents.",
        "apihelp-upload-param-async": "Make potentially large file operations asynchronous when possible.",
-       "apihelp-upload-param-asyncdownload": "Make fetching a URL asynchronous.",
-       "apihelp-upload-param-leavemessage": "If asyncdownload is used, leave a message on the user talk page if finished.",
-       "apihelp-upload-param-statuskey": "Fetch the upload status for this file key (upload by URL).",
        "apihelp-upload-param-checkstatus": "Only fetch the upload status for the given file key.",
        "apihelp-upload-example-url": "Upload from a URL.",
        "apihelp-upload-example-filekey": "Complete an upload that failed due to warnings.",
index 7863f69..6705658 100644 (file)
        "apihelp-upload-param-offset": "{{doc-apihelp-param|upload|offset}}",
        "apihelp-upload-param-chunk": "{{doc-apihelp-param|upload|chunk}}",
        "apihelp-upload-param-async": "{{doc-apihelp-param|upload|async}}",
-       "apihelp-upload-param-asyncdownload": "{{doc-apihelp-param|upload|asyncdownload}}",
-       "apihelp-upload-param-leavemessage": "{{doc-apihelp-param|upload|leavemessage}}",
-       "apihelp-upload-param-statuskey": "{{doc-apihelp-param|upload|statuskey}}",
        "apihelp-upload-param-checkstatus": "{{doc-apihelp-param|upload|checkstatus}}",
        "apihelp-upload-example-url": "{{doc-apihelp-example|upload}}",
        "apihelp-upload-example-filekey": "{{doc-apihelp-example|upload}}",
diff --git a/includes/jobqueue/jobs/UploadFromUrlJob.php b/includes/jobqueue/jobs/UploadFromUrlJob.php
deleted file mode 100644 (file)
index 0491e64..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-<?php
-/**
- * Job for asynchronous upload-by-url.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup JobQueue
- */
-
-/**
- * Job for asynchronous upload-by-url.
- *
- * This job is in fact an interface to UploadFromUrl, which is designed such
- * that it does not require any globals. If it does, fix it elsewhere, do not
- * add globals in here.
- *
- * @ingroup JobQueue
- */
-class UploadFromUrlJob extends Job {
-       const SESSION_KEYNAME = 'wsUploadFromUrlJobData';
-
-       /** @var UploadFromUrl */
-       public $upload;
-
-       /** @var User */
-       protected $user;
-
-       public function __construct( Title $title, array $params ) {
-               parent::__construct( 'uploadFromUrl', $title, $params );
-       }
-
-       public function run() {
-               global $wgCopyUploadAsyncTimeout;
-               # Initialize this object and the upload object
-               $this->upload = new UploadFromUrl();
-               $this->upload->initialize(
-                       $this->title->getText(),
-                       $this->params['url'],
-                       false
-               );
-               $this->user = User::newFromName( $this->params['userName'] );
-
-               # Fetch the file
-               $opts = array();
-               if ( $wgCopyUploadAsyncTimeout ) {
-                       $opts['timeout'] = $wgCopyUploadAsyncTimeout;
-               }
-               $status = $this->upload->fetchFile( $opts );
-               if ( !$status->isOk() ) {
-                       $this->leaveMessage( $status );
-
-                       return true;
-               }
-
-               # Verify upload
-               $result = $this->upload->verifyUpload();
-               if ( $result['status'] != UploadBase::OK ) {
-                       $status = $this->upload->convertVerifyErrorToStatus( $result );
-                       $this->leaveMessage( $status );
-
-                       return true;
-               }
-
-               # Check warnings
-               if ( !$this->params['ignoreWarnings'] ) {
-                       $warnings = $this->upload->checkWarnings();
-                       if ( $warnings ) {
-
-                               # Stash the upload
-                               $key = $this->upload->stashFile( $this->user );
-
-                               // @todo FIXME: This has been broken for a while.
-                               // User::leaveUserMessage() does not exist.
-                               if ( $this->params['leaveMessage'] ) {
-                                       $this->user->leaveUserMessage(
-                                               wfMessage( 'upload-warning-subj' )->text(),
-                                               wfMessage( 'upload-warning-msg',
-                                                       $key,
-                                                       $this->params['url'] )->text()
-                                       );
-                               } else {
-                                       $session = MediaWiki\Session\SessionManager::singleton()
-                                               ->getSessionById( $this->params['sessionId'] );
-                                       $this->storeResultInSession( $session, 'Warning',
-                                               'warnings', $warnings );
-                               }
-
-                               return true;
-                       }
-               }
-
-               # Perform the upload
-               $status = $this->upload->performUpload(
-                       $this->params['comment'],
-                       $this->params['pageText'],
-                       $this->params['watch'],
-                       $this->user
-               );
-               $this->leaveMessage( $status );
-
-               return true;
-       }
-
-       /**
-        * Leave a message on the user talk page or in the session according to
-        * $params['leaveMessage'].
-        *
-        * @param Status $status
-        */
-       protected function leaveMessage( $status ) {
-               if ( $this->params['leaveMessage'] ) {
-                       if ( $status->isGood() ) {
-                               // @todo FIXME: user->leaveUserMessage does not exist.
-                               $this->user->leaveUserMessage( wfMessage( 'upload-success-subj' )->text(),
-                                       wfMessage( 'upload-success-msg',
-                                               $this->upload->getTitle()->getText(),
-                                               $this->params['url']
-                                       )->text() );
-                       } else {
-                               // @todo FIXME: user->leaveUserMessage does not exist.
-                               $this->user->leaveUserMessage( wfMessage( 'upload-failure-subj' )->text(),
-                                       wfMessage( 'upload-failure-msg',
-                                               $status->getWikiText(),
-                                               $this->params['url']
-                                       )->text() );
-                       }
-               } else {
-                       $session = MediaWiki\Session\SessionManager::singleton()
-                               ->getSessionById( $this->params['sessionId'] );
-                       if ( $status->isOk() ) {
-                               $this->storeResultInSession( $session, 'Success',
-                                       'filename', $this->upload->getLocalFile()->getName() );
-                       } else {
-                               $this->storeResultInSession( $session, 'Failure',
-                                       'errors', $status->getErrorsArray() );
-                       }
-               }
-       }
-
-       /**
-        * Store a result in the session data. Note that the caller is responsible
-        * for appropriate session_start and session_write_close calls.
-        *
-        * @param MediaWiki\\Session\\Session|null $session Session to store result into
-        * @param string $result The result (Success|Warning|Failure)
-        * @param string $dataKey The key of the extra data
-        * @param mixed $dataValue The extra data itself
-        */
-       protected function storeResultInSession(
-               MediaWiki\Session\Session $session = null, $result, $dataKey, $dataValue
-       ) {
-               if ( $session ) {
-                       $data = self::getSessionData( $session, $this->params['sessionKey'] );
-                       $data['result'] = $result;
-                       $data[$dataKey] = $dataValue;
-                       self::setSessionData( $session, $this->params['sessionKey'], $data );
-               } else {
-                       wfDebug( __METHOD__ . ': Cannot store result in session, session does not exist' );
-               }
-       }
-
-       /**
-        * Initialize the session data. Sets the initial result to queued.
-        */
-       public function initializeSessionData() {
-               $session = MediaWiki\Session\SessionManager::getGlobalSession();
-               $data = self::getSessionData( $session, $this->params['sessionKey'] );
-               $data['result'] = 'Queued';
-               self::setSessionData( $session, $this->params['sessionKey'], $data );
-       }
-
-       /**
-        * @param MediaWiki\\Session\\Session $session
-        * @param string $key
-        * @return mixed
-        */
-       public static function getSessionData( MediaWiki\Session\Session $session, $key ) {
-               $data = $session->get( self::SESSION_KEYNAME );
-               if ( !is_array( $data ) || !isset( $data[$key] ) ) {
-                       self::setSessionData( $session, $key, array() );
-                       return array();
-               }
-               return $data[$key];
-       }
-
-       /**
-        * @param MediaWiki\\Session\\Session $session
-        * @param string $key
-        * @param mixed $value
-        */
-       public static function setSessionData( MediaWiki\Session\Session $session, $key, $value ) {
-               $data = $session->get( self::SESSION_KEYNAME, array() );
-               if ( !is_array( $data ) ) {
-                       $data = array();
-               }
-               $data[$key] = $value;
-               $session->set( self::SESSION_KEYNAME, $data );
-       }
-}
index 23a4962..f6d538b 100644 (file)
@@ -29,8 +29,7 @@
  * @author Michael Dale
  */
 class UploadFromUrl extends UploadBase {
-       protected $mAsync, $mUrl;
-       protected $mIgnoreWarnings = true;
+       protected $mUrl;
 
        protected $mTempPath, $mTmpHandle;
 
@@ -130,21 +129,12 @@ class UploadFromUrl extends UploadBase {
         *
         * @param string $name
         * @param string $url
-        * @param bool|string $async Whether the download should be performed
-        * asynchronous. False for synchronous, async or async-leavemessage for
-        * asynchronous download.
         * @throws MWException
         */
-       public function initialize( $name, $url, $async = false ) {
-               global $wgAllowAsyncCopyUploads;
-
+       public function initialize( $name, $url ) {
                $this->mUrl = $url;
-               $this->mAsync = $wgAllowAsyncCopyUploads ? $async : false;
-               if ( $async ) {
-                       throw new MWException( 'Asynchronous copy uploads are no longer possible as of r81612.' );
-               }
 
-               $tempPath = $this->mAsync ? null : $this->makeTemporaryFile();
+               $tempPath = $this->makeTemporaryFile();
                # File size and removeTempFile will be filled in later
                $this->initializePathInfo( $name, $tempPath, 0, false );
        }
@@ -186,9 +176,9 @@ class UploadFromUrl extends UploadBase {
        }
 
        /**
-        * Download the file (if not async)
+        * Download the file
         *
-        * @param array $httpOptions Array of options for MWHttpRequest. Ignored if async.
+        * @param array $httpOptions Array of options for MWHttpRequest.
         *   This could be used to override the timeout on the http request.
         * @return Status
         */
@@ -203,11 +193,7 @@ class UploadFromUrl extends UploadBase {
                if ( !self::isAllowedUrl( $this->mUrl ) ) {
                        return Status::newFatal( 'upload-copy-upload-invalid-url' );
                }
-               if ( !$this->mAsync ) {
-                       return $this->reallyFetchFile( $httpOptions );
-               }
-
-               return Status::newGood();
+               return $this->reallyFetchFile( $httpOptions );
        }
 
        /**
@@ -311,91 +297,4 @@ class UploadFromUrl extends UploadBase {
 
                return $status;
        }
-
-       /**
-        * Wrapper around the parent function in order to defer verifying the
-        * upload until the file really has been fetched.
-        * @return array|mixed
-        */
-       public function verifyUpload() {
-               if ( $this->mAsync ) {
-                       return array( 'status' => UploadBase::OK );
-               }
-
-               return parent::verifyUpload();
-       }
-
-       /**
-        * Wrapper around the parent function in order to defer checking warnings
-        * until the file really has been fetched.
-        * @return array
-        */
-       public function checkWarnings() {
-               if ( $this->mAsync ) {
-                       $this->mIgnoreWarnings = false;
-
-                       return array();
-               }
-
-               return parent::checkWarnings();
-       }
-
-       /**
-        * Wrapper around the parent function in order to defer checking protection
-        * until we are sure that the file can actually be uploaded
-        * @param User $user
-        * @return bool|mixed
-        */
-       public function verifyTitlePermissions( $user ) {
-               if ( $this->mAsync ) {
-                       return true;
-               }
-
-               return parent::verifyTitlePermissions( $user );
-       }
-
-       /**
-        * Wrapper around the parent function in order to defer uploading to the
-        * job queue for asynchronous uploads
-        * @param string $comment
-        * @param string $pageText
-        * @param bool $watch
-        * @param User $user
-        * @return Status
-        */
-       public function performUpload( $comment, $pageText, $watch, $user ) {
-               if ( $this->mAsync ) {
-                       $sessionKey = $this->insertJob( $comment, $pageText, $watch, $user );
-
-                       return Status::newFatal( 'async', $sessionKey );
-               }
-
-               return parent::performUpload( $comment, $pageText, $watch, $user );
-       }
-
-       /**
-        * @param string $comment
-        * @param string $pageText
-        * @param bool $watch
-        * @param User $user
-        * @return string
-        */
-       protected function insertJob( $comment, $pageText, $watch, $user ) {
-               $sessionKey = $this->stashSession();
-               $job = new UploadFromUrlJob( $this->getTitle(), array(
-                       'url' => $this->mUrl,
-                       'comment' => $comment,
-                       'pageText' => $pageText,
-                       'watch' => $watch,
-                       'userName' => $user->getName(),
-                       'leaveMessage' => $this->mAsync == 'async-leavemessage',
-                       'ignoreWarnings' => $this->mIgnoreWarnings,
-                       'sessionId' => MediaWiki\Session\SessionManager::getGlobalSession()->getId(),
-                       'sessionKey' => $sessionKey,
-               ) );
-               $job->initializeSessionData();
-               JobQueueGroup::singleton()->push( $job );
-
-               return $sessionKey;
-       }
 }
index 43fdbd9..943a275 100644 (file)
        "filename-thumb-name": "This looks like a thumbnail title. Please do not upload thumbnails back to the same wiki. Otherwise, please fix the filename so it is more meaningful, and does not have the thumbnail prefix.",
        "filename-bad-prefix": "The name of the file you are uploading begins with <strong>\"$1\"</strong>, which is a non-descriptive name typically assigned automatically by digital cameras.\nPlease choose a more descriptive name for your file.",
        "filename-prefix-blacklist": " #<!-- leave this line exactly as it is --> <pre>\n# Syntax is as follows:\n#   * Everything from a \"#\" character to the end of the line is a comment\n#   * Every non-blank line is a prefix for typical filenames assigned automatically by digital cameras\nCIMG # Casio\nDSC_ # Nikon\nDSCF # Fuji\nDSCN # Nikon\nDUW # some mobile phones\nIMG # generic\nJD # Jenoptik\nMGP # Pentax\nPICT # misc.\n #</pre> <!-- leave this line exactly as it is -->",
-       "upload-success-subj": "Successful upload",
-       "upload-success-msg": "Your upload from [$2] was successful. It is available here: [[:{{ns:file}}:$1]]",
-       "upload-failure-subj": "Upload problem",
-       "upload-failure-msg": "There was a problem with your upload from [$2]:\n\n$1",
-       "upload-warning-subj": "Upload warning",
-       "upload-warning-msg": "There was a problem with your upload from [$2]. You may return to the [[Special:Upload/stash/$1|upload form]] to correct this problem.",
        "upload-proto-error": "Incorrect protocol",
        "upload-proto-error-text": "Remote upload requires URLs beginning with <code>http://</code> or <code>ftp://</code>.",
        "upload-file-error": "Internal error",
index 37e1a5a..a823139 100644 (file)
        "filename-thumb-name": "Appears when thumbnail title is similar to \"22px-Example.jpg\" - the prefix is what MW adds when downloading pictures as thumbnails.",
        "filename-bad-prefix": "Used as warning in [[Special:Upload]]. Parameters:\n* $1 - prefix\nSee also:\n* {{msg-mw|fileexists}}\n* {{msg-mw|filepageexists}}\n* {{msg-mw|fileexists-extension}}\n* {{msg-mw|fileexists-thumbnail-yes}}\n* {{msg-mw|file-thumbnail-no}}\n* {{msg-mw|filewasdeleted}}",
        "filename-prefix-blacklist": "{{optional}}\nDo not translate the file name prefixes before the hash mark (#). Leave all the wiki markup, including the spaces, as is. You can translate the text, including 'Leave this line exactly as it is'. The first line of this messages has one (1) leading space.",
-       "upload-success-subj": "Used as message subject which is posted on the user talk page.\n\nSee also:\n* {{msg-mw|upload-success-subj|subject}}\n* {{msg-mw|upload-success-msg|message}}\n* {{msg-mw|upload-failure-subj|subject}}\n* {{msg-mw|upload-failure-msg|message}}",
-       "upload-success-msg": "Used as message body which is posted on the user talk page. Parameters:\n* $1 - the local file name after uploading\n* $2 - the URL the file was uploaded from, when using upload-by-URL\nSee also:\n* {{msg-mw|upload-success-subj|subject}}\n* {{msg-mw|upload-success-msg|message}}\n* {{msg-mw|upload-failure-subj|subject}}\n* {{msg-mw|upload-failure-msg|message}}",
-       "upload-failure-subj": "Used as message subject which is posted on the user talk page.\n\nI think this message should be translated as opposed to {{msg-mw|upload-success-subj}}.\n\nSee also:\n* {{msg-mw|upload-success-subj|subject}}\n* {{msg-mw|upload-success-msg|message}}\n* {{msg-mw|upload-failure-subj|subject}}\n* {{msg-mw|upload-failure-msg|message}}",
-       "upload-failure-msg": "Used as message body which is posted on the user talk page. Parameters:\n* $1 - the specific error message\n* $2 - the URL the file tried to upload from, when using upload-by-URL.\nSee also:\n* {{msg-mw|upload-success-subj|subject}}\n* {{msg-mw|upload-success-msg|message}}\n* {{msg-mw|upload-failure-subj|subject}}\n* {{msg-mw|upload-failure-msg|message}}",
-       "upload-warning-subj": "Used as warning subject which is posted on the user talk page.\n\nSee also:\n* {{msg-mw|upload-warning-subj|subject}}\n* {{msg-mw|upload-warning-msg|message}}",
-       "upload-warning-msg": "Used as warning body which is posted on the user talk page. Parameters:\n* $1 - the URL the file was uploaded from, when using upload-by-URL\n* $2 - the session key for the upload\nSee also:\n* {{msg-mw|Upload-warning-subj|subject}}",
        "upload-proto-error": "See also:\n* {{msg-mw|Upload-proto-error|title}}\n* {{msg-mw|Upload-proto-error-text|text}}",
        "upload-proto-error-text": "\"Remote upload\" is explained on [[w:Uploading_and_downloading#Remote_upload|Wikipedia]].\n\nSee also:\n* {{msg-mw|Upload-proto-error|title}}\n* {{msg-mw|Upload-proto-error-text|text}}",
        "upload-file-error": "Unused on core [[mw:Special:Code/MediaWiki/53282]].\n\nExtensions making use of it:\n*ImportFreeImages\n*SemanticForms\nSee also:\n* {{msg-mw|Upload-file-error|title}}\n* {{msg-mw|Upload-file-error-text|text}}\n{{Identical|Internal error}}",
index 2322909..6d5472e 100644 (file)
@@ -541,8 +541,6 @@ assert
 astriks
 asymp
 async
-asynccopyuploaddisabled
-asyncdownload
 at
 atend
 atext
@@ -2151,7 +2149,6 @@ lcount
 lcrocker
 ldquo
 le
-leavemessage
 len
 length
 leprop
index 40de254..18f0f79 100644 (file)
@@ -83,7 +83,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                        ), $session, self::$users['uploader']->getUser() );
                } catch ( UsageException $e ) {
                        $exception = true;
-                       $this->assertEquals( "One of the parameters filekey, file, url, statuskey is required",
+                       $this->assertEquals( "One of the parameters filekey, file, url is required",
                                $e->getMessage() );
                }
                $this->assertTrue( $exception, "Got exception" );
index 428fd27..fb14c65 100644 (file)
@@ -14,7 +14,6 @@ class UploadFromUrlTest extends ApiTestCase {
                $this->setMwGlobals( array(
                        'wgEnableUploads' => true,
                        'wgAllowCopyUploads' => true,
-                       'wgAllowAsyncCopyUploads' => true,
                ) );
 
                if ( wfLocalFile( 'UploadFromUrlTest.png' )->exists() ) {
@@ -73,7 +72,7 @@ class UploadFromUrlTest extends ApiTestCase {
                        ), $data );
                } catch ( UsageException $e ) {
                        $exception = true;
-                       $this->assertEquals( "One of the parameters sessionkey, file, url, statuskey is required",
+                       $this->assertEquals( "One of the parameters sessionkey, file, url is required",
                                $e->getMessage() );
                }
                $this->assertTrue( $exception, "Got exception" );
@@ -105,67 +104,6 @@ class UploadFromUrlTest extends ApiTestCase {
                        $this->assertEquals( "Permission denied", $e->getMessage() );
                }
                $this->assertTrue( $exception, "Got exception" );
-
-               $this->user->addGroup( 'sysop' );
-               $data = $this->doApiRequest( array(
-                       'action' => 'upload',
-                       'url' => 'http://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png',
-                       'asyncdownload' => 1,
-                       'filename' => 'UploadFromUrlTest.png',
-                       'token' => $token,
-               ), $data );
-
-               $this->assertEquals( $data[0]['upload']['result'], 'Queued', 'Queued upload' );
-
-               $job = JobQueueGroup::singleton()->pop();
-               $this->assertThat( $job, $this->isInstanceOf( 'UploadFromUrlJob' ), 'Queued upload inserted' );
-       }
-
-       /**
-        * @depends testClearQueue
-        */
-       public function testAsyncUpload( $data ) {
-               $token = $this->user->getEditToken();
-
-               $this->user->addGroup( 'users' );
-
-               $data = $this->doAsyncUpload( $token, true );
-               $this->assertEquals( $data[0]['upload']['result'], 'Success' );
-               $this->assertEquals( $data[0]['upload']['filename'], 'UploadFromUrlTest.png' );
-               $this->assertTrue( wfLocalFile( $data[0]['upload']['filename'] )->exists() );
-
-               $this->deleteFile( 'UploadFromUrlTest.png' );
-
-               return $data;
-       }
-
-       /**
-        * @depends testClearQueue
-        */
-       public function testAsyncUploadWarning( $data ) {
-               $token = $this->user->getEditToken();
-
-               $this->user->addGroup( 'users' );
-
-               $data = $this->doAsyncUpload( $token );
-
-               $this->assertEquals( $data[0]['upload']['result'], 'Warning' );
-               $this->assertTrue( isset( $data[0]['upload']['sessionkey'] ) );
-
-               $data = $this->doApiRequest( array(
-                       'action' => 'upload',
-                       'sessionkey' => $data[0]['upload']['sessionkey'],
-                       'filename' => 'UploadFromUrlTest.png',
-                       'ignorewarnings' => 1,
-                       'token' => $token,
-               ) );
-               $this->assertEquals( $data[0]['upload']['result'], 'Success' );
-               $this->assertEquals( $data[0]['upload']['filename'], 'UploadFromUrlTest.png' );
-               $this->assertTrue( wfLocalFile( $data[0]['upload']['filename'] )->exists() );
-
-               $this->deleteFile( 'UploadFromUrlTest.png' );
-
-               return $data;
        }
 
        /**
@@ -195,120 +133,6 @@ class UploadFromUrlTest extends ApiTestCase {
                return $data;
        }
 
-       public function testLeaveMessage() {
-               $token = $this->user->user->getEditToken();
-
-               $talk = $this->user->user->getTalkPage();
-               if ( $talk->exists() ) {
-                       $page = WikiPage::factory( $talk );
-                       $page->doDeleteArticle( '' );
-               }
-
-               $this->assertFalse(
-                       (bool)$talk->getArticleID( Title::GAID_FOR_UPDATE ),
-                       'User talk does not exist'
-               );
-
-               $this->doApiRequest( array(
-                       'action' => 'upload',
-                       'filename' => 'UploadFromUrlTest.png',
-                       'url' => 'http://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png',
-                       'asyncdownload' => 1,
-                       'token' => $token,
-                       'leavemessage' => 1,
-                       'ignorewarnings' => 1,
-               ) );
-
-               $job = JobQueueGroup::singleton()->pop();
-               $this->assertEquals( 'UploadFromUrlJob', get_class( $job ) );
-               $job->run();
-
-               $this->assertTrue( wfLocalFile( 'UploadFromUrlTest.png' )->exists() );
-               $this->assertTrue( (bool)$talk->getArticleID( Title::GAID_FOR_UPDATE ), 'User talk exists' );
-
-               $this->deleteFile( 'UploadFromUrlTest.png' );
-
-               $exception = false;
-               try {
-                       $this->doApiRequest( array(
-                               'action' => 'upload',
-                               'filename' => 'UploadFromUrlTest.png',
-                               'url' => 'http://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png',
-                               'asyncdownload' => 1,
-                               'token' => $token,
-                               'leavemessage' => 1,
-                       ) );
-               } catch ( UsageException $e ) {
-                       $exception = true;
-                       $this->assertEquals(
-                               'Using leavemessage without ignorewarnings is not supported',
-                               $e->getMessage()
-                       );
-               }
-               $this->assertTrue( $exception );
-
-               $job = JobQueueGroup::singleton()->pop();
-               $this->assertFalse( $job );
-
-               return;
-               /*
-               // Broken until using leavemessage with ignorewarnings is supported
-               $talkRev = Revision::newFromTitle( $talk );
-               $talkSize = $talkRev->getSize();
-
-               $job->run();
-
-               $this->assertFalse( wfLocalFile( 'UploadFromUrlTest.png' )->exists() );
-
-               $talkRev = Revision::newFromTitle( $talk );
-               $this->assertTrue( $talkRev->getSize() > $talkSize, 'New message left' );
-               */
-       }
-
-       /**
-        * Helper function to perform an async upload, execute the job and fetch
-        * the status
-        *
-        * @param string $token
-        * @param bool $ignoreWarnings
-        * @param bool $leaveMessage
-        * @return array The result of action=upload&statuskey=key
-        */
-       private function doAsyncUpload( $token, $ignoreWarnings = false, $leaveMessage = false ) {
-               $params = array(
-                       'action' => 'upload',
-                       'filename' => 'UploadFromUrlTest.png',
-                       'url' => 'http://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png',
-                       'asyncdownload' => 1,
-                       'token' => $token,
-               );
-               if ( $ignoreWarnings ) {
-                       $params['ignorewarnings'] = 1;
-               }
-               if ( $leaveMessage ) {
-                       $params['leavemessage'] = 1;
-               }
-
-               $data = $this->doApiRequest( $params );
-               $this->assertEquals( $data[0]['upload']['result'], 'Queued' );
-               $this->assertTrue( isset( $data[0]['upload']['statuskey'] ) );
-               $statusKey = $data[0]['upload']['statuskey'];
-
-               $job = JobQueueGroup::singleton()->pop();
-               $this->assertEquals( 'UploadFromUrlJob', get_class( $job ) );
-
-               $status = $job->run();
-               $this->assertTrue( $status );
-
-               $data = $this->doApiRequest( array(
-                       'action' => 'upload',
-                       'statuskey' => $statusKey,
-                       'token' => $token,
-               ) );
-
-               return $data;
-       }
-
        protected function deleteFile( $name ) {
                $t = Title::newFromText( $name, NS_FILE );
                $this->assertTrue( $t->exists(), "File '$name' exists" );