Followup r70461 if PARAM_REQUIRED is set, use for missing param in getPossibleErrors...
[lhc/web/wiklou.git] / includes / api / ApiUpload.php
index b83c7c7..59a267d 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 <?php
-/*
+/**
  * Created on Aug 21, 2008
  * API for MediaWiki 1.8+
  *
  * Created on Aug 21, 2008
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2008 - 2010 Bryan Tong Minh <Bryan.TongMinh@Gmail.com>
+ * Copyright © 2008 - 2010 Bryan Tong Minh <Bryan.TongMinh@Gmail.com>
  *
  * 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
  *
  * 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
@@ -17,7 +17,7 @@
  *
  * 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.,
  *
  * 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.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  */
 
  * http://www.gnu.org/copyleft/gpl.html
  */
 
@@ -38,169 +38,186 @@ class ApiUpload extends ApiBase {
        }
 
        public function execute() {
        }
 
        public function execute() {
-               global $wgUser, $wgAllowCopyUploads;
+               global $wgUser;
 
                // Check whether upload is enabled
 
                // Check whether upload is enabled
-               if ( !UploadBase::isEnabled() )
+               if ( !UploadBase::isEnabled() ) {
                        $this->dieUsageMsg( array( 'uploaddisabled' ) );
                        $this->dieUsageMsg( array( 'uploaddisabled' ) );
+               }
 
 
+               // Parameter handling
                $this->mParams = $this->extractRequestParams();
                $request = $this->getMain()->getRequest();
                $this->mParams = $this->extractRequestParams();
                $request = $this->getMain()->getRequest();
-
-               // Do token checks:
-               if ( is_null( $this->mParams['token'] ) )
-                       $this->dieUsageMsg( array( 'missingparam', 'token' ) );
-               if ( !$wgUser->matchEditToken( $this->mParams['token'] ) )
-                       $this->dieUsageMsg( array( 'sessionfailure' ) );
-
                // Add the uploaded file to the params array
                $this->mParams['file'] = $request->getFileName( 'file' );
 
                // Add the uploaded file to the params array
                $this->mParams['file'] = $request->getFileName( 'file' );
 
-               // One and only one of the following parameters is needed
-               $this->requireOnlyOneParameter( $this->mParams,
-                       'sessionkey', 'file', 'url', 'enablechunks' );
+               // Select an upload module
+               $this->selectUploadModule();
+               if ( !isset( $this->mUpload ) ) {
+                       $this->dieUsage( 'No upload module set', 'nomodule' );
+               }
+               
+               // First check permission to upload
+               $this->checkPermissions( $wgUser );
+               
+               // Fetch the file
+               $status = $this->mUpload->fetchFile();
+               if ( !$status->isGood() ) {
+                       $errors = $status->getErrorsArray();
+                       $error = array_shift( $errors[0] );
+                       $this->dieUsage( 'Error fetching file from remote source', $error, 0, $errors[0] );
+               }
 
 
-               // Initialize $this->mUpload
-               if ( $this->mParams['enablechunks'] ) {
-                       $this->mUpload = new UploadFromChunks();
+               // Check if the uploaded file is sane
+               $this->verifyUpload();
+               
+               // Check permission to upload this file
+               $permErrors = $this->mUpload->verifyPermissions( $wgUser );
+               if ( $permErrors !== true ) {
+                       // Todo: stash the upload and allow choosing a new name
+                       $this->dieUsageMsg( array( 'badaccess-groups' ) );
+               }
 
 
-                       $this->mUpload->initialize(
-                               $request->getVal( 'done', null ),
-                               $request->getVal( 'filename', null ),
-                               $request->getVal( 'chunksession', null ),
-                               $request->getFileTempName( 'chunk' ),
-                               $request->getFileSize( 'chunk' ),
-                               $request->getSessionData( 'wsUploadData' )
-                       );
+               // Check warnings if necessary
+               $warnings = $this->checkForWarnings();
+               if ( $warnings ) {
+                       $this->getResult()->addValue( null, $this->getModuleName(), $warnings );
+               } else {
+                       // Perform the upload
+                       $result = $this->performUpload();
+                       $this->getResult()->addValue( null, $this->getModuleName(), $result );
+               }
+
+               // Cleanup any temporary mess
+               $this->mUpload->cleanupTempFile();
+       }
+       
+       /**
+        * Select an upload module and set it to mUpload. Dies on failure.
+        */
+       protected function selectUploadModule() {
+               $request = $this->getMain()->getRequest();
+               
+               // One and only one of the following parameters is needed
+               $this->requireOnlyOneParameter( $this->mParams,
+                       'sessionkey', 'file', 'url' );
 
 
-                       if ( !$this->mUpload->status->isOK() ) {
-                               return $this->dieUsageMsg( $this->mUpload->status->getErrorsArray() );
+               if ( $this->mParams['sessionkey'] ) {
+                       // Upload stashed in a previous request
+                       $sessionData = $request->getSessionData( UploadBase::getSessionKeyName() );
+                       if ( !UploadFromStash::isValidSessionKey( $this->mParams['sessionkey'], $sessionData ) ) {
+                               $this->dieUsageMsg( array( 'invalid-session-key' ) );
                        }
                        }
-               } elseif ( $this->mParams['sessionkey'] ) {
-                       /**
-                        * Upload stashed in a previous request
-                        */
-                       // Check the session key
-                       if ( !isset( $_SESSION['wsUploadData'][$this->mParams['sessionkey']] ) )
-                               return $this->dieUsageMsg( array( 'invalid-session-key' ) );
 
                        $this->mUpload = new UploadFromStash();
                        $this->mUpload->initialize( $this->mParams['filename'],
 
                        $this->mUpload = new UploadFromStash();
                        $this->mUpload->initialize( $this->mParams['filename'],
-                               $_SESSION['wsUploadData'][$this->mParams['sessionkey']] );
-               } elseif ( isset( $this->mParams['filename'] ) ) {
-                       /**
-                        * Upload from url, etc
-                        * Parameter filename is required
-                        */
-
-                       if ( isset( $this->mParams['file'] ) ) {
-                               $this->mUpload = new UploadFromFile();
-                               $this->mUpload->initialize(
-                                       $this->mParams['filename'],
-                                       $request->getFileTempName( 'file' ),
-                                       $request->getFileSize( 'file' )
-                               );
-                       } elseif ( isset( $this->mParams['url'] ) ) {
-                               // make sure upload by url is enabled:
-                               if ( !$wgAllowCopyUploads )
-                                       $this->dieUsageMsg( array( 'uploaddisabled' ) );
-
-                               // make sure the current user can upload
-                               if ( ! $wgUser->isAllowed( 'upload_by_url' ) )
-                                       $this->dieUsageMsg( array( 'badaccess-groups' ) );
-
-                               $this->mUpload = new UploadFromUrl();
-                               $this->mUpload->initialize( $this->mParams['filename'],
-                                               $this->mParams['url'] );
-
-                               $status = $this->mUpload->fetchFile();
-                               if ( !$status->isOK() ) {
-                                       return $this->dieUsage( $status->getWikiText(),  'fetchfileerror' );
+                               $this->mParams['sessionkey'],
+                               $sessionData[$this->mParams['sessionkey']] );
+                       
+                       
+               } elseif ( isset( $this->mParams['file'] ) ) {
+                       $this->mUpload = new UploadFromFile();
+                       $this->mUpload->initialize(
+                               $this->mParams['filename'],
+                               $request->getUpload( 'file' )
+                       );      
+               } elseif ( isset( $this->mParams['url'] ) ) {
+                       // Make sure upload by URL is enabled:
+                       if ( !UploadFromUrl::isEnabled() ) {
+                               $this->dieUsageMsg( array( 'copyuploaddisabled' ) );
+                       }
+                       
+                       $async = false;
+                       if ( $this->mParams['asyncdownload'] ) {
+                               if ( $this->mParams['leavemessage'] ) {
+                                       $async = 'async-leavemessage';
+                               } else {
+                                       $async = 'async';
                                }
                        }
                                }
                        }
-               } else $this->dieUsageMsg( array( 'missingparam', 'filename' ) );
+                       $this->mUpload = new UploadFromUrl;
+                       $this->mUpload->initialize( $this->mParams['filename'],
+                               $this->mParams['url'], $async );
 
 
-               if ( !isset( $this->mUpload ) )
-                       $this->dieUsage( 'No upload module set', 'nomodule' );
+               }
+       }
 
 
+       /**
+        * Checks that the user has permissions to perform this upload.
+        * Dies with usage message on inadequate permissions.
+        * @param $user User The user to check.
+        */
+       protected function checkPermissions( $user ) {
                // Check whether the user has the appropriate permissions to upload anyway
                // Check whether the user has the appropriate permissions to upload anyway
-               $permission = $this->mUpload->isAllowed( $wgUser );
+               $permission = $this->mUpload->isAllowed( $user );
 
                if ( $permission !== true ) {
 
                if ( $permission !== true ) {
-                       if ( !$wgUser->isLoggedIn() )
+                       if ( !$user->isLoggedIn() ) {
                                $this->dieUsageMsg( array( 'mustbeloggedin', 'upload' ) );
                                $this->dieUsageMsg( array( 'mustbeloggedin', 'upload' ) );
-                       else
+                       } else {
                                $this->dieUsageMsg( array( 'badaccess-groups' ) );
                                $this->dieUsageMsg( array( 'badaccess-groups' ) );
-               }
-               // Perform the upload
-               $result = $this->performUpload();
-
-               // Cleanup any temporary mess
-               $this->mUpload->cleanupTempFile();
-
-               if( $this->mParams['enablechunks'] ) {
-                       foreach ($result as $key => $value) {
-                               if($value === null) $value = "";
-                               $this->getResult()->addValue( null, $key, $value );
                        }
                        }
-               } else {
-                       $this->getResult()->addValue( null, $this->getModuleName(), $result );
                }
        }
 
                }
        }
 
