From bca71b173ef12c386b118a618eec2482d037cd33 Mon Sep 17 00:00:00 2001 From: Brion VIBBER Date: Wed, 23 May 2012 19:27:48 +0000 Subject: [PATCH] Revert "(bug 30625) Add, to every API upload response, the warnings raised." Inconsistent formatting (returns an empty array vs a full object, breaks UploadWizard) This reverts commit e2b3d53db5c766dea3ea1d34e4136259214a03c9 --- includes/api/ApiUpload.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 9f5c5e31c2..e58a1ca075 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -117,25 +117,25 @@ class ApiUpload extends ApiBase { */ private function getContextResult(){ $warnings = $this->getApiWarnings(); - if ( $warnings && !$this->mParams['ignorewarnings'] ) { + if ( $warnings ) { // Get warnings formated in result array format return $this->getWarningsResult( $warnings ); } elseif ( $this->mParams['chunk'] ) { // Add chunk, and get result - return $this->getChunkResult( $warnings ); + return $this->getChunkResult(); } elseif ( $this->mParams['stash'] ) { // Stash the file and get stash result - return $this->getStashResult( $warnings ); + return $this->getStashResult(); } // This is the most common case -- a normal upload with no warnings // performUpload will return a formatted properly for the API with status - return $this->performUpload( $warnings ); + return $this->performUpload(); } /** * Get Stash Result, throws an expetion if the file could not be stashed. * @return array */ - private function getStashResult( $warnings ){ + private function getStashResult(){ $result = array (); // Some uploads can request they be stashed, so as not to publish them immediately. // In this case, a failure to stash ought to be fatal @@ -143,7 +143,6 @@ class ApiUpload extends ApiBase { $result['result'] = 'Success'; $result['filekey'] = $this->performStash(); $result['sessionkey'] = $result['filekey']; // backwards compatibility - $result['warnings'] = $warnings; } catch ( MWException $e ) { $this->dieUsage( $e->getMessage(), 'stashfailed' ); } @@ -172,11 +171,10 @@ class ApiUpload extends ApiBase { * Get the result of a chunk upload. * @return array */ - private function getChunkResult( $warnings ){ + private function getChunkResult(){ $result = array(); $result['result'] = 'Continue'; - $result['warnings'] = $warnings; $request = $this->getMain()->getRequest(); $chunkPath = $request->getFileTempname( 'chunk' ); $chunkSize = $request->getUpload( 'chunk' )->getSize(); @@ -455,8 +453,9 @@ class ApiUpload extends ApiBase { protected function getApiWarnings() { $warnings = array(); - $warnings = $this->mUpload->checkWarnings(); - + if ( !$this->mParams['ignorewarnings'] ) { + $warnings = $this->mUpload->checkWarnings(); + } return $this->transformWarnings( $warnings ); } @@ -491,7 +490,7 @@ class ApiUpload extends ApiBase { * * @return array */ - protected function performUpload( $warnings ) { + protected function performUpload() { // Use comment as initial page text by default if ( is_null( $this->mParams['text'] ) ) { $this->mParams['text'] = $this->mParams['comment']; @@ -530,7 +529,6 @@ class ApiUpload extends ApiBase { $result['result'] = 'Success'; $result['filename'] = $file->getName(); - $result['warnings'] = $warnings; return $result; } -- 2.20.1