From 8edf4a2d92f2c93aff3a18363b175e969c057274 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Wed, 29 Jun 2011 23:46:39 +0000 Subject: [PATCH] Fix trailing whitespace Swap methods that call $this->getResult() to use temporary variable --- includes/SiteStats.php | 4 ++-- includes/api/ApiBase.php | 11 ++++++----- includes/api/ApiQuery.php | 4 +--- includes/api/ApiQueryLogEvents.php | 5 +++-- includes/api/ApiResult.php | 3 +-- includes/api/ApiUpload.php | 25 +++++++++++++------------ includes/api/ApiUserrights.php | 7 ++++--- 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/includes/SiteStats.php b/includes/SiteStats.php index 9041757cd3..d61d4fc7df 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -377,7 +377,7 @@ class SiteStatsInit { $this->mPages = $this->db->selectField( 'page', 'COUNT(*)', '', __METHOD__ ); return $this->mPages; } - + /** * Count total users * @return Integer @@ -386,7 +386,7 @@ class SiteStatsInit { $this->mUsers = $this->db->selectField( 'user', 'COUNT(*)', '', __METHOD__ ); return $this->mUsers; } - + /** * Count views * @return Integer diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 3884428130..c10aeedc27 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -181,7 +181,8 @@ abstract class ApiBase { * @param $warning string Warning message */ public function setWarning( $warning ) { - $data = $this->getResult()->getData(); + $result = $this->getResult(); + $data = $result->getData(); if ( isset( $data['warnings'][$this->getModuleName()] ) ) { // Don't add duplicate warnings $warn_regex = preg_quote( $warning, '/' ); @@ -191,13 +192,13 @@ abstract class ApiBase { $oldwarning = $data['warnings'][$this->getModuleName()]['*']; // If there is a warning already, append it to the existing one $warning = "$oldwarning\n$warning"; - $this->getResult()->unsetValue( 'warnings', $this->getModuleName() ); + $result->unsetValue( 'warnings', $this->getModuleName() ); } $msg = array(); ApiResult::setContent( $msg, $warning ); - $this->getResult()->disableSizeCheck(); - $this->getResult()->addValue( 'warnings', $this->getModuleName(), $msg ); - $this->getResult()->enableSizeCheck(); + $result->disableSizeCheck(); + $result->addValue( 'warnings', $this->getModuleName(), $msg ); + $result->enableSizeCheck(); } /** diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index fedc847102..844b66e61e 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -601,8 +601,6 @@ class ApiQuery extends ApiBase { * @return string */ public function makeHelpMsg() { - $msg = ''; - // Make sure the internal object is empty // (just in case a sub-module decides to optimize during instantiation) $this->mPageSet = null; @@ -610,7 +608,7 @@ class ApiQuery extends ApiBase { $querySeparator = str_repeat( '--- ', 12 ); $moduleSeparator = str_repeat( '*** ', 14 ); - $msg .= "\n$querySeparator Query: Prop $querySeparator\n\n"; + $msg = "\n$querySeparator Query: Prop $querySeparator\n\n"; $msg .= $this->makeHelpMsgHelper( $this->mQueryPropModules, 'prop' ); $msg .= "\n$querySeparator Query: List $querySeparator\n\n"; $msg .= $this->makeHelpMsgHelper( $this->mQueryListModules, 'list' ); diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index e051c8345a..913dbddad2 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -172,6 +172,7 @@ class ApiQueryLogEvents extends ApiQueryBase { $count = 0; $res = $this->select( __METHOD__ ); + $result = $this->getResult(); foreach ( $res as $row ) { if ( ++ $count > $limit ) { // We've reached the one extra which shows that there are additional pages to be had. Stop here... @@ -183,13 +184,13 @@ class ApiQueryLogEvents extends ApiQueryBase { if ( !$vals ) { continue; } - $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals ); + $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals ); if ( !$fit ) { $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->log_timestamp ) ); break; } } - $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'item' ); + $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'item' ); } /** diff --git a/includes/api/ApiResult.php b/includes/api/ApiResult.php index 5100973332..a8ca6046ea 100644 --- a/includes/api/ApiResult.php +++ b/includes/api/ApiResult.php @@ -346,7 +346,6 @@ class ApiResult extends ApiBase { global $wgContLang; $s = $wgContLang->normalize( $s ); } - /** * Converts a Status object to an array suitable for addValue @@ -358,7 +357,7 @@ class ApiResult extends ApiBase { if ( $status->isGood() ) { return array(); } - + $result = array(); foreach ( $status->getErrorsByType( $errorType ) as $error ) { $this->setIndexedTagName( $error['params'], 'param' ); diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index c123bac42a..8b302e4eff 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -146,11 +146,11 @@ class ApiUpload extends ApiBase { } return $sessionKey; } - + /** - * Throw an error that the user can recover from by providing a better + * Throw an error that the user can recover from by providing a better * value for $parameter - * + * * @param $error array Error array suitable for passing to dieUsageMsg() * @param $parameter string Parameter that needs revising * @param $data array Optional extra data to pass to the user @@ -163,7 +163,7 @@ class ApiUpload extends ApiBase { $data['stashfailed'] = $e->getMessage(); } $data['invalidparameter'] = $parameter; - + $parsed = $this->parseMsg( $error ); $this->dieUsage( $parsed['info'], $parsed['code'], 0, $data ); } @@ -184,7 +184,7 @@ class ApiUpload extends ApiBase { if ( $this->mParams['statuskey'] ) { $this->checkAsyncDownloadEnabled(); - + // Status request for an async upload $sessionData = UploadFromUrlJob::getSessionData( $this->mParams['statuskey'] ); if ( !isset( $sessionData['result'] ) ) { @@ -231,7 +231,7 @@ class ApiUpload extends ApiBase { $async = false; if ( $this->mParams['asyncdownload'] ) { $this->checkAsyncDownloadEnabled(); - + if ( $this->mParams['leavemessage'] && !$this->mParams['ignorewarnings'] ) { $this->dieUsage( 'Using leavemessage without ignorewarnings is not supported', 'missing-ignorewarnings' ); @@ -286,7 +286,7 @@ class ApiUpload extends ApiBase { // Recoverable errors case UploadBase::MIN_LENGTH_PARTNAME: $this->dieRecoverableError( 'filename-tooshort', 'filename' ); - break; + break; case UploadBase::ILLEGAL_FILENAME: $this->dieRecoverableError( 'illegal-filename', 'filename', array( 'filename' => $verification['filtered'] ) ); @@ -297,7 +297,7 @@ class ApiUpload extends ApiBase { case UploadBase::WINDOWS_NONASCII_FILENAME: $this->dieRecoverableError( 'windows-nonascii-filename', 'filename' ); break; - + // Unrecoverable errors case UploadBase::EMPTY_FILE: $this->dieUsage( 'The file you submitted was empty', 'empty-file' ); @@ -345,18 +345,19 @@ class ApiUpload extends ApiBase { } return $this->transformWarnings( $warnings ); } - + protected function transformWarnings( $warnings ) { if ( $warnings ) { // Add indices - $this->getResult()->setIndexedTagName( $warnings, 'warning' ); + $result = $this->getResult(); + $result->setIndexedTagName( $warnings, 'warning' ); if ( isset( $warnings['duplicate'] ) ) { $dupes = array(); foreach ( $warnings['duplicate'] as $dupe ) { $dupes[] = $dupe->getName(); } - $this->getResult()->setIndexedTagName( $dupes, 'duplicate' ); + $result->setIndexedTagName( $dupes, 'duplicate' ); $warnings['duplicate'] = $dupes; } @@ -418,7 +419,7 @@ class ApiUpload extends ApiBase { return $result; } - + /** * Checks if asynchronous copy uploads are enabled and throws an error if they are not. */ diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php index f0aeebf612..60853a1c09 100644 --- a/includes/api/ApiUserrights.php +++ b/includes/api/ApiUserrights.php @@ -53,9 +53,10 @@ class ApiUserrights extends ApiBase { $user, (array)$params['add'], (array)$params['remove'], $params['reason'] ); - $this->getResult()->setIndexedTagName( $r['added'], 'group' ); - $this->getResult()->setIndexedTagName( $r['removed'], 'group' ); - $this->getResult()->addValue( null, $this->getModuleName(), $r ); + $result = $this->getResult(); + $result->setIndexedTagName( $r['added'], 'group' ); + $result->setIndexedTagName( $r['removed'], 'group' ); + $result->addValue( null, $this->getModuleName(), $r ); } /** -- 2.20.1