X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiUpload.php;h=a283b5a215341eb91a4fac9bf044d4a67c70598b;hb=bb866e75d0c6e7e47f59371fd5b9e37fc6e66fc8;hp=311fa54a9ff8f37daf783e8b14e3bb7add9a79eb;hpb=a2fadd06195cad8458c4815c555ca1e96aa3719f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 311fa54a9f..a283b5a215 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -494,6 +494,13 @@ class ApiUpload extends ApiBase { $this->mParams['filekey'], $this->mParams['filename'], !$this->mParams['async'] ); } elseif ( isset( $this->mParams['file'] ) ) { + // Can't async upload directly from a POSTed file, we'd have to + // stash the file and then queue the publish job. The user should + // just submit the two API queries to perform those two steps. + if ( $this->mParams['async'] ) { + $this->dieWithError( 'apierror-cannot-async-upload-file' ); + } + $this->mUpload = new UploadFromFile(); $this->mUpload->initialize( $this->mParams['filename'], @@ -637,7 +644,8 @@ class ApiUpload extends ApiBase { break; case UploadBase::HOOK_ABORTED: - $this->dieWithError( $params, 'hookaborted', [ 'details' => $verification['error'] ] ); + $msg = $verification['error'] === '' ? 'hookaborted' : $verification['error']; + $this->dieWithError( $msg, 'hookaborted', [ 'details' => $verification['error'] ] ); break; default: $this->dieWithError( 'apierror-unknownerror-nocode', 'unknown-error', @@ -719,7 +727,7 @@ class ApiUpload extends ApiBase { * @return StatusValue */ protected function handleStashException( $e ) { - switch ( get_class( $exception ) ) { + switch ( get_class( $e ) ) { case 'UploadStashFileNotFoundException': $wrap = 'apierror-stashedfilenotfound'; break; @@ -920,6 +928,6 @@ class ApiUpload extends ApiBase { } public function getHelpUrls() { - return 'https://www.mediawiki.org/wiki/API:Upload'; + return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Upload'; } }