r75647 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75646‎ | r75647 | r75648 >
Date:16:06, 29 October 2010
Author:reedy
Status:resolved
Tags:
Comment:
Fixup some while to foreach. Remove an unused global
Modified paths:
  • /trunk/extensions/AntiSpoof/SpoofUser.php (modified) (history)
  • /trunk/extensions/AntiSpoof/batchAntiSpoof.php (modified) (history)
  • /trunk/extensions/CentralAuth/migratePass0.php (modified) (history)
  • /trunk/extensions/CentralAuth/migratePass1.php (modified) (history)
  • /trunk/extensions/CentralAuth/migrateStewards.php (modified) (history)
  • /trunk/extensions/CheckUser/install.inc (modified) (history)
  • /trunk/extensions/CommunityVoice/Modules/Ratings.php (modified) (history)
  • /trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AntiSpoof/batchAntiSpoof.php
@@ -12,7 +12,7 @@
1313
1414 $result = $dbw->select( 'user', 'user_name', null, 'batchAntiSpoof.php' );
1515 $n = 0;
16 -while ( $row = $dbw->fetchObject( $result ) ) {
 16+foreach( $res as $row ) {
1717 if ( $n++ % $batchSize == 0 ) {
1818 echo "$wgDBname $n\n";
1919 }
Index: trunk/extensions/AntiSpoof/SpoofUser.php
@@ -59,7 +59,7 @@
6060 ) );
6161
6262 $spoofs = array();
63 - while ( $row = $dbr->fetchObject( $spoofedUsers ) ) {
 63+ foreach ( $spoofedUsers as $row ) {
6464 array_push( $spoofs, $row->user_name );
6565 }
6666 return $spoofs;
Index: trunk/extensions/CommunityVoice/Modules/Ratings.php
@@ -24,7 +24,7 @@
2525 'DISTINCT vot_category'
2626 );
2727 $categories = array();
28 - while ( $row = $result->fetchRow() ) {
 28+ foreach( $result as $row ) {
2929 $categories[] = (string)$row['vot_category'];
3030 }
3131 return $categories;
Index: trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php
@@ -84,7 +84,7 @@
8585 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
8686 __METHOD__ );
8787
88 - while ( $row = $dbr->fetchObject( $res ) ) {
 88+ foreach ( $res as $row ) {
8989 $linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title ));
9090 }
9191
@@ -94,8 +94,6 @@
9595 }
9696
9797 function getSQL() {
98 - global $wgContentNamespaces;
99 -
10098 $dbr = wfGetDB( DB_SLAVE );
10199 $page = $dbr->tableName( 'page' );
102100 $templatelinks = $dbr->tableName( 'templatelinks' );
Index: trunk/extensions/CentralAuth/migratePass0.php
@@ -29,7 +29,7 @@
3030 "user_id BETWEEN $min AND $max",
3131 __FUNCTION__ );
3232
33 - while ( $row = $dbr->fetchObject( $result ) ) {
 33+ foreach( $result as $row ) {
3434 $users[intval( $row->user_id )] = $row->user_name;
3535 ++$migrated;
3636 }
Index: trunk/extensions/CentralAuth/migratePass1.php
@@ -18,7 +18,7 @@
1919 array( 'gn_name' ),
2020 '',
2121 __METHOD__ );
22 - while ( $row = $dbBackground->fetchObject( $result ) ) {
 22+ foreach( $result as $row ) {
2323 $name = $row->gn_name;
2424 $central = new CentralAuthUser( $name );
2525 if ( $central->storeAndMigrate() ) {
Index: trunk/extensions/CentralAuth/migrateStewards.php
@@ -16,7 +16,7 @@
1717 'migrateStewards.php'
1818 );
1919 $localStewards = array();
20 -while ( $row = $dbl->fetchObject( $result ) ) {
 20+foreach ( $result as $row ) {
2121 $localStewards[] = $row->user_name;
2222 }
2323
@@ -33,7 +33,7 @@
3434 ),
3535 'migrateStewards.php'
3636 );
37 -while ( $row = $dbl->fetchObject( $result ) ) {
 37+foreach ( $result as $row ) {
3838 $globalStewards[$row->gu_name] = $row->gu_id;
3939 }
4040
Index: trunk/extensions/CheckUser/install.inc
@@ -43,7 +43,7 @@
4444 $cond = "rc_id BETWEEN $blockStart AND $blockEnd $cutoffCond";
4545 $res = $db->select( 'recentchanges', '*', $cond, __FUNCTION__ );
4646 $batch = array();
47 - while ( $row = $db->fetchObject( $res ) ) {
 47+ foreach ( $res as $row ) {
4848 $batch[] = array(
4949 'cuc_timestamp' => $row->rc_timestamp,
5050 'cuc_user' => $row->rc_user,

Follow-up revisions

RevisionCommit summaryAuthorDate
r81201followup r75647 typo in var namemah03:24, 30 January 2011

Status & tagging log