From: Siebrand Mazeland Date: Thu, 14 Nov 2013 13:01:41 +0000 (+0100) Subject: The light at the end of the API code format updating tunnel X-Git-Tag: 1.31.0-rc.0~18139^2 X-Git-Url: https://git.cyclocoop.org/?a=commitdiff_plain;h=d1c1724ee5778665a6a0d56a8ea77bdba56b4295;p=lhc%2Fweb%2Fwiklou.git The light at the end of the API code format updating tunnel Change-Id: I12fdb71bc87a8ad5ed5b9f1fe9c06bd0f7154e9a --- diff --git a/includes/api/ApiResult.php b/includes/api/ApiResult.php index 39c114b822..68137ff672 100644 --- a/includes/api/ApiResult.php +++ b/includes/api/ApiResult.php @@ -117,6 +117,7 @@ class ApiResult extends ApiBase { // Objects can't always be cast to string $s = strlen( $value ); } + return $s; } @@ -287,7 +288,8 @@ class ApiResult extends ApiBase { if ( $newsize > $wgAPIMaxResultSize ) { $this->setWarning( "This result was truncated because it would otherwise be larger than the " . - "limit of {$wgAPIMaxResultSize} bytes" ); + "limit of {$wgAPIMaxResultSize} bytes" ); + return false; } $this->mSize = $newsize; @@ -322,6 +324,7 @@ class ApiResult extends ApiBase { // Add named element self::setElement( $data, $name, $value, $flags ); } + return true; } @@ -394,6 +397,7 @@ class ApiResult extends ApiBase { $result[] = $error; } $this->setIndexedTagName( $result, $errorType ); + return $result; } diff --git a/includes/api/ApiRsd.php b/includes/api/ApiRsd.php index d219c91c4c..e01f0fa9ac 100644 --- a/includes/api/ApiRsd.php +++ b/includes/api/ApiRsd.php @@ -107,6 +107,7 @@ class ApiRsd extends ApiBase { ), ); wfRunHooks( 'ApiRsdServiceApis', array( &$apis ) ); + return $apis; } @@ -149,6 +150,7 @@ class ApiRsd extends ApiBase { } $outputData[] = $data; } + return $outputData; } } diff --git a/includes/api/ApiSetNotificationTimestamp.php b/includes/api/ApiSetNotificationTimestamp.php index 53a68fde84..5302896532 100644 --- a/includes/api/ApiSetNotificationTimestamp.php +++ b/includes/api/ApiSetNotificationTimestamp.php @@ -172,6 +172,7 @@ class ApiSetNotificationTimestamp extends ApiBase { if ( !isset( $this->mPageSet ) ) { $this->mPageSet = new ApiPageSet( $this ); } + return $this->mPageSet; } @@ -210,8 +211,8 @@ class ApiSetNotificationTimestamp extends ApiBase { if ( $flags ) { $result += $this->getPageSet()->getFinalParams( $flags ); } - return $result; + return $result; } public function getParamDescription() { @@ -271,6 +272,7 @@ class ApiSetNotificationTimestamp extends ApiBase { public function getPossibleErrors() { $ps = $this->getPageSet(); + return array_merge( parent::getPossibleErrors(), $ps->getFinalPossibleErrors(), diff --git a/includes/api/ApiTokens.php b/includes/api/ApiTokens.php index d220a5e6c4..6862668d9b 100644 --- a/includes/api/ApiTokens.php +++ b/includes/api/ApiTokens.php @@ -67,6 +67,7 @@ class ApiTokens extends ApiBase { wfRunHooks( 'ApiTokensGetTokenTypes', array( &$types ) ); ksort( $types ); wfProfileOut( __METHOD__ ); + return $types; } diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php index 6a739a2f34..78137a8652 100644 --- a/includes/api/ApiUnblock.php +++ b/includes/api/ApiUnblock.php @@ -96,6 +96,7 @@ class ApiUnblock extends ApiBase { public function getParamDescription() { $p = $this->getModulePrefix(); + return array( 'id' => "ID of the block you want to unblock (obtained through list=blocks). Cannot be used together with {$p}user", 'user' => "Username, IP address or IP range you want to unblock. Cannot be used together with {$p}id", diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 5839edc9a9..6d5861d585 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -141,6 +141,7 @@ class ApiUpload extends ApiBase { // Stash the file and get stash result return $this->getStashResult( $warnings ); } + // 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 ); @@ -165,6 +166,7 @@ class ApiUpload extends ApiBase { } catch ( MWException $e ) { $this->dieUsage( $e->getMessage(), 'stashfailed' ); } + return $result; } @@ -185,6 +187,7 @@ class ApiUpload extends ApiBase { } catch ( MWException $e ) { $result['warnings']['stashfailed'] = $e->getMessage(); } + return $result; } @@ -217,6 +220,7 @@ class ApiUpload extends ApiBase { $chunkPath, $chunkSize, $this->mParams['offset'] ); if ( !$status->isGood() ) { $this->dieUsage( $status->getWikiText(), 'stashfailed' ); + return array(); } } @@ -252,6 +256,7 @@ class ApiUpload extends ApiBase { $status = $this->mUpload->concatenateChunks(); if ( !$status->isGood() ) { $this->dieUsage( $status->getWikiText(), 'stashfailed' ); + return array(); } @@ -265,6 +270,7 @@ class ApiUpload extends ApiBase { } $result['filekey'] = $filekey; $result['offset'] = $this->mParams['offset'] + $chunkSize; + return $result; } @@ -287,6 +293,7 @@ class ApiUpload extends ApiBase { wfDebug( __METHOD__ . ' ' . $message . "\n" ); throw new MWException( $message ); } + return $fileKey; } @@ -341,6 +348,7 @@ class ApiUpload extends ApiBase { } unset( $progress['status'] ); // remove Status object $this->getResult()->addValue( null, $this->getModuleName(), $progress ); + return false; } @@ -357,6 +365,7 @@ class ApiUpload extends ApiBase { $sessionData['sessionkey'] = $this->mParams['statuskey']; } $this->getResult()->addValue( null, $this->getModuleName(), $sessionData ); + return false; } @@ -481,7 +490,7 @@ class ApiUpload extends ApiBase { break; case UploadBase::ILLEGAL_FILENAME: $this->dieRecoverableError( 'illegal-filename', 'filename', - array( 'filename' => $verification['filtered'] ) ); + array( 'filename' => $verification['filtered'] ) ); break; case UploadBase::FILENAME_TOO_LONG: $this->dieRecoverableError( 'filename-toolong', 'filename' ); @@ -521,15 +530,15 @@ class ApiUpload extends ApiBase { case UploadBase::VERIFICATION_ERROR: $this->getResult()->setIndexedTagName( $verification['details'], 'detail' ); $this->dieUsage( 'This file did not pass file verification', 'verification-error', - 0, array( 'details' => $verification['details'] ) ); + 0, array( 'details' => $verification['details'] ) ); break; case UploadBase::HOOK_ABORTED: $this->dieUsage( "The modification you tried to make was aborted by an extension hook", - 'hookaborted', 0, array( 'error' => $verification['error'] ) ); + 'hookaborted', 0, array( 'error' => $verification['error'] ) ); break; default: $this->dieUsage( 'An unknown error occurred', 'unknown-error', - 0, array( 'code' => $verification['status'] ) ); + 0, array( 'code' => $verification['status'] ) ); break; } } @@ -569,6 +578,7 @@ class ApiUpload extends ApiBase { $warnings[$warning['warning']] = $localFile->getName(); } } + return $warnings; } @@ -764,7 +774,6 @@ class ApiUpload extends ApiBase { ); return $params; - } public function getResultProperties() { diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php index 7d308285df..5e068cbdcc 100644 --- a/includes/api/ApiUserrights.php +++ b/includes/api/ApiUserrights.php @@ -72,6 +72,7 @@ class ApiUserrights extends ApiBase { } $this->mUser = $user; + return $user; }