jenkins-bot has submitted this change and it was merged.
Change subject: Remove unneeded uses of else{} in api/
......................................................................
Remove unneeded uses of else{} in api/
Fixed a little documentation issue, removed a line of unreachable code
and fixed up two formatting issues in the process.
Change-Id: If29391ee1a0daf19973437f36c3216b8716debd0
---
M includes/api/ApiBase.php
M includes/api/ApiComparePages.php
M includes/api/ApiEditPage.php
M includes/api/ApiFormatJson.php
M includes/api/ApiMain.php
M includes/api/ApiModuleManager.php
M includes/api/ApiMove.php
M includes/api/ApiParse.php
M includes/api/ApiQueryRecentChanges.php
M includes/api/ApiQueryUsers.php
M includes/api/ApiUpload.php
11 files changed, 66 insertions(+), 75 deletions(-)
Approvals:
Chad: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 47fb687..b6a7ca8 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -177,9 +177,9 @@
public function getModuleProfileName( $db = false ) {
if ( $db ) {
return 'API:' . $this->mModuleName . '-DB';
- } else {
- return 'API:' . $this->mModuleName;
}
+
+ return 'API:' . $this->mModuleName;
}
/**
@@ -530,9 +530,9 @@
}
return $msg;
- } else {
- return false;
}
+
+ return false;
}
/**
@@ -1297,9 +1297,9 @@
private function warnOrDie( $msg, $enforceLimits = false ) {
if ( $enforceLimits ) {
$this->dieUsage( $msg, 'integeroutofrange' );
- } else {
- $this->setWarning( $msg );
}
+
+ $this->setWarning( $msg );
}
/**
@@ -1902,14 +1902,14 @@
global $wgDebugAPI;
if ( $wgDebugAPI !== true ) {
$this->dieUsageMsg( $error );
- } else {
- if ( is_string( $error ) ) {
- $error = array( $error );
- }
- $parsed = $this->parseMsg( $error );
- $this->setWarning( '$wgDebugAPI: ' . $parsed['code']
- . ' - ' . $parsed['info'] );
}
+
+ if ( is_string( $error ) ) {
+ $error = array( $error );
+ }
+
+ $parsed = $this->parseMsg( $error );
+ $this->setWarning( '$wgDebugAPI: ' . $parsed['code'] . ' - ' .
$parsed['info'] );
}
/**
diff --git a/includes/api/ApiComparePages.php b/includes/api/ApiComparePages.php
index 1049b49..237e8c8 100644
--- a/includes/api/ApiComparePages.php
+++ b/includes/api/ApiComparePages.php
@@ -70,10 +70,10 @@
'not exist or you do not have
permission to view them.',
'baddiff'
);
- } else {
- ApiResult::setContent( $vals, $difftext );
}
+ ApiResult::setContent( $vals, $difftext );
+
$this->getResult()->addValue( null, $this->getModuleName(),
$vals );
}
diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php
index 4e1c871..73eebca 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -381,9 +381,9 @@
$apiResult->addValue( null,
$this->getModuleName(), $r );
return;
- } else {
- $this->dieUsageMsg( 'hookaborted' );
}
+
+ $this->dieUsageMsg( 'hookaborted' );
}
// Do the actual save
diff --git a/includes/api/ApiFormatJson.php b/includes/api/ApiFormatJson.php
index 15dc73b..be0b58b 100644
--- a/includes/api/ApiFormatJson.php
+++ b/includes/api/ApiFormatJson.php
@@ -91,8 +91,8 @@
public function getDescription() {
if ( $this->mIsRaw ) {
return 'Output data with the debugging elements in JSON
format' . parent::getDescription();
- } else {
- return 'Output data in JSON format' .
parent::getDescription();
}
+
+ return 'Output data in JSON format' . parent::getDescription();
}
}
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index 9ecae8d..85f24b6 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -741,12 +741,10 @@
if ( $salt !== false ) {
if ( !isset( $moduleParams['token'] ) ) {
$this->dieUsageMsg( array( 'missingparam',
'token' ) );
- } else {
- if ( !$this->getUser()
- ->matchEditToken(
$moduleParams['token'], $salt, $this->getContext()->getRequest() )
- ) {
- $this->dieUsageMsg( 'sessionfailure' );
- }
+ }
+
+ if ( !$this->getUser()->matchEditToken(
$moduleParams['token'], $salt, $this->getContext()->getRequest() ) ) {
+ $this->dieUsageMsg( 'sessionfailure' );
}
}
@@ -773,11 +771,9 @@
if ( $wgShowHostnames ) {
$this->dieUsage( "Waiting for $host:
$lag seconds lagged", 'maxlag' );
- } else {
- $this->dieUsage( "Waiting for a
database server: $lag seconds lagged", 'maxlag' );
}
- return false;
+ $this->dieUsage( "Waiting for a database
server: $lag seconds lagged", 'maxlag' );
}
}
diff --git a/includes/api/ApiModuleManager.php
b/includes/api/ApiModuleManager.php
index 407e089..c33e18c 100644
--- a/includes/api/ApiModuleManager.php
+++ b/includes/api/ApiModuleManager.php
@@ -146,9 +146,9 @@
public function isDefined( $moduleName, $group = null ) {
if ( isset( $this->mModules[$moduleName] ) ) {
return $group === null ||
$this->mModules[$moduleName][0] === $group;
- } else {
- return false;
}
+
+ return false;
}
/**
@@ -159,9 +159,9 @@
public function getModuleGroup( $moduleName ) {
if ( isset( $this->mModules[$moduleName] ) ) {
return $this->mModules[$moduleName][0];
- } else {
- return null;
}
+
+ return null;
}
/**
diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php
index 5d5d1b7..20ac48a 100644
--- a/includes/api/ApiMove.php
+++ b/includes/api/ApiMove.php
@@ -157,19 +157,19 @@
$success = $fromTitle->moveSubpages( $toTitle, true, $reason,
!$noredirect );
if ( isset( $success[0] ) ) {
return array( 'error' => $this->parseMsg( $success ) );
- } else {
- // At least some pages could be moved
- // Report each of them separately
- foreach ( $success as $oldTitle => $newTitle ) {
- $r = array( 'from' => $oldTitle );
- if ( is_array( $newTitle ) ) {
- $r['error'] = $this->parseMsg( reset(
$newTitle ) );
- } else {
- // Success
- $r['to'] = $newTitle;
- }
- $retval[] = $r;
+ }
+
+ // At least some pages could be moved
+ // Report each of them separately
+ foreach ( $success as $oldTitle => $newTitle ) {
+ $r = array( 'from' => $oldTitle );
+ if ( is_array( $newTitle ) ) {
+ $r['error'] = $this->parseMsg( reset( $newTitle
) );
+ } else {
+ // Success
+ $r['to'] = $newTitle;
}
+ $retval[] = $r;
}
return $retval;
diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index 3ce5da2..ddc032d 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -425,23 +425,24 @@
if ( $this->section !== false && $this->content !== null ) {
$this->content = $this->getSectionContent(
$this->content,
- !is_null( $pageId ) ? 'page id ' . $pageId :
$page->getTitle()->getText() );
+ !is_null( $pageId ) ? 'page id ' . $pageId :
$page->getTitle()->getText()
+ );
// Not cached (save or load)
return $this->content->getParserOutput(
$page->getTitle(), null, $popts );
- } else {
- // Try the parser cache first
- // getParserOutput will save to Parser cache if able
- $pout = $page->getParserOutput( $popts );
- if ( !$pout ) {
- $this->dieUsage( "There is no revision ID
{$page->getLatest()}", 'missingrev' );
- }
- if ( $getWikitext ) {
- $this->content = $page->getContent(
Revision::RAW );
- }
-
- return $pout;
}
+
+ // Try the parser cache first
+ // getParserOutput will save to Parser cache if able
+ $pout = $page->getParserOutput( $popts );
+ if ( !$pout ) {
+ $this->dieUsage( "There is no revision ID
{$page->getLatest()}", 'missingrev' );
+ }
+ if ( $getWikitext ) {
+ $this->content = $page->getContent( Revision::RAW );
+ }
+
+ return $pout;
}
private function getSectionContent( Content $content, $what ) {
diff --git a/includes/api/ApiQueryRecentChanges.php
b/includes/api/ApiQueryRecentChanges.php
index 50a3352..b44565e 100644
--- a/includes/api/ApiQueryRecentChanges.php
+++ b/includes/api/ApiQueryRecentChanges.php
@@ -72,7 +72,7 @@
* @param $pageid
* @param $title
* @param $rc RecentChange (optional)
- * @return bool|String
+ * @return bool|string
*/
public static function getPatrolToken( $pageid, $title, $rc = null ) {
global $wgUser;
@@ -85,23 +85,22 @@
) {
$validTokenUser = true;
}
- } else {
- if ( $wgUser->useRCPatrol() || $wgUser->useNPPatrol() )
{
- $validTokenUser = true;
- }
+ } elseif ( $wgUser->useRCPatrol() || $wgUser->useNPPatrol() ) {
+ $validTokenUser = true;
}
if ( $validTokenUser ) {
// The patrol token is always the same, let's exploit
that
static $cachedPatrolToken = null;
+
if ( is_null( $cachedPatrolToken ) ) {
$cachedPatrolToken = $wgUser->getEditToken(
'patrol' );
}
return $cachedPatrolToken;
- } else {
- return false;
}
+
+ return false;
}
/**
diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php
index f22140a..cd4a8fc 100644
--- a/includes/api/ApiQueryUsers.php
+++ b/includes/api/ApiQueryUsers.php
@@ -271,11 +271,7 @@
}
public function getCacheMode( $params ) {
- if ( isset( $params['token'] ) ) {
- return 'private';
- } else {
- return 'anon-public-user-private';
- }
+ return isset( $params['token'] ) ? 'private' :
'anon-public-user-private';
}
public function getAllowedParams() {
diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php
index 01e0f6e..1a642b9 100644
--- a/includes/api/ApiUpload.php
+++ b/includes/api/ApiUpload.php
@@ -458,9 +458,9 @@
if ( $permission !== true ) {
if ( !$user->isLoggedIn() ) {
$this->dieUsageMsg( array( 'mustbeloggedin',
'upload' ) );
- } else {
- $this->dieUsageMsg( 'badaccess-groups' );
}
+
+ $this->dieUsageMsg( 'badaccess-groups' );
}
}
@@ -661,11 +661,10 @@
'result' => 'Queued',
'statuskey' => $error[0][1],
);
- } else {
- $this->getResult()->setIndexedTagName(
$error, 'error' );
-
- $this->dieUsage( 'An internal error
occurred', 'internal-error', 0, $error );
}
+
+ $this->getResult()->setIndexedTagName( $error,
'error' );
+ $this->dieUsage( 'An internal error occurred',
'internal-error', 0, $error );
}
$result['result'] = 'Success';
}
--
To view, visit https://gerrit.wikimedia.org/r/95887
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If29391ee1a0daf19973437f36c3216b8716debd0
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: IAlex <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits