X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiUpload.php;h=78a497144f119e937003b5aff7ecb122a3b52970;hb=95c85f71b178e75efd0a4444a4f39bbce27e694f;hp=43e4c61e0cad026e7386fd19c95c8142afc36e49;hpb=2a2bbf0a5ddb382d2ca1ef7618c42ce3023379d8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 43e4c61e0c..78a497144f 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -161,7 +161,7 @@ class ApiUpload extends ApiBase { } } catch ( UploadStashException $e ) { $this->handleStashException( $e ); - } catch ( MWException $e ) { + } catch ( Exception $e ) { $this->dieUsage( $e->getMessage(), 'stashfailed' ); } @@ -182,7 +182,7 @@ class ApiUpload extends ApiBase { try { $result['filekey'] = $this->performStash(); $result['sessionkey'] = $result['filekey']; // backwards compatibility - } catch ( MWException $e ) { + } catch ( Exception $e ) { $result['warnings']['stashfailed'] = $e->getMessage(); } @@ -209,7 +209,7 @@ class ApiUpload extends ApiBase { $filekey = $this->performStash(); } catch ( UploadStashException $e ) { $this->handleStashException( $e ); - } catch ( MWException $e ) { + } catch ( Exception $e ) { // FIXME: Error handling here is wrong/different from rest of this $this->dieUsage( $e->getMessage(), 'stashfailed' ); } @@ -218,7 +218,11 @@ class ApiUpload extends ApiBase { $status = $this->mUpload->addChunk( $chunkPath, $chunkSize, $this->mParams['offset'] ); if ( !$status->isGood() ) { - $this->dieUsage( $status->getWikiText(), 'stashfailed' ); + $extradata = array( + 'offset' => $this->mUpload->getOffset(), + ); + + $this->dieUsage( $status->getWikiText(), 'stashfailed', 0, $extradata ); return array(); } @@ -277,13 +281,13 @@ class ApiUpload extends ApiBase { */ private function performStash() { try { - $stashFile = $this->mUpload->stashFile(); + $stashFile = $this->mUpload->stashFile( $this->getUser() ); if ( !$stashFile ) { throw new MWException( 'Invalid stashed file' ); } $fileKey = $stashFile->getFileKey(); - } catch ( MWException $e ) { + } catch ( Exception $e ) { $message = 'Stashing temporary file failed: ' . get_class( $e ) . ' ' . $e->getMessage(); wfDebug( __METHOD__ . ' ' . $message . "\n" ); $className = get_class( $e ); @@ -306,7 +310,7 @@ class ApiUpload extends ApiBase { try { $data['filekey'] = $this->performStash(); $data['sessionkey'] = $data['filekey']; - } catch ( MWException $e ) { + } catch ( Exception $e ) { $data['stashfailed'] = $e->getMessage(); } $data['invalidparameter'] = $parameter;