X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiUpload.php;h=e04c76214b1ca0853720efd56c9b39e62b23a2ff;hb=c58873fb4213447615761a55fd2be72fa53f8ec2;hp=9d30729c6f8a881338af2a13a85ff3d2cf8dcb0e;hpb=c0f872ddf7ac1ebe791933a1423c629eee9ee521;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 9d30729c6f..e04c76214b 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -56,7 +56,7 @@ class ApiUpload extends ApiBase { $this->mParams['chunk'] = $request->getFileName( 'chunk' ); // Copy the session key to the file key, for backward compatibility. - if( !$this->mParams['filekey'] && $this->mParams['sessionkey'] ) { + if ( !$this->mParams['filekey'] && $this->mParams['sessionkey'] ) { $this->mParams['filekey'] = $this->mParams['sessionkey']; } @@ -82,15 +82,16 @@ class ApiUpload extends ApiBase { // Check if the uploaded file is sane if ( $this->mParams['chunk'] ) { $maxSize = $this->mUpload->getMaxUploadSize(); - if( $this->mParams['filesize'] > $maxSize ) { + if ( $this->mParams['filesize'] > $maxSize ) { $this->dieUsage( 'The file you submitted was too large', 'file-too-large' ); } if ( !$this->mUpload->getTitle() ) { $this->dieUsage( 'Invalid file title supplied', 'internal-error' ); } - } elseif ( $this->mParams['async'] ) { + } elseif ( $this->mParams['async'] && $this->mParams['filekey'] ) { // defer verification to background process } else { + wfDebug( __METHOD__ . 'about to verify' ); $this->verifyUpload(); } @@ -195,7 +196,12 @@ class ApiUpload extends ApiBase { $chunkPath = $request->getFileTempname( 'chunk' ); $chunkSize = $request->getUpload( 'chunk' )->getSize(); if ( $this->mParams['offset'] == 0 ) { - $filekey = $this->performStash(); + try { + $filekey = $this->performStash(); + } catch ( MWException $e ) { + // FIXME: Error handling here is wrong/different from rest of this + $this->dieUsage( $e->getMessage(), 'stashfailed' ); + } } else { $filekey = $this->mParams['filekey']; /** @var $status Status */ @@ -354,7 +360,7 @@ class ApiUpload extends ApiBase { if ( $this->mParams['chunk'] ) { // Chunk upload $this->mUpload = new UploadFromChunks(); - if( isset( $this->mParams['filekey'] ) ) { + if ( isset( $this->mParams['filekey'] ) ) { // handle new chunk $this->mUpload->continueChunks( $this->mParams['filename'], @@ -456,7 +462,7 @@ class ApiUpload extends ApiBase { global $wgFileExtensions; // @todo Move them to ApiBase's message map - switch( $verification['status'] ) { + switch ( $verification['status'] ) { // Recoverable errors case UploadBase::MIN_LENGTH_PARTNAME: $this->dieRecoverableError( 'filename-tooshort', 'filename' );