From 32fd68f81c2b7ff2477ca7cd885281ccb8f3d4d5 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sat, 12 Jan 2013 01:50:48 -0500 Subject: [PATCH] Minor cleanup Fixed spacing, eol chars, "string" --> 'string' Change-Id: I630247c6c5b469efb67ec9de32e8533ae88e59fb --- includes/api/ApiBase.php | 10 +++-- includes/api/ApiEditPage.php | 6 +-- includes/api/ApiFeedContributions.php | 2 +- includes/api/ApiFeedWatchlist.php | 2 +- includes/api/ApiMain.php | 6 +-- includes/api/ApiMove.php | 2 +- includes/api/ApiParse.php | 4 +- includes/api/ApiQueryAllLinks.php | 4 +- includes/api/ApiQueryAllMessages.php | 2 +- includes/api/ApiQueryBacklinks.php | 12 ++--- includes/api/ApiQueryCategoryMembers.php | 2 +- includes/api/ApiQueryImageInfo.php | 2 +- includes/api/ApiQueryInfo.php | 56 ++++++++++++------------ includes/api/ApiQueryLogEvents.php | 8 ++-- includes/api/ApiQuerySearch.php | 2 +- includes/api/ApiQueryUsers.php | 2 +- includes/api/ApiQueryWatchlist.php | 2 +- 17 files changed, 63 insertions(+), 61 deletions(-) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 1b176e7f1e..0a3edb99ad 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -340,13 +340,15 @@ abstract class ApiBase extends ContextSource { return ''; } if ( !is_array( $input ) ) { - $input = array( - $input - ); + $input = array( $input ); } if ( count( $input ) > 0 ) { - $msg = $title . ( count( $input ) > 1 ? 's' : '' ) . ":\n "; + if ( $title ) { + $msg = $title . ( count( $input ) > 1 ? 's' : '' ) . ":\n "; + } else { + $msg = ' '; + } $msg .= implode( $prefix, $input ) . "\n"; return $msg; } diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index cae4a21fb6..b1066ccb0a 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -68,12 +68,12 @@ class ApiEditPage extends ApiBase { $redirValues = array(); foreach ( $titles as $id => $newTitle ) { - if ( !isset( $titles[ $id - 1 ] ) ) { - $titles[ $id - 1 ] = $oldTitle; + if ( !isset( $titles[$id - 1] ) ) { + $titles[$id - 1] = $oldTitle; } $redirValues[] = array( - 'from' => $titles[ $id - 1 ]->getPrefixedText(), + 'from' => $titles[$id - 1]->getPrefixedText(), 'to' => $newTitle->getPrefixedText() ); diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index fb6a06ffcb..15a377c144 100644 --- a/includes/api/ApiFeedContributions.php +++ b/includes/api/ApiFeedContributions.php @@ -51,7 +51,7 @@ class ApiFeedContributions extends ApiBase { $this->dieUsage( 'Syndication feeds are not available', 'feed-unavailable' ); } - if( !isset( $wgFeedClasses[ $params['feedformat'] ] ) ) { + if( !isset( $wgFeedClasses[$params['feedformat']] ) ) { $this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' ); } diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index 6ccb02fe44..373abdb99b 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -62,7 +62,7 @@ class ApiFeedWatchlist extends ApiBase { $this->dieUsage( 'Syndication feeds are not available', 'feed-unavailable' ); } - if( !isset( $wgFeedClasses[ $params['feedformat'] ] ) ) { + if( !isset( $wgFeedClasses[$params['feedformat']] ) ) { $this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' ); } if ( !is_null( $params['wlexcludeuser'] ) ) { diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 135e0bdb0c..57ccc7a81b 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -876,7 +876,7 @@ class ApiMain extends ApiBase { if ( !$table ) { $chars = ';@$!*(),/:'; for ( $i = 0; $i < strlen( $chars ); $i++ ) { - $table[ rawurlencode( $chars[$i] ) ] = $chars[$i]; + $table[rawurlencode( $chars[$i] )] = $chars[$i]; } } return strtr( rawurlencode( $s ), $table ); @@ -1140,6 +1140,7 @@ class ApiMain extends ApiBase { foreach ( array_keys( $this->mModules ) as $moduleName ) { $module = new $this->mModules[$moduleName] ( $this, $moduleName ); $msg .= self::makeHelpMsgHeader( $module, 'action' ); + $msg2 = $module->makeHelpMsg(); if ( $msg2 !== false ) { $msg .= $msg2; @@ -1150,9 +1151,8 @@ class ApiMain extends ApiBase { $msg .= "\n$astriks Permissions $astriks\n\n"; foreach ( self::$mRights as $right => $rightMsg ) { $groups = User::getGroupsWithPermission( $right ); - $msg .= "* " . $right . " *\n " . wfMsgReplaceArgs( $rightMsg[ 'msg' ], $rightMsg[ 'params' ] ) . + $msg .= "* " . $right . " *\n " . wfMsgReplaceArgs( $rightMsg['msg'], $rightMsg['params'] ) . "\nGranted to:\n " . str_replace( '*', 'all', implode( ', ', $groups ) ) . "\n\n"; - } $msg .= "\n$astriks Formats $astriks\n\n"; diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 6c53e99e37..9b70b56de3 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -129,7 +129,7 @@ class ApiMove extends ApiBase { } } - $watch = "preferences"; + $watch = 'preferences'; if ( isset( $params['watchlist'] ) ) { $watch = $params['watchlist']; } elseif ( $params['watch'] ) { diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 08764a5b18..94b4a8b5db 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -450,14 +450,14 @@ class ApiParse extends ApiBase { $text = Language::fetchLanguageName( $nt->getInterwiki() ); $langs[] = Html::element( 'a', - array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ), + array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => 'external' ), $text == '' ? $l : $text ); } $s .= implode( wfMessage( 'pipe-separator' )->escaped(), $langs ); if ( $wgContLang->isRTL() ) { - $s = Html::rawElement( 'span', array( 'dir' => "LTR" ), $s ); + $s = Html::rawElement( 'span', array( 'dir' => 'LTR' ), $s ); } return $s; diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index b37dbbf16c..3b478b081a 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -159,7 +159,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { if ( $params['unique'] ) { $this->setContinueEnumParameter( 'continue', $row->pl_title ); } else { - $this->setContinueEnumParameter( 'continue', $row->pl_title . "|" . $row->pl_from ); + $this->setContinueEnumParameter( 'continue', $row->pl_title . '|' . $row->pl_from ); } break; } @@ -178,7 +178,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { if ( $params['unique'] ) { $this->setContinueEnumParameter( 'continue', $row->pl_title ); } else { - $this->setContinueEnumParameter( 'continue', $row->pl_title . "|" . $row->pl_from ); + $this->setContinueEnumParameter( 'continue', $row->pl_title . '|' . $row->pl_from ); } break; } diff --git a/includes/api/ApiQueryAllMessages.php b/includes/api/ApiQueryAllMessages.php index f5e1146b60..9fd2db8422 100644 --- a/includes/api/ApiQueryAllMessages.php +++ b/includes/api/ApiQueryAllMessages.php @@ -143,7 +143,7 @@ class ApiQueryAllMessages extends ApiQueryBase { } if ( $customiseFilterEnabled ) { - $messageIsCustomised = isset( $customisedMessages['pages'][ $langObj->ucfirst( $message ) ] ); + $messageIsCustomised = isset( $customisedMessages['pages'][$langObj->ucfirst( $message )] ); if ( $customised === $messageIsCustomised ) { if ( $customised ) { $a['customised'] = ''; diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 06db87bf18..6f45726b38 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -455,12 +455,12 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => 'namespace' ), - 'dir' => array( - ApiBase::PARAM_DFLT => 'ascending', - ApiBase::PARAM_TYPE => array( - 'ascending', - 'descending' - ) + 'dir' => array( + ApiBase::PARAM_DFLT => 'ascending', + ApiBase::PARAM_TYPE => array( + 'ascending', + 'descending' + ) ), 'filterredir' => array( ApiBase::PARAM_DFLT => 'all', diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index 55ce02345e..a07b049aa4 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -118,7 +118,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { // Add a WHERE clause for sortkey and from // pack( "H*", $foo ) is used to convert hex back to binary - $escSortkey = $this->getDB()->addQuotes( pack( "H*", $cont[1] ) ); + $escSortkey = $this->getDB()->addQuotes( pack( 'H*', $cont[1] ) ); $from = intval( $cont[2] ); $op = $dir == 'newer' ? '>' : '<'; // $contWhere is used further down diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 2be33931ce..0a0b5ddb0a 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -87,7 +87,7 @@ class ApiQueryImageInfo extends ApiQueryBase { } $start = $skip ? $fromTimestamp : $params['start']; - $pageId = $pageIds[NS_FILE][ $img->getTitle()->getDBkey() ]; + $pageId = $pageIds[NS_FILE][$img->getTitle()->getDBkey()]; $fit = $result->addValue( array( 'query', 'pages', intval( $pageId ) ), diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index e5cea96421..dd1326b4f0 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -118,11 +118,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens[ 'edit' ] ) ) { - ApiQueryInfo::$cachedTokens[ 'edit' ] = $wgUser->getEditToken(); + if ( !isset( ApiQueryInfo::$cachedTokens['edit'] ) ) { + ApiQueryInfo::$cachedTokens['edit'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens[ 'edit' ]; + return ApiQueryInfo::$cachedTokens['edit']; } public static function getDeleteToken( $pageid, $title ) { @@ -132,11 +132,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens[ 'delete' ] ) ) { - ApiQueryInfo::$cachedTokens[ 'delete' ] = $wgUser->getEditToken(); + if ( !isset( ApiQueryInfo::$cachedTokens['delete'] ) ) { + ApiQueryInfo::$cachedTokens['delete'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens[ 'delete' ]; + return ApiQueryInfo::$cachedTokens['delete']; } public static function getProtectToken( $pageid, $title ) { @@ -146,11 +146,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens[ 'protect' ] ) ) { - ApiQueryInfo::$cachedTokens[ 'protect' ] = $wgUser->getEditToken(); + if ( !isset( ApiQueryInfo::$cachedTokens['protect'] ) ) { + ApiQueryInfo::$cachedTokens['protect'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens[ 'protect' ]; + return ApiQueryInfo::$cachedTokens['protect']; } public static function getMoveToken( $pageid, $title ) { @@ -160,11 +160,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens[ 'move' ] ) ) { - ApiQueryInfo::$cachedTokens[ 'move' ] = $wgUser->getEditToken(); + if ( !isset( ApiQueryInfo::$cachedTokens['move'] ) ) { + ApiQueryInfo::$cachedTokens['move'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens[ 'move' ]; + return ApiQueryInfo::$cachedTokens['move']; } public static function getBlockToken( $pageid, $title ) { @@ -174,11 +174,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens[ 'block' ] ) ) { - ApiQueryInfo::$cachedTokens[ 'block' ] = $wgUser->getEditToken(); + if ( !isset( ApiQueryInfo::$cachedTokens['block'] ) ) { + ApiQueryInfo::$cachedTokens['block'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens[ 'block' ]; + return ApiQueryInfo::$cachedTokens['block']; } public static function getUnblockToken( $pageid, $title ) { @@ -193,11 +193,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens[ 'email' ] ) ) { - ApiQueryInfo::$cachedTokens[ 'email' ] = $wgUser->getEditToken(); + if ( !isset( ApiQueryInfo::$cachedTokens['email'] ) ) { + ApiQueryInfo::$cachedTokens['email'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens[ 'email' ]; + return ApiQueryInfo::$cachedTokens['email']; } public static function getImportToken( $pageid, $title ) { @@ -207,11 +207,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens[ 'import' ] ) ) { - ApiQueryInfo::$cachedTokens[ 'import' ] = $wgUser->getEditToken(); + if ( !isset( ApiQueryInfo::$cachedTokens['import'] ) ) { + ApiQueryInfo::$cachedTokens['import'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens[ 'import' ]; + return ApiQueryInfo::$cachedTokens['import']; } public static function getWatchToken( $pageid, $title ) { @@ -221,11 +221,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens[ 'watch' ] ) ) { - ApiQueryInfo::$cachedTokens[ 'watch' ] = $wgUser->getEditToken( 'watch' ); + if ( !isset( ApiQueryInfo::$cachedTokens['watch'] ) ) { + ApiQueryInfo::$cachedTokens['watch'] = $wgUser->getEditToken( 'watch' ); } - return ApiQueryInfo::$cachedTokens[ 'watch' ]; + return ApiQueryInfo::$cachedTokens['watch']; } public static function getOptionsToken( $pageid, $title ) { @@ -235,11 +235,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens[ 'options' ] ) ) { - ApiQueryInfo::$cachedTokens[ 'options' ] = $wgUser->getEditToken(); + if ( !isset( ApiQueryInfo::$cachedTokens['options'] ) ) { + ApiQueryInfo::$cachedTokens['options'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens[ 'options' ]; + return ApiQueryInfo::$cachedTokens['options']; } public function execute() { @@ -349,7 +349,7 @@ class ApiQueryInfo extends ApiQueryBase { $pageInfo['touched'] = wfTimestamp( TS_ISO_8601, $this->pageTouched[$pageid] ); $pageInfo['lastrevid'] = intval( $this->pageLatest[$pageid] ); $pageInfo['counter'] = $wgDisableCounters - ? "" + ? '' : intval( $this->pageCounter[$pageid] ); $pageInfo['length'] = intval( $this->pageLength[$pageid] ); diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index caed635256..b2eebfb00d 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -70,7 +70,7 @@ class ApiQueryLogEvents extends ApiQueryBase { 'user' => array( 'JOIN', 'user_id=log_user' ), 'page' => array( 'LEFT JOIN', - array( 'log_namespace=page_namespace', + array( 'log_namespace=page_namespace', 'log_title=page_title' ) ) ) ); $index = array( 'logging' => 'times' ); // default, may change @@ -209,15 +209,15 @@ class ApiQueryLogEvents extends ApiQueryBase { $noredirKey = '5::noredir'; } - if ( isset( $params[ $targetKey ] ) ) { - $title = Title::newFromText( $params[ $targetKey ] ); + if ( isset( $params[$targetKey] ) ) { + $title = Title::newFromText( $params[$targetKey] ); if ( $title ) { $vals2 = array(); ApiQueryBase::addTitleInfo( $vals2, $title, 'new_' ); $vals[$type] = $vals2; } } - if ( isset( $params[ $noredirKey ] ) && $params[ $noredirKey ] ) { + if ( isset( $params[$noredirKey] ) && $params[$noredirKey] ) { $vals[$type]['suppressedredirect'] = ''; } $params = null; diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index cfd08a88a2..a0a0fbe05f 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -168,7 +168,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { } } if ( isset( $prop['hasrelated'] ) && $result->hasRelated() ) { - $vals['hasrelated'] = ""; + $vals['hasrelated'] = ''; } // Add item to results and see whether it fits diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index edcbc1a439..e5690184a0 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -124,7 +124,7 @@ class ApiQueryUsers extends ApiQueryBase { $this->addWhereFld( 'user_name', $goodNames ); $this->addTables( 'user_groups' ); $this->addJoinConds( array( 'user_groups' => array( 'INNER JOIN', 'ug_user=user_id' ) ) ); - $this->addFields( array('user_name', 'ug_group') ); + $this->addFields( array( 'user_name', 'ug_group' ) ); $userGroupsRes = $this->select( __METHOD__ ); foreach( $userGroupsRes as $row ) { diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index a1a337281f..22d98b7755 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -116,7 +116,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { ) ); $userId = $user->getId(); - $this->addJoinConds( array( 'watchlist' => array('INNER JOIN', + $this->addJoinConds( array( 'watchlist' => array( 'INNER JOIN', array( 'wl_user' => $userId, 'wl_namespace=rc_namespace', -- 2.20.1