-       protected function performUpload() {
-               global $wgUser;
-               $result = array();
-               $permErrors = $this->mUpload->verifyPermissions( $wgUser );
-               if ( $permErrors !== true ) {
-                       $this->dieUsageMsg( array( 'badaccess-groups' ) );
+       /**
+        * Performs file verification, dies on error.
+        */
+       protected function verifyUpload( ) {
+               $verification = $this->mUpload->verifyUpload( );
+               if ( $verification['status'] === UploadBase::OK ) {
+                       return;         
                }
 
                // TODO: Move them to ApiBase's message map
                }
 
                // TODO: Move them to ApiBase's message map
-               $verification = $this->mUpload->verifyUpload();
-               if ( $verification['status'] !== UploadBase::OK ) {
-                       $result['result'] = 'Failure';
-                       switch( $verification['status'] ) {
-                               case UploadBase::EMPTY_FILE:
-                                       $this->dieUsage( 'The file you submitted was empty', 'empty-file' );
-                                       break;
-                               case UploadBase::FILETYPE_MISSING:
-                                       $this->dieUsage( 'The file is missing an extension', 'filetype-missing' );
-                                       break;
-                               case UploadBase::FILETYPE_BADTYPE:
-                                       global $wgFileExtensions;
-                                       $this->dieUsage( 'This type of file is banned', 'filetype-banned',
-                                                       0, array(
-                                                               'filetype' => $verification['finalExt'],
-                                                               'allowed' => $wgFileExtensions
-                                                       ) );
-                                       break;
-                               case UploadBase::MIN_LENGTH_PARTNAME:
-                                       $this->dieUsage( 'The filename is too short', 'filename-tooshort' );
-                                       break;
-                               case UploadBase::ILLEGAL_FILENAME:
-                                       $this->dieUsage( 'The filename is not allowed', 'illegal-filename',
-                                                       0, array( 'filename' => $verification['filtered'] ) );
-                                       break;
-                               case UploadBase::OVERWRITE_EXISTING_FILE:
-                                       $this->dieUsage( 'Overwriting an existing file is not allowed', 'overwrite' );
-                                       break;
-                               case UploadBase::VERIFICATION_ERROR:
-                                       $this->getResult()->setIndexedTagName( $verification['details'], 'detail' );
-                                       $this->dieUsage( 'This file did not pass file verification', 'verification-error',
-                                                       0, array( 'details' => $verification['details'] ) );
-                                       break;
-                               case UploadBase::HOOK_ABORTED:
-                                       $this->dieUsage( "The modification you tried to make was aborted by an extension hook",
-                                                       'hookaborted', 0, array( 'error' => $verification['error'] ) );
-                                       break;
-                               default:
-                                       $this->dieUsage( 'An unknown error occurred', 'unknown-error',
-                                                       0, array( 'code' =>  $verification['status'] ) );
-                                       break;
-                       }
-                       return $result;
+               switch( $verification['status'] ) {
+                       case UploadBase::EMPTY_FILE:
+                               $this->dieUsage( 'The file you submitted was empty', 'empty-file' );
+                               break;
+                       case UploadBase::FILE_TOO_LARGE:
+                               $this->dieUsage( 'The file you submitted was too large', 'file-too-large' );
+                               break;
+                       case UploadBase::FILETYPE_MISSING:
+                               $this->dieUsage( 'The file is missing an extension', 'filetype-missing' );
+                               break;
+                       case UploadBase::FILETYPE_BADTYPE:
+                               global $wgFileExtensions;
+                               $this->dieUsage( 'This type of file is banned', 'filetype-banned',
+                                               0, array(
+                                                       'filetype' => $verification['finalExt'],
+                                                       'allowed' => $wgFileExtensions
+                                               ) );
+                               break;
+                       case UploadBase::MIN_LENGTH_PARTNAME:
+                               $this->dieUsage( 'The filename is too short', 'filename-tooshort' );
+                               break;
+                       case UploadBase::ILLEGAL_FILENAME:
+                               $this->dieUsage( 'The filename is not allowed', 'illegal-filename',
+                                               0, array( 'filename' => $verification['filtered'] ) );
+                               break;
+                       case UploadBase::VERIFICATION_ERROR:
+                               $this->getResult()->setIndexedTagName( $verification['details'], 'detail' );
+                               $this->dieUsage( 'This file did not pass file verification', 'verification-error',
+                                               0, array( 'details' => $verification['details'] ) );
+                               break;
+                       case UploadBase::HOOK_ABORTED:
+                               $this->dieUsage( "The modification you tried to make was aborted by an extension hook",
+                                               'hookaborted', 0, array( 'error' => $verification['error'] ) );
+                               break;
+                       default:
+                               $this->dieUsage( 'An unknown error occurred', 'unknown-error',
+                                               0, array( 'code' =>  $verification['status'] ) );
+                               break;
                }
                }
+       }
+
+       /**
+        * Check warnings if ignorewarnings is not set. 
+        * Returns a suitable result array if there were warnings
+        */
+       protected function checkForWarnings() {
+               $result = array();
+
                if ( !$this->mParams['ignorewarnings'] ) {
                        $warnings = $this->mUpload->checkWarnings();
                        if ( $warnings ) {
                if ( !$this->mParams['ignorewarnings'] ) {
                        $warnings = $this->mUpload->checkWarnings();
                        if ( $warnings ) {
@@ -215,7 +232,6 @@ class ApiUpload extends ApiBase {
                                        $warnings['duplicate'] = $dupes;
                                }
 
                                        $warnings['duplicate'] = $dupes;
                                }
 
-
                                if ( isset( $warnings['exists'] ) ) {
                                        $warning = $warnings['exists'];
                                        unset( $warnings['exists'] );
                                if ( isset( $warnings['exists'] ) ) {
                                        $warning = $warnings['exists'];
                                        unset( $warnings['exists'] );
@@ -226,33 +242,61 @@ class ApiUpload extends ApiBase {
                                $result['warnings'] = $warnings;
 
                                $sessionKey = $this->mUpload->stashSession();
                                $result['warnings'] = $warnings;
 
                                $sessionKey = $this->mUpload->stashSession();
-                               if ( !$sessionKey )
+                               if ( !$sessionKey ) {
                                        $this->dieUsage( 'Stashing temporary file failed', 'stashfailed' );
                                        $this->dieUsage( 'Stashing temporary file failed', 'stashfailed' );
+                               }
 
                                $result['sessionkey'] = $sessionKey;
 
                                return $result;
                        }
                }
 
                                $result['sessionkey'] = $sessionKey;
 
                                return $result;
                        }
                }
+               return;
+       }
 
 
+       /**
+        * Perform the actual upload. Returns a suitable result array on success;
+        * dies on failure.
+        */
+       protected function performUpload() {
+               global $wgUser;
+               
                // Use comment as initial page text by default
                // Use comment as initial page text by default
-               if ( is_null( $this->mParams['text'] ) )
+               if ( is_null( $this->mParams['text'] ) ) {
                        $this->mParams['text'] = $this->mParams['comment'];
                        $this->mParams['text'] = $this->mParams['comment'];
+               }
+
+               $file = $this->mUpload->getLocalFile();
+               $watch = $this->getWatchlistValue( $this->mParams['watchlist'], $file->getTitle() );
+
+               // Deprecated parameters
+               if ( $this->mParams['watch'] ) {
+                       $watch = true;
+               }
 
                // No errors, no warnings: do the upload
                $status = $this->mUpload->performUpload( $this->mParams['comment'],
 
                // No errors, no warnings: do the upload
                $status = $this->mUpload->performUpload( $this->mParams['comment'],
-                       $this->mParams['text'], $this->mParams['watch'], $wgUser );
+                       $this->mParams['text'], $watch, $wgUser );
 
                if ( !$status->isGood() ) {
                        $error = $status->getErrorsArray();
 
                if ( !$status->isGood() ) {
                        $error = $status->getErrorsArray();
-                       $this->getResult()->setIndexedTagName( $result['details'], 'error' );
+                       
+                       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',
+                                       'sessionkey' => $error[0][1],
+                               );
+                       } else {
+                               $this->getResult()->setIndexedTagName( $error, 'error' );
 
 
-                       $this->dieUsage( 'An internal error occurred', 'internal-error', 0, $error );
-               } elseif( $this->mParams['enablechunks'] ) {
-                       return $status->value;
+                               $this->dieUsage( 'An internal error occurred', 'internal-error', 0, $error );
+                       }
                }
 
                $file = $this->mUpload->getLocalFile();
                }
 
                $file = $this->mUpload->getLocalFile();
+
                $result['result'] = 'Success';
                $result['filename'] = $file->getName();
                $result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() );
                $result['result'] = 'Success';
                $result['filename'] = $file->getName();
                $result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() );
