r91144 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91143‎ | r91144 | r91145 >
Date:23:46, 29 June 2011
Author:reedy
Status:ok
Tags:
Comment:
Fix trailing whitespace

Swap methods that call $this->getResult() to use temporary variable
Modified paths:
  • /trunk/extensions/MetricsReporting/ApiAnalyticsBase.php (modified) (history)
  • /trunk/phase3/includes/SiteStats.php (modified) (history)
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLogEvents.php (modified) (history)
  • /trunk/phase3/includes/api/ApiResult.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUpload.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUserrights.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SiteStats.php
@@ -377,7 +377,7 @@
378378 $this->mPages = $this->db->selectField( 'page', 'COUNT(*)', '', __METHOD__ );
379379 return $this->mPages;
380380 }
381 -
 381+
382382 /**
383383 * Count total users
384384 * @return Integer
@@ -386,7 +386,7 @@
387387 $this->mUsers = $this->db->selectField( 'user', 'COUNT(*)', '', __METHOD__ );
388388 return $this->mUsers;
389389 }
390 -
 390+
391391 /**
392392 * Count views
393393 * @return Integer
Index: trunk/phase3/includes/api/ApiUserrights.php
@@ -53,9 +53,10 @@
5454 $user, (array)$params['add'],
5555 (array)$params['remove'], $params['reason'] );
5656
57 - $this->getResult()->setIndexedTagName( $r['added'], 'group' );
58 - $this->getResult()->setIndexedTagName( $r['removed'], 'group' );
59 - $this->getResult()->addValue( null, $this->getModuleName(), $r );
 57+ $result = $this->getResult();
 58+ $result->setIndexedTagName( $r['added'], 'group' );
 59+ $result->setIndexedTagName( $r['removed'], 'group' );
 60+ $result->addValue( null, $this->getModuleName(), $r );
6061 }
6162
6263 /**
Index: trunk/phase3/includes/api/ApiResult.php
@@ -346,7 +346,6 @@
347347 global $wgContLang;
348348 $s = $wgContLang->normalize( $s );
349349 }
350 -
351350
352351 /**
353352 * Converts a Status object to an array suitable for addValue
@@ -358,7 +357,7 @@
359358 if ( $status->isGood() ) {
360359 return array();
361360 }
362 -
 361+
363362 $result = array();
364363 foreach ( $status->getErrorsByType( $errorType ) as $error ) {
365364 $this->setIndexedTagName( $error['params'], 'param' );
Index: trunk/phase3/includes/api/ApiQueryLogEvents.php
@@ -172,6 +172,7 @@
173173
174174 $count = 0;
175175 $res = $this->select( __METHOD__ );
 176+ $result = $this->getResult();
176177 foreach ( $res as $row ) {
177178 if ( ++ $count > $limit ) {
178179 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
@@ -183,13 +184,13 @@
184185 if ( !$vals ) {
185186 continue;
186187 }
187 - $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals );
 188+ $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
188189 if ( !$fit ) {
189190 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->log_timestamp ) );
190191 break;
191192 }
192193 }
193 - $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'item' );
 194+ $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'item' );
194195 }
195196
196197 /**
Index: trunk/phase3/includes/api/ApiQuery.php
@@ -601,8 +601,6 @@
602602 * @return string
603603 */
604604 public function makeHelpMsg() {
605 - $msg = '';
606 -
607605 // Make sure the internal object is empty
608606 // (just in case a sub-module decides to optimize during instantiation)
609607 $this->mPageSet = null;
@@ -610,7 +608,7 @@
611609
612610 $querySeparator = str_repeat( '--- ', 12 );
613611 $moduleSeparator = str_repeat( '*** ', 14 );
614 - $msg .= "\n$querySeparator Query: Prop $querySeparator\n\n";
 612+ $msg = "\n$querySeparator Query: Prop $querySeparator\n\n";
615613 $msg .= $this->makeHelpMsgHelper( $this->mQueryPropModules, 'prop' );
616614 $msg .= "\n$querySeparator Query: List $querySeparator\n\n";
617615 $msg .= $this->makeHelpMsgHelper( $this->mQueryListModules, 'list' );
Index: trunk/phase3/includes/api/ApiBase.php
@@ -181,7 +181,8 @@
182182 * @param $warning string Warning message
183183 */
184184 public function setWarning( $warning ) {
185 - $data = $this->getResult()->getData();
 185+ $result = $this->getResult();
 186+ $data = $result->getData();
186187 if ( isset( $data['warnings'][$this->getModuleName()] ) ) {
187188 // Don't add duplicate warnings
188189 $warn_regex = preg_quote( $warning, '/' );
@@ -191,13 +192,13 @@
192193 $oldwarning = $data['warnings'][$this->getModuleName()]['*'];
193194 // If there is a warning already, append it to the existing one
194195 $warning = "$oldwarning\n$warning";
195 - $this->getResult()->unsetValue( 'warnings', $this->getModuleName() );
 196+ $result->unsetValue( 'warnings', $this->getModuleName() );
196197 }
197198 $msg = array();
198199 ApiResult::setContent( $msg, $warning );
199 - $this->getResult()->disableSizeCheck();
200 - $this->getResult()->addValue( 'warnings', $this->getModuleName(), $msg );
201 - $this->getResult()->enableSizeCheck();
 200+ $result->disableSizeCheck();
 201+ $result->addValue( 'warnings', $this->getModuleName(), $msg );
 202+ $result->enableSizeCheck();
202203 }
203204
204205 /**
Index: trunk/phase3/includes/api/ApiUpload.php
@@ -146,11 +146,11 @@
147147 }
148148 return $sessionKey;
149149 }
150 -
 150+
151151 /**
152 - * Throw an error that the user can recover from by providing a better
 152+ * Throw an error that the user can recover from by providing a better
153153 * value for $parameter
154 - *
 154+ *
155155 * @param $error array Error array suitable for passing to dieUsageMsg()
156156 * @param $parameter string Parameter that needs revising
157157 * @param $data array Optional extra data to pass to the user
@@ -163,7 +163,7 @@
164164 $data['stashfailed'] = $e->getMessage();
165165 }
166166 $data['invalidparameter'] = $parameter;
167 -
 167+
168168 $parsed = $this->parseMsg( $error );
169169 $this->dieUsage( $parsed['info'], $parsed['code'], 0, $data );
170170 }
@@ -184,7 +184,7 @@
185185
186186 if ( $this->mParams['statuskey'] ) {
187187 $this->checkAsyncDownloadEnabled();
188 -
 188+
189189 // Status request for an async upload
190190 $sessionData = UploadFromUrlJob::getSessionData( $this->mParams['statuskey'] );
191191 if ( !isset( $sessionData['result'] ) ) {
@@ -231,7 +231,7 @@
232232 $async = false;
233233 if ( $this->mParams['asyncdownload'] ) {
234234 $this->checkAsyncDownloadEnabled();
235 -
 235+
236236 if ( $this->mParams['leavemessage'] && !$this->mParams['ignorewarnings'] ) {
237237 $this->dieUsage( 'Using leavemessage without ignorewarnings is not supported',
238238 'missing-ignorewarnings' );
@@ -286,7 +286,7 @@
287287 // Recoverable errors
288288 case UploadBase::MIN_LENGTH_PARTNAME:
289289 $this->dieRecoverableError( 'filename-tooshort', 'filename' );
290 - break;
 290+ break;
291291 case UploadBase::ILLEGAL_FILENAME:
292292 $this->dieRecoverableError( 'illegal-filename', 'filename',
293293 array( 'filename' => $verification['filtered'] ) );
@@ -297,7 +297,7 @@
298298 case UploadBase::WINDOWS_NONASCII_FILENAME:
299299 $this->dieRecoverableError( 'windows-nonascii-filename', 'filename' );
300300 break;
301 -
 301+
302302 // Unrecoverable errors
303303 case UploadBase::EMPTY_FILE:
304304 $this->dieUsage( 'The file you submitted was empty', 'empty-file' );
@@ -345,18 +345,19 @@
346346 }
347347 return $this->transformWarnings( $warnings );
348348 }
349 -
 349+
350350 protected function transformWarnings( $warnings ) {
351351 if ( $warnings ) {
352352 // Add indices
353 - $this->getResult()->setIndexedTagName( $warnings, 'warning' );
 353+ $result = $this->getResult();
 354+ $result->setIndexedTagName( $warnings, 'warning' );
354355
355356 if ( isset( $warnings['duplicate'] ) ) {
356357 $dupes = array();
357358 foreach ( $warnings['duplicate'] as $dupe ) {
358359 $dupes[] = $dupe->getName();
359360 }
360 - $this->getResult()->setIndexedTagName( $dupes, 'duplicate' );
 361+ $result->setIndexedTagName( $dupes, 'duplicate' );
361362 $warnings['duplicate'] = $dupes;
362363 }
363364
@@ -418,7 +419,7 @@
419420
420421 return $result;
421422 }
422 -
 423+
423424 /**
424425 * Checks if asynchronous copy uploads are enabled and throws an error if they are not.
425426 */
Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php
@@ -1,6 +1,6 @@
22 <?php
33
4 -abstract class ApiAnalyticsBase extends ApiBase/*ApiQueryBase*/ {
 4+abstract class ApiAnalyticsBase extends ApiBase {
55
66 protected $mDb;
77
@@ -32,6 +32,16 @@
3333
3434 $query = $this->getQueryInfo();
3535 $query['fields'] = $this->getQueryFields();
 36+
 37+ $db = $this->getDB();
 38+
 39+ $this->profileDBIn();
 40+ $res = $db->select( $query['table'], $query['fields'], $query['conds'], __METHOD__, $query['options'], $query['join_conds'] );
 41+ $this->profileDBOut();
 42+
 43+ foreach( $res as $row ) {
 44+
 45+ }
3646 }
3747
3848 protected abstract function getQueryInfo();
@@ -337,7 +347,6 @@
338348 'YE',
339349 'ZM',
340350 'ZW',
341 -
342351 ),
343352 ),
344353 'selectwebproperties' => array(

Status & tagging log