public function getModuleProfileName( $db = false ) {
if ( $db ) {
return 'API:' . $this->mModuleName . '-DB';
- } else {
- return 'API:' . $this->mModuleName;
}
+
+ return 'API:' . $this->mModuleName;
}
/**
}
return $msg;
- } else {
- return false;
}
+
+ return false;
}
/**
private function warnOrDie( $msg, $enforceLimits = false ) {
if ( $enforceLimits ) {
$this->dieUsage( $msg, 'integeroutofrange' );
- } else {
- $this->setWarning( $msg );
}
+
+ $this->setWarning( $msg );
}
/**
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'] );
}
/**
'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 );
}
$apiResult->addValue( null, $this->getModuleName(), $r );
return;
- } else {
- $this->dieUsageMsg( 'hookaborted' );
}
+
+ $this->dieUsageMsg( 'hookaborted' );
}
// Do the actual save
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();
}
}
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' );
}
}
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' );
}
}
public function isDefined( $moduleName, $group = null ) {
if ( isset( $this->mModules[$moduleName] ) ) {
return $group === null || $this->mModules[$moduleName][0] === $group;
- } else {
- return false;
}
+
+ return false;
}
/**
public function getModuleGroup( $moduleName ) {
if ( isset( $this->mModules[$moduleName] ) ) {
return $this->mModules[$moduleName][0];
- } else {
- return null;
}
+
+ return null;
}
/**
$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;
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 ) {
* @param $pageid
* @param $title
* @param $rc RecentChange (optional)
- * @return bool|String
+ * @return bool|string
*/
public static function getPatrolToken( $pageid, $title, $rc = null ) {
global $wgUser;
) {
$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;
}
/**
}
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() {
if ( $permission !== true ) {
if ( !$user->isLoggedIn() ) {
$this->dieUsageMsg( array( 'mustbeloggedin', 'upload' ) );
- } else {
- $this->dieUsageMsg( 'badaccess-groups' );
}
+
+ $this->dieUsageMsg( 'badaccess-groups' );
}
}
'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';
}