@@ -270,71 +314,113 @@ class ApiUpload extends ApiBase {
 
        public function getAllowedParams() {
                $params = array(
 
        public function getAllowedParams() {
                $params = array(
-                       'filename' => null,
+                       'filename' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => true
+                       ),
                        'comment' => array(
                                ApiBase::PARAM_DFLT => ''
                        ),
                        'text' => null,
                        'token' => null,
                        'comment' => array(
                                ApiBase::PARAM_DFLT => ''
                        ),
                        'text' => null,
                        'token' => null,
-                       'watch' => false,
+                       'watch' => array(
+                               ApiBase::PARAM_DFLT => false,
+                               ApiBase::PARAM_DEPRECATED => true,
+                       ),
+                       'watchlist' => array(
+                               ApiBase::PARAM_DFLT => 'preferences',
+                               ApiBase::PARAM_TYPE => array(
+                                       'watch',
+                                       'preferences',
+                                       'nochange'
+                               ),
+                       ),
                        'ignorewarnings' => false,
                        'file' => null,
                        'ignorewarnings' => false,
                        'file' => null,
-                       'enablechunks' => false,
-                       'chunksession' => null,
-                       'chunk' => null,
-                       'done' => false,
                        'url' => null,
                        'url' => null,
+
                        'sessionkey' => null,
                );
                        'sessionkey' => null,
                );
-
-               if ( $this->getMain()->isInternalMode() )
-                       $params['internalhttpsession'] = null;
+               
+               global $wgAllowAsyncCopyUploads;
+               if ( $wgAllowAsyncCopyUploads ) {
+                       $params += array(
+                               'asyncdownload' => false,
+                               'leavemessage' => false,                        
+                       );
+               }
                return $params;
                return $params;
-
        }
 
        public function getParamDescription() {
        }
 
        public function getParamDescription() {
-               return array(
+               $params = array(
                        'filename' => 'Target filename',
                        'token' => 'Edit token. You can get one of these through prop=info',
                        'comment' => 'Upload comment. Also used as the initial page text for new files if "text" is not specified',
                        'text' => 'Initial page text for new files',
                        'watch' => 'Watch the page',
                        'filename' => 'Target filename',
                        'token' => 'Edit token. You can get one of these through prop=info',
                        'comment' => 'Upload comment. Also used as the initial page text for new files if "text" is not specified',
                        'text' => 'Initial page text for new files',
                        'watch' => 'Watch the page',
+                       'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
                        'ignorewarnings' => 'Ignore any warnings',
                        'file' => 'File contents',
                        'ignorewarnings' => 'Ignore any warnings',
                        'file' => 'File contents',
-                       'enablechunks' => 'Set to use chunk mode; see http://firefogg.org/dev/chunk_post.html for protocol',
-                       'chunksession' => 'The session key, established on the first contact during the chunked upload',
-                       'chunk' => 'The data in this chunk of a chunked upload',
-                       'done' => 'Set to 1 on the last chunk of a chunked upload',
                        'url' => 'Url to fetch the file from',
                        'url' => 'Url to fetch the file from',
-                       'sessionkey' => array(
-                               'Session key returned by a previous upload that failed due to warnings',
-                       ),
+                       'sessionkey' => 'Session key returned by a previous upload that failed due to warnings',
                );
                );
+
+               global $wgAllowAsyncCopyUploads;
+               if ( $wgAllowAsyncCopyUploads ) {
+                       $params += array(
+                               'asyncdownload' => 'Make fetching a URL asynchronous',
+                               'leavemessage' => 'If asyncdownload is used, leave a message on the user talk page if finished',                        
+                       );
+               }
+               
+               return $params;
+               
        }
 
        public function getDescription() {
                return array(
                        'Upload a file, or get the status of pending uploads. Several methods are available:',
                        ' * Upload file contents directly, using the "file" parameter',
        }
 
        public function getDescription() {
                return array(
                        'Upload a file, or get the status of pending uploads. Several methods are available:',
                        ' * Upload file contents directly, using the "file" parameter',
-                       ' * Upload a file in chunks, using the "enablechunks",',
                        ' * Have the MediaWiki server fetch a file from a URL, using the "url" parameter',
                        ' * Complete an earlier upload that failed due to warnings, using the "sessionkey" parameter',
                        'Note that the HTTP POST must be done as a file upload (i.e. using multipart/form-data) when',
                        ' * Have the MediaWiki server fetch a file from a URL, using the "url" parameter',
                        ' * Complete an earlier upload that failed due to warnings, using the "sessionkey" parameter',
                        'Note that the HTTP POST must be done as a file upload (i.e. using multipart/form-data) when',
-                       'sending the "file" or "chunk" parameters. Note also that queries using session keys must be',
+                       'sending the "file". Note also that queries using session keys must be',
                        'done in the same login session as the query that originally returned the key (i.e. do not',
                        'done in the same login session as the query that originally returned the key (i.e. do not',
-                       'log out and then log back in). Also you must get and send an edit token before doing any upload stuff.'
+                       'log out and then log back in). Also you must get and send an edit token before doing any upload stuff'
                );
        }
 
                );
        }
 
