r61442 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61441‎ | r61442 | r61443 >
Date:22:47, 23 January 2010
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
More of r61437 (adding/removing whitespace)
Modified paths:
  • /trunk/phase3/includes/api/ApiParamInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)
  • /trunk/phase3/includes/api/ApiProtect.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllmessages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllpages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBacklinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryProtectedTitles.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRecentChanges.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryTags.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php
@@ -149,17 +149,20 @@
150150 $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
151151 $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
152152 $this->addWhereIf( 'page_is_redirect = 1', isset ( $show['redirect'] ) );
 153+
153154 // Don't throw log entries out the window here
154155 $this->addWhereIf( 'page_is_redirect = 0 OR page_is_redirect IS NULL', isset ( $show['!redirect'] ) );
155156 }
156157
157158 if ( !is_null( $params['user'] ) && !is_null( $param['excludeuser'] ) )
158159 $this->dieUsage( 'user and excludeuser cannot be used together', 'user-excludeuser' );
 160+
159161 if ( !is_null( $params['user'] ) )
160162 {
161163 $this->addWhereFld( 'rc_user_text', $params['user'] );
162164 $index = 'rc_user_text';
163165 }
 166+
164167 if ( !is_null( $params['excludeuser'] ) )
165168 // We don't use the rc_user_text index here because
166169 // * it would require us to sort by rc_user_text before rc_timestamp
@@ -284,12 +287,23 @@
285288
286289 /* Determine what kind of change this was. */
287290 switch ( $type ) {
288 - case RC_EDIT: $vals['type'] = 'edit'; break;
289 - case RC_NEW: $vals['type'] = 'new'; break;
290 - case RC_MOVE: $vals['type'] = 'move'; break;
291 - case RC_LOG: $vals['type'] = 'log'; break;
292 - case RC_MOVE_OVER_REDIRECT: $vals['type'] = 'move over redirect'; break;
293 - default: $vals['type'] = $type;
 291+ case RC_EDIT:
 292+ $vals['type'] = 'edit';
 293+ break;
 294+ case RC_NEW:
 295+ $vals['type'] = 'new';
 296+ break;
 297+ case RC_MOVE:
 298+ $vals['type'] = 'move';
 299+ break;
 300+ case RC_LOG:
 301+ $vals['type'] = 'log';
 302+ break;
 303+ case RC_MOVE_OVER_REDIRECT:
 304+ $vals['type'] = 'move over redirect';
 305+ break;
 306+ default:
 307+ $vals['type'] = $type;
294308 }
295309
296310 /* Create a new entry in the result for the title. */
Index: trunk/phase3/includes/api/ApiQueryLinks.php
@@ -110,6 +110,7 @@
111111 $order[] = "{$this->prefix}_from";
112112 if ( count( $params['namespace'] ) != 1 )
113113 $order[] = "{$this->prefix}_namespace";
 114+
