X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiUpload.php;h=d6748460225f8141002b232489cfe02a900bf9d4;hb=554ca56fd5e76b0216c09543d447dbecd5773202;hp=e76b3651ebf0988c7d857e3d6bf535132dd6b700;hpb=9073d2a0b5d37a6c3a4dca74bfb358b1085edf1e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index e76b3651eb..d674846022 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -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; @@ -735,6 +703,13 @@ class ApiUpload extends ApiBase { $watch = true; } + if ( $this->mParams['tags'] ) { + $status = ChangeTags::canAddTagsAccompanyingChange( $this->mParams['tags'], $this->getUser() ); + if ( !$status->isOK() ) { + $this->dieStatus( $status ); + } + } + // No errors, no warnings: do the upload if ( $this->mParams['async'] ) { $progress = UploadBase::getSessionStatus( $this->getUser(), $this->mParams['filekey'] ); @@ -752,6 +727,7 @@ class ApiUpload extends ApiBase { 'filename' => $this->mParams['filename'], 'filekey' => $this->mParams['filekey'], 'comment' => $this->mParams['comment'], + 'tags' => $this->mParams['tags'], 'text' => $this->mParams['text'], 'watch' => $watch, 'session' => $this->getContext()->exportSession() @@ -762,20 +738,10 @@ class ApiUpload extends ApiBase { } else { /** @var $status Status */ $status = $this->mUpload->performUpload( $this->mParams['comment'], - $this->mParams['text'], $watch, $this->getUser() ); + $this->mParams['text'], $watch, $this->getUser(), $this->mParams['tags'] ); 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 +756,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; } @@ -815,6 +772,10 @@ class ApiUpload extends ApiBase { 'comment' => array( ApiBase::PARAM_DFLT => '' ), + 'tags' => array( + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ), 'text' => array( ApiBase::PARAM_TYPE => 'text', ), @@ -855,9 +816,6 @@ class ApiUpload extends ApiBase { ), 'async' => false, - 'asyncdownload' => false, - 'leavemessage' => false, - 'statuskey' => null, 'checkstatus' => false, );