Merge "Capitalise Message in SpecialAllMessages files"
[lhc/web/wiklou.git] / includes / api / ApiUpload.php
index 3ef2bbe..5e6c962 100644 (file)
@@ -34,8 +34,6 @@ class ApiUpload extends ApiBase {
        protected $mParams;
 
        public function execute() {
-               global $wgEnableAsyncUploads;
-
                // Check whether upload is enabled
                if ( !UploadBase::isEnabled() ) {
                        $this->dieUsageMsg( 'uploaddisabled' );
@@ -47,7 +45,7 @@ class ApiUpload extends ApiBase {
                $this->mParams = $this->extractRequestParams();
                $request = $this->getMain()->getRequest();
                // Check if async mode is actually supported (jobs done in cli mode)
-               $this->mParams['async'] = ( $this->mParams['async'] && $wgEnableAsyncUploads );
+               $this->mParams['async'] = ( $this->mParams['async'] && $this->getConfig()->get( 'EnableAsyncUploads' ) );
                // Add the uploaded file to the params array
                $this->mParams['file'] = $request->getFileName( 'file' );
                $this->mParams['chunk'] = $request->getFileName( 'chunk' );
@@ -234,7 +232,7 @@ class ApiUpload extends ApiBase {
                                        array( 'result' => 'Poll',
                                                'stage' => 'queued', 'status' => Status::newGood() )
                                );
-                               $ok = JobQueueGroup::singleton()->push( new AssembleUploadChunksJob(
+                               JobQueueGroup::singleton()->push( new AssembleUploadChunksJob(
                                        Title::makeTitle( NS_FILE, $filekey ),
                                        array(
                                                'filename' => $this->mParams['filename'],
@@ -242,13 +240,7 @@ class ApiUpload extends ApiBase {
                                                'session' => $this->getContext()->exportSession()
                                        )
                                ) );
-                               if ( $ok ) {
-                                       $result['result'] = 'Poll';
-                               } else {
-                                       UploadBase::setSessionStatus( $filekey, false );
-                                       $this->dieUsage(
-                                               "Failed to start AssembleUploadChunks.php", 'stashfailed' );
-                               }
+                               $result['result'] = 'Poll';
                        } else {
                                $status = $this->mUpload->concatenateChunks();
                                if ( !$status->isGood() ) {
@@ -477,8 +469,6 @@ class ApiUpload extends ApiBase {
         * Performs file verification, dies on error.
         */
        protected function checkVerification( array $verification ) {
-               global $wgFileExtensions;
-
                // @todo Move them to ApiBase's message map
                switch ( $verification['status'] ) {
                        // Recoverable errors
@@ -510,7 +500,7 @@ class ApiUpload extends ApiBase {
                        case UploadBase::FILETYPE_BADTYPE:
                                $extradata = array(
                                        'filetype' => $verification['finalExt'],
-                                       'allowed' => array_values( array_unique( $wgFileExtensions ) )
+                                       'allowed' => array_values( array_unique( $this->getConfig()->get( 'FileExtensions' ) ) )
                                );
                                $this->getResult()->setIndexedTagName( $extradata['allowed'], 'ext' );
 
@@ -625,7 +615,7 @@ class ApiUpload extends ApiBase {
                                $this->mParams['filekey'],
                                array( 'result' => 'Poll', 'stage' => 'queued', 'status' => Status::newGood() )
                        );
-                       $ok = JobQueueGroup::singleton()->push( new PublishStashedFileJob(
+                       JobQueueGroup::singleton()->push( new PublishStashedFileJob(
                                Title::makeTitle( NS_FILE, $this->mParams['filename'] ),
                                array(
                                        'filename' => $this->mParams['filename'],
@@ -636,13 +626,7 @@ class ApiUpload extends ApiBase {
                                        'session' => $this->getContext()->exportSession()
                                )
                        ) );
-                       if ( $ok ) {
-                               $result['result'] = 'Poll';
-                       } else {
-                               UploadBase::setSessionStatus( $this->mParams['filekey'], false );
-                               $this->dieUsage(
-                                       "Failed to start PublishStashedFile.php", 'publishfailed' );
-                       }
+                       $result['result'] = 'Poll';
                } else {
                        /** @var $status Status */
                        $status = $this->mUpload->performUpload( $this->mParams['comment'],
@@ -678,8 +662,7 @@ class ApiUpload extends ApiBase {
         * Checks if asynchronous copy uploads are enabled and throws an error if they are not.
         */
        protected function checkAsyncDownloadEnabled() {
-               global $wgAllowAsyncCopyUploads;
-               if ( !$wgAllowAsyncCopyUploads ) {
+               if ( !$this->getConfig()->get( 'AllowAsyncCopyUploads' ) ) {
                        $this->dieUsage( 'Asynchronous copy uploads disabled', 'asynccopyuploaddisabled' );
                }
        }