X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiUpload.php;h=5e6c962d12977b6df06df261e69a367ac8dc729c;hb=af2c2b6331842bc9e66d5cdda27291de585c8ea5;hp=3ef2bbe46eece9e292f48133c3cd8368c6d666f3;hpb=280cb03b4d87e864a723686daf5d1699b3566ec1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 3ef2bbe46e..5e6c962d12 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -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' ); } }