114115 $order[] = "{$this->prefix}_title";
115116 $this->addOption( 'ORDER BY', implode( ", ", $order ) );
116117 $this->addOption( 'USE INDEX', "{$this->prefix}_from" );
@@ -141,7 +142,6 @@
142143 }
143144 }
144145 } else {
145 -
146146 $titles = array();
147147 $count = 0;
148148 while ( $row = $db->fetchObject( $res ) ) {
Index: trunk/phase3/includes/api/ApiParse.php
@@ -66,6 +66,7 @@
6767 $this->dieUsage( "There is no revision ID $oldid", 'missingrev' );
6868 if ( !$rev->userCan( Revision::DELETED_TEXT ) )
6969 $this->dieUsage( "You don't have permission to view deleted revisions", 'permissiondenied' );
 70+
7071 $text = $rev->getText( Revision::FOR_THIS_USER );
7172 $titleObj = $rev->getTitle();
7273 $wgTitle = $titleObj;
Index: trunk/phase3/includes/api/ApiQueryAllpages.php
@@ -51,7 +51,6 @@
5252 }
5353
5454 private function run( $resultPageSet = null ) {
55 -
5655 $db = $this->getDB();
5756
5857 $params = $this->extractRequestParams();
Index: trunk/phase3/includes/api/ApiProtect.php
@@ -78,10 +78,12 @@
7979 {
8080 $p = explode( '=', $prot );
8181 $protections[$p[0]] = ( $p[1] == 'all' ? '' : $p[1] );
 82+
8283 if ( $titleObj->exists() && $p[0] == 'create' )
8384 $this->dieUsageMsg( array( 'create-titleexists' ) );
8485 if ( !$titleObj->exists() && $p[0] != 'create' )
8586 $this->dieUsageMsg( array( 'missingtitle-createonly' ) );
 87+
8688 if ( !in_array( $p[0], $restrictionTypes ) && $p[0] != 'create' )
8789 $this->dieUsageMsg( array( 'protect-invalidaction', $p[0] ) );
8890 if ( !in_array( $p[1], $wgRestrictionLevels ) && $p[1] != 'all' )
Index: trunk/phase3/includes/api/ApiQueryBacklinks.php
@@ -109,11 +109,14 @@
110110 $this->addFields( array( 'page_id', 'page_title', 'page_namespace' ) );
111111 else
112112 $this->addFields( $resultPageSet->getPageTableFields() );
 113+
113114 $this->addFields( 'page_is_redirect' );
114115 $this->addWhereFld( $this->bl_title, $this->rootTitle->getDBkey() );
 116+
115117 if ( $this->hasNS )
116118 $this->addWhereFld( $this->bl_ns, $this->rootTitle->getNamespace() );
117119 $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
 120+
118121 if ( !is_null( $this->contID ) )
119122 $this->addWhere( "{$this->bl_from}>={$this->contID}" );
120123
@@ -136,13 +139,16 @@
137140 $db = $this->getDB();
138141 $this->addTables( array( 'page', $this->bl_table ) );
139142 $this->addWhere( "{$this->bl_from}=page_id" );
 143+
140144 if ( is_null( $resultPageSet ) )
141145 $this->addFields( array( 'page_id', 'page_title', 'page_namespace', 'page_is_redirect' ) );
142146 else
143147 $this->addFields( $resultPageSet->getPageTableFields() );
 148+
144149 $this->addFields( $this->bl_title );
145150 if ( $this->hasNS )
146151 $this->addFields( $this->bl_ns );
 152+
147153 // We can't use LinkBatch here because $this->hasNS may be false
148154 $titleWhere = array();
149155 foreach ( $this->redirTitles as $t )
@@ -150,6 +156,7 @@
151157 ( $this->hasNS ? " AND {$this->bl_ns} = '{$t->getNamespace()}'" : "" );
152158 $this->addWhere( $db->makeList( $titleWhere, LIST_OR ) );
153159 $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
 160+
154161 if ( !is_null( $this->redirID ) )
155162 {
156163 $first = $this->redirTitles[0];
@@ -172,6 +179,7 @@
173180 $this->addWhereFld( 'page_is_redirect', 1 );
174181 else if ( $this->params['filterredir'] == 'nonredirects' )
175182 $this->addWhereFld( 'page_is_redirect', 0 );
 183+
176184 $this->addOption( 'LIMIT', $this->params['limit'] + 1 );
177185 $this->addOption( 'ORDER BY', $this->bl_sort );
178186 $this->addOption( 'USE INDEX', array( 'page' => 'PRIMARY' ) );
@@ -356,13 +364,16 @@
357365 // Illegal continue parameter
358366 $this->dieUsage( "Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue" );
359367 $this->rootTitle = Title::makeTitleSafe( $rootNs, $continueList[1] );
 368+
360369 if ( !$this->rootTitle )
361370 $this->dieUsage( "Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue" );
362371 $contID = intval( $continueList[2] );
 372+
363373 if ( $contID === 0 && $continueList[2] !== '0' )
364374 $this->dieUsage( "Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue" );
365375 $this->contID = $contID;
366376 $redirID = intval( @$continueList[3] );
 377+
367378 if ( $redirID === 0 && @$continueList[3] !== '0' )
368379 // This one isn't required
369380 return;
Index: trunk/phase3/includes/api/ApiQueryBase.php
@@ -226,7 +226,6 @@
227227 * @return ResultWrapper
228228 */
229229 protected function select( $method ) {
230 -
231230 // getDB has its own profileDBIn/Out calls
232231 $db = $this->getDB();
233232
Index: trunk/phase3/includes/api/ApiQueryAllmessages.php
@@ -77,9 +77,9 @@
7878 $result = $this->getResult();
7979 foreach ( $messages_target as $message ) {
8080 // Skip all messages up to $params['from']
81 - if ( $skip && $message === $params['from'] )
 81+ if ( $skip && $message === $params['from'] ) {
8282 $skip = false;
83 - if ( !$skip ) {
 83+
8484 $a = array( 'name' => $message );
8585 $msg = wfMsgGetKey( $message, true, false, false );
8686 if ( wfEmptyMsg( $message, $msg ) )
Index: trunk/phase3/includes/api/ApiQueryProtectedTitles.php
@@ -91,12 +91,16 @@
9292 ApiQueryBase::addTitleInfo( $vals, $title );
9393 if ( isset( $prop['timestamp'] ) )
9494 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->pt_timestamp );
 95+
9596 if ( isset( $prop['user'] ) && !is_null( $row->user_name ) )
9697 $vals['user'] = $row->user_name;
 98+
9799 if ( isset( $prop['comment'] ) )
98100 $vals['comment'] = $row->pt_reason;
 101+
99102 if ( isset( $prop['expiry'] ) )
100103 $vals['expiry'] = Block::decodeExpiry( $row->pt_expiry, TS_ISO_8601 );
 104+
101105 if ( isset( $prop['level'] ) )
102106 $vals['level'] = $row->pt_create_perm;
103107
Index: trunk/phase3/includes/api/ApiQuery.php
@@ -197,22 +197,16 @@
198198 $this->params = $this->extractRequestParams();
199199 $this->redirects = $this->params['redirects'];
200200
201 - //
202201 // Create PageSet
203 - //
204202 $this->mPageSet = new ApiPageSet( $this, $this->redirects );
205203
206 - //
207204 // Instantiate requested modules
208 - //
209205 $modules = array ();
210206 $this->InstantiateModules( $modules, 'prop', $this->mQueryPropModules );
211207 $this->InstantiateModules( $modules, 'list', $this->mQueryListModules );
212208 $this->InstantiateModules( $modules, 'meta', $this->mQueryMetaModules );
213209
214 - //
215210 // If given, execute generator to substitute user supplied data with generated data.
216 - //
217211 if ( isset ( $this->params['generator'] ) ) {
218212 $this->executeGeneratorModule( $this->params['generator'], $modules );
219213 } else {
@@ -221,14 +215,10 @@
222216 $this->mPageSet->execute();
223217 }
224218
225 - //
226219 // Record page information (title, namespace, if exists, etc)
227 - //
228220 $this->outputGeneralPageInfo();
229221
230 - //
231222 // Execute all requested modules.
232 - //
233223 foreach ( $modules as $module ) {
234224 $module->profileIn();
235225 $module->execute();
@@ -391,6 +381,7 @@
392382 $exporter->closeStream();
393383 $exportxml = ob_get_contents();
394384 ob_end_clean();
 385+
395386 // Don't check the size of exported stuff
396387 // It's not continuable, so it would cause more
397388 // problems than it'd solve
Index: trunk/phase3/includes/api/ApiParamInfo.php
@@ -147,9 +147,11 @@
148148 ApiBase::LIMIT_SML2 :
149149 ApiBase::LIMIT_SML1;
150150 }
 151+
151152 if ( isset( $p[ApiBase::PARAM_ALLOW_DUPLICATES] ) )
152153 if ( $p[ApiBase::PARAM_ALLOW_DUPLICATES] )
153154 $a['allowsduplicates'] = '';
 155+
154156 if ( isset( $p[ApiBase::PARAM_TYPE] ) )
155157 {
156158 $a['type'] = $p[ApiBase::PARAM_TYPE];
Index: trunk/phase3/includes/api/ApiQueryInfo.php
@@ -305,12 +305,16 @@
306306 $this->protections[$title->getNamespace()][$title->getDBkey()];
307307 $this->getResult()->setIndexedTagName( $pageInfo['protection'], 'pr' );
308308 }
 309+
309310 if ( $this->fld_watched && isset( $this->watched[$title->getNamespace()][$title->getDBkey()] ) )
310311 $pageInfo['watched'] = '';
 312+
311313 if ( $this->fld_talkid && isset( $this->talkids[$title->getNamespace()][$title->getDBkey()] ) )
312314 $pageInfo['talkid'] = $this->talkids[$title->getNamespace()][$title->getDBkey()];
 315+
313316 if ( $this->fld_subjectid && isset( $this->subjectids[$title->getNamespace()][$title->getDBkey()] ) )
314317 $pageInfo['subjectid'] = $this->subjectids[$title->getNamespace()][$title->getDBkey()];
 318+
315319 if ( $this->fld_url ) {
316320 $pageInfo['fullurl'] = $title->getFullURL();
317321 $pageInfo['editurl'] = $title->getFullURL( 'action=edit' );
Index: trunk/phase3/includes/api/ApiQueryTags.php
@@ -172,6 +172,6 @@
173173 }
174174
175175 public function getVersion() {
176 - return __CLASS__ . ': $Id: ApiQueryTags.php';
 176+ return __CLASS__ . ': $Id$';
177177 }
178178 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r61445Properly fix r61436/r61442reedy22:58, 23 January 2010
r61651Fix careless errors in r61442 and r61444.tstarling00:51, 29 January 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61437Add/remove whitelines to increase readability in API code filesreedy22:26, 23 January 2010

Comments

#Comment by Tim Starling (talk | contribs)   00:34, 29 January 2010

It doesn't look like whitespace to me. It looks like you broke ApiQueryAllmessages.php, changing the conditions under which the code block will be run, is_null( $params['from'] ) instead of !is_null( $params['from'] ).

Please review svn diff before every commit, and write a commit message that corresponds with what you see.

Status & tagging log