+       public function getPossibleErrors() {
+               return array_merge( parent::getPossibleErrors(), array(
+                       array( 'uploaddisabled' ),
+                       array( 'invalid-session-key' ),
+                       array( 'uploaddisabled' ),
+                       array( 'badaccess-groups' ),
+                       array( 'mustbeloggedin', 'upload' ),
+                       array( 'badaccess-groups' ),
+                       array( 'badaccess-groups' ),
+                       array( 'code' => 'fetchfileerror', 'info' => '' ),
+                       array( 'code' => 'nomodule', 'info' => 'No upload module set' ),
+                       array( 'code' => 'empty-file', 'info' => 'The file you submitted was empty' ),
+                       array( 'code' => 'filetype-missing', 'info' => 'The file is missing an extension' ),
+                       array( 'code' => 'filename-tooshort', 'info' => 'The filename is too short' ),
+                       array( 'code' => 'overwrite', 'info' => 'Overwriting an existing file is not allowed' ),
+                       array( 'code' => 'stashfailed', 'info' => 'Stashing temporary file failed' ),
+                       array( 'code' => 'internal-error', 'info' => 'An internal error occurred' ),
+               ) );
+       }
+
+       public function getTokenSalt() {
+               return '';
+       }
+
        protected function getExamples() {
                return array(
                        'Upload from a URL:',
                        '    api.php?action=upload&filename=Wiki.png&url=http%3A//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png',
                        'Complete an upload that failed due to warnings:',
                        '    api.php?action=upload&filename=Wiki.png&sessionkey=sessionkey&ignorewarnings=1',
        protected function getExamples() {
                return array(
                        'Upload from a URL:',
                        '    api.php?action=upload&filename=Wiki.png&url=http%3A//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png',
                        'Complete an upload that failed due to warnings:',
                        '    api.php?action=upload&filename=Wiki.png&sessionkey=sessionkey&ignorewarnings=1',
-                       'Begin a chunked upload:',
-                       '    api.php?action=upload&filename=Wiki.png&enablechunks=1'
                );
        }
 
                );
        }