r55204 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55203‎ | r55204 | r55205 >
Date:21:15, 17 August 2009
Author:ialex
Status:deferred (Comments)
Tags:
Comment:
* batch change for "while ( $row = $db->fetchObject( $res ) )" and similar to "foreach ( $res as $row )"
* identation fix in nukeNS.php
Modified paths:
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)
  • /trunk/phase3/maintenance/attachLatest.php (modified) (history)
  • /trunk/phase3/maintenance/checkUsernames.php (modified) (history)
  • /trunk/phase3/maintenance/clear_interwiki_cache.php (modified) (history)
  • /trunk/phase3/maintenance/convertUserOptions.php (modified) (history)
  • /trunk/phase3/maintenance/deleteArchivedFiles.php (modified) (history)
  • /trunk/phase3/maintenance/deleteDefaultMessages.php (modified) (history)
  • /trunk/phase3/maintenance/deleteImageMemcached.php (modified) (history)
  • /trunk/phase3/maintenance/deleteOldRevisions.php (modified) (history)
  • /trunk/phase3/maintenance/deleteOrphanedRevisions.php (modified) (history)
  • /trunk/phase3/maintenance/dumpLinks.php (modified) (history)
  • /trunk/phase3/maintenance/dumpSisterSites.php (modified) (history)
  • /trunk/phase3/maintenance/fixSlaveDesync.php (modified) (history)
  • /trunk/phase3/maintenance/fixTimestamps.php (modified) (history)
  • /trunk/phase3/maintenance/fixUserRegistration.php (modified) (history)
  • /trunk/phase3/maintenance/generateSitemap.php (modified) (history)
  • /trunk/phase3/maintenance/initEditCount.php (modified) (history)
  • /trunk/phase3/maintenance/namespaceDupes.php (modified) (history)
  • /trunk/phase3/maintenance/nukeNS.php (modified) (history)
  • /trunk/phase3/maintenance/nukePage.php (modified) (history)
  • /trunk/phase3/maintenance/orphans.php (modified) (history)
  • /trunk/phase3/maintenance/populateLogSearch.php (modified) (history)
  • /trunk/phase3/maintenance/populateLogUsertext.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildFileCache.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildrecentchanges.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildtextindex.php (modified) (history)
  • /trunk/phase3/maintenance/refreshLinks.php (modified) (history)
  • /trunk/phase3/maintenance/removeUnusedAccounts.php (modified) (history)
  • /trunk/phase3/maintenance/sql.php (modified) (history)
  • /trunk/phase3/maintenance/updateRestrictions.php (modified) (history)
  • /trunk/phase3/maintenance/updateSearchIndex.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/updateRestrictions.php
@@ -54,7 +54,7 @@
5555 $cond = "page_id BETWEEN $blockStart AND $blockEnd AND page_restrictions !=''";
5656 $res = $db->select( 'page', array('page_id','page_namespace','page_restrictions'), $cond, __METHOD__ );
5757 $batch = array();
58 - while( $row = $db->fetchObject( $res ) ) {
 58+ foreach( $res as $row ) {
5959 $oldRestrictions = array();
6060 foreach( explode( ':', trim( $row->page_restrictions ) ) as $restrict ) {
6161 $temp = explode( '=', trim( $restrict ) );
Index: trunk/phase3/maintenance/deleteDefaultMessages.php
@@ -54,7 +54,7 @@
5555
5656 $dbw = wfGetDB( DB_MASTER );
5757
58 - while ( $row = $dbr->fetchObject( $res ) ) {
 58+ foreach ( $res as $row ) {
5959 if ( function_exists( 'wfWaitForSlaves' ) ) {
6060 wfWaitForSlaves( 5 );
6161 }
Index: trunk/phase3/maintenance/refreshLinks.php
@@ -91,7 +91,7 @@
9292 $num = $dbr->numRows( $res );
9393 $this->output( "Refreshing $num old redirects from $start...\n" );
9494
95 - while( $row = $dbr->fetchObject( $res ) ) {
 95+ foreach( $res as $row ) {
9696 if ( !( ++$i % $reportingInterval ) ) {
9797 $this->output( "$i\n" );
9898 wfWaitForSlaves( $maxLag );
@@ -111,7 +111,7 @@
112112 $this->output( "$num new articles...\n" );
113113
114114 $i = 0;
115 - while ( $row = $dbr->fetchObject( $res ) ) {
 115+ foreach ( $res as $row ) {
116116 if ( !( ++$i % $reportingInterval ) ) {
117117 $this->output( "$i\n" );
118118 wfWaitForSlaves( $maxLag );
Index: trunk/phase3/maintenance/deleteOldRevisions.php
@@ -62,7 +62,7 @@
6363 # Get "active" revisions from the page table
6464 $this->output( "Searching for active revisions..." );
6565 $res = $dbw->query( "SELECT page_latest FROM $tbl_pag{$pageIdClause}" );
66 - while( $row = $dbw->fetchObject( $res ) ) {
 66+ foreach( $res as $row ) {
6767 $cur[] = $row->page_latest;
6868 }
6969 $this->output( "done.\n" );
@@ -71,7 +71,7 @@
7272 $this->output( "Searching for inactive revisions..." );
7373 $set = implode( ', ', $cur );
7474 $res = $dbw->query( "SELECT rev_id FROM $tbl_rev WHERE rev_id NOT IN ( $set ){$revPageClause}" );
75 - while( $row = $dbw->fetchObject( $res ) ) {
 75+ foreach( $res as $row ) {
7676 $old[] = $row->rev_id;
7777 }
7878 $this->output( "done.\n" );
Index: trunk/phase3/maintenance/removeUnusedAccounts.php
@@ -51,7 +51,7 @@
5252 $this->error( "Please put a valid positive integer on the --ignore-touched parameter.", true );
5353 }
5454 $touchedSeconds = 86400 * $touched;
55 - while( $row = $dbr->fetchObject( $res ) ) {
 55+ foreach( $res as $row ) {
5656 # Check the account, but ignore it if it's within a $excludedGroups group or if it's touched within the $touchedSeconds seconds.
5757 $instance = User::newFromId( $row->user_id );
5858 if( count( array_intersect( $instance->getEffectiveGroups(), $excludedGroups ) ) == 0
Index: trunk/phase3/maintenance/fixTimestamps.php
@@ -69,7 +69,7 @@
7070 $badRevs = array();
7171 $numGoodRevs = 0;
7272
73 - while ( $row = $dbw->fetchObject( $res ) ) {
 73+ foreach ( $res as $row ) {
7474 $timestamp = wfTimestamp( TS_UNIX, $row->rev_timestamp );
7575 $delta = $timestamp - $lastNormal;
7676 $sign = $delta == 0 ? 0 : $delta / abs( $delta );
Index: trunk/phase3/maintenance/namespaceDupes.php
@@ -137,7 +137,7 @@
138138 private function getInterwikiList() {
139139 $result = $this->db->select( 'interwiki', array( 'iw_prefix' ) );
140140 $prefixes = array();
141 - while( $row = $this->db->fetchObject( $result ) ) {
 141+ foreach( $result as $row ) {
142142 $prefixes[] = $row->iw_prefix;
143143 }
144144 $this->db->freeResult( $result );
@@ -216,7 +216,7 @@
217217 $result = $this->db->query( $sql, __METHOD__ );
218218
219219 $set = array();
220 - while( $row = $this->db->fetchObject( $result ) ) {
 220+ foreach( $result as $row ) {
221221 $set[] = $row;
222222 }
223223 $this->db->freeResult( $result );
Index: trunk/phase3/maintenance/nukePage.php
@@ -56,7 +56,7 @@
5757 # Get corresponding revisions
5858 $this->output( "Searching for revisions..." );
5959 $res = $dbw->query( "SELECT rev_id FROM $tbl_rev WHERE rev_page = $id" );
60 - while( $row = $dbw->fetchObject( $res ) ) {
 60+ foreach( $res as $row ) {
6161 $revs[] = $row->rev_id;
6262 }
6363 $count = count( $revs );
Index: trunk/phase3/maintenance/generateSitemap.php
@@ -214,7 +214,7 @@
215215 )
216216 );
217217
218 - while ( $row = $this->dbr->fetchObject( $res ) )
 218+ foreach ( $res as $row )
219219 $this->namespaces[] = $row->page_namespace;
220220 }
221221
@@ -281,7 +281,7 @@
282282
283283 $fns = $wgContLang->getFormattedNsText( $namespace );
284284 $this->output( "$namespace ($fns)" );
285 - while ( $row = $this->dbr->fetchObject( $res ) ) {
 285+ foreach ( $res as $row ) {
286286 if ( $i++ === 0 || $i === $this->url_limit + 1 || $length + $this->limit[1] + $this->limit[2] > $this->size_limit ) {
287287 if ( $this->file !== false ) {
288288 $this->write( $this->file, $this->closeFile() );
Index: trunk/phase3/maintenance/fixSlaveDesync.php
@@ -62,7 +62,7 @@
6363 $masterIDs = array();
6464 $res = $dbw->select( 'page', array( 'page_id', 'page_latest' ), array( 'page_id<6054123' ), __METHOD__ );
6565 $this->output( "Number of pages: " . $dbw->numRows( $res ) . "\n" );
66 - while ( $row = $dbw->fetchObject( $res ) ) {
 66+ foreach ( $res as $row ) {
6767 $masterIDs[$row->page_id] = $row->page_latest;
6868 if ( !( ++$n % 10000 ) ) {
6969 $this->output( "$n\r" );
@@ -75,7 +75,7 @@
7676 foreach ( $slaveIndexes as $i ) {
7777 $db = wfGetDB( $i );
7878 $res = $db->select( 'page', array( 'page_id', 'page_latest' ), array( 'page_id<6054123' ), __METHOD__ );
79 - while ( $row = $db->fetchObject( $res ) ) {
 79+ foreach ( $res as $row ) {
8080 if ( isset( $masterIDs[$row->page_id] ) && $masterIDs[$row->page_id] != $row->page_latest ) {
8181 $desync[$row->page_id] = true;
8282 $this->output( $row->page_id . "\t" );
@@ -128,14 +128,14 @@
129129 $res = $dbw->select( 'revision', array( 'rev_id' ), array( 'rev_page' => $pageID ),
130130 __METHOD__, 'FOR UPDATE' );
131131 $masterIDs = array();
132 - while ( $row = $dbw->fetchObject( $res ) ) {
 132+ foreach ( $res as $row ) {
133133 $masterIDs[] = $row->rev_id;
134134 }
135135 $dbw->freeResult( $res );
136136
137137 $res = $db->select( 'revision', array( 'rev_id' ), array( 'rev_page' => $pageID ), __METHOD__ );
138138 $slaveIDs = array();
139 - while ( $row = $db->fetchObject( $res ) ) {
 139+ foreach ( $res as $row ) {
140140 $slaveIDs[] = $row->rev_id;
141141 }
142142 $db->freeResult( $res );
Index: trunk/phase3/maintenance/fixUserRegistration.php
@@ -35,7 +35,7 @@
3636
3737 // Get user IDs which need fixing
3838 $res = $dbr->select( 'user', 'user_id', 'user_registration IS NULL', __METHOD__ );
39 - while ( $row = $dbr->fetchObject( $res ) ) {
 39+ foreach ( $res as $row ) {
4040 $id = $row->user_id;
4141 // Get first edit time
4242 $timestamp = $dbr->selectField( 'revision', 'MIN(rev_timestamp)', array( 'rev_user' => $id ), __METHOD__ );
Index: trunk/phase3/maintenance/populateLogSearch.php
@@ -53,7 +53,7 @@
5454 $cond = "log_id BETWEEN $blockStart AND $blockEnd";
5555 $res = $db->select( 'logging', '*', $cond, __FUNCTION__ );
5656 $batch = array();
57 - while( $row = $db->fetchObject( $res ) ) {
 57+ foreach( $res as $row ) {
5858 // RevisionDelete logs - revisions
5959 if( LogEventsList::typeAction( $row, array('delete','suppress'), 'revision' ) ) {
6060 $params = LogPage::extractParams( $row->log_params );
Index: trunk/phase3/maintenance/initEditCount.php
@@ -73,7 +73,7 @@
7474 GROUP BY user_id",
7575 __METHOD__ );
7676
77 - while( $row = $dbr->fetchObject( $result ) ) {
 77+ foreach( $result as $row ) {
7878 $dbw->update( 'user',
7979 array( 'user_editcount' => $row->user_editcount ),
8080 array( 'user_id' => $row->user_id ),
Index: trunk/phase3/maintenance/deleteImageMemcached.php
@@ -52,7 +52,7 @@
5353 $i = 0;
5454 $total = $this->getImageCount();
5555
56 - while ( $row = $dbr->fetchObject( $res ) ) {
 56+ foreach ( $res as $row ) {
5757 if ($i % $this->report == 0)
5858 $this->output( sprintf("%s: %13s done (%s)\n", wfWikiID(), "$i/$total", wfPercent( $i / $total * 100 ) ) );
5959 $md5 = md5( $row->img_name );
Index: trunk/phase3/maintenance/dumpSisterSites.php
@@ -42,7 +42,7 @@
4343 ),
4444 __METHOD__ );
4545
46 - while( $row = $dbr->fetchObject( $result ) ) {
 46+ foreach( $result as $row ) {
4747 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
4848 $url = $title->getFullUrl();
4949 $text = $title->getPrefixedText();
Index: trunk/phase3/maintenance/Maintenance.php
@@ -671,7 +671,7 @@
672672 # Get "active" text records from the revisions table
673673 $this->output( "Searching for active text records in revisions table..." );
674674 $res = $dbw->query( "SELECT DISTINCT rev_text_id FROM $tbl_rev" );
675 - while( $row = $dbw->fetchObject( $res ) ) {
 675+ foreach( $res as $row ) {
676676 $cur[] = $row->rev_text_id;
677677 }
678678 $this->output( "done.\n" );
@@ -679,7 +679,7 @@
680680 # Get "active" text records from the archive table
681681 $this->output( "Searching for active text records in archive table..." );
682682 $res = $dbw->query( "SELECT DISTINCT ar_text_id FROM $tbl_arc" );
683 - while( $row = $dbw->fetchObject( $res ) ) {
 683+ foreach( $res as $row ) {
684684 $cur[] = $row->ar_text_id;
685685 }
686686 $this->output( "done.\n" );
@@ -689,7 +689,7 @@
690690 $set = implode( ', ', $cur );
691691 $res = $dbw->query( "SELECT old_id FROM $tbl_txt WHERE old_id NOT IN ( $set )" );
692692 $old = array();
693 - while( $row = $dbw->fetchObject( $res ) ) {
 693+ foreach( $res as $row ) {
694694 $old[] = $row->old_id;
695695 }
696696 $this->output( "done.\n" );
Index: trunk/phase3/maintenance/rebuildtextindex.php
@@ -95,7 +95,7 @@
9696 AND rev_text_id=old_id";
9797 $res = $database->query($sql, "rebuildTextIndex" );
9898
99 - while( $s = $database->fetchObject($res) ) {
 99+ foreach( $res as $s ) {
100100 $revtext = Revision::getRevisionText( $s );
101101 $u = new SearchUpdate( $s->page_id, $s->page_title, $revtext );
102102 $u->doUpdate();
Index: trunk/phase3/maintenance/nukeNS.php
@@ -55,24 +55,24 @@
5656
5757 $n_deleted = 0;
5858
59 - while( $row = $dbw->fetchObject( $res ) ) {
 59+ foreach( $res as $row ) {
6060 //echo "$ns_name:".$row->page_title, "\n";
61 - $title = Title::newFromText($row->page_title, $ns);
 61+ $title = Title::makeTitle( $ns, $row->page_title );
6262 $id = $title->getArticleID();
6363
6464 // Get corresponding revisions
6565 $res2 = $dbw->query( "SELECT rev_id FROM $tbl_rev WHERE rev_page = $id" );
6666 $revs = array();
6767
68 - while( $row2 = $dbw->fetchObject( $res2 ) ) {
 68+ foreach( $res2 as $row2 ) {
6969 $revs[] = $row2->rev_id;
7070 }
7171 $count = count( $revs );
7272
7373 //skip anything that looks modified (i.e. multiple revs)
74 - if (($count == 1)) {
 74+ if ( $count == 1 ) {
7575 #echo $title->getPrefixedText(), "\t", $count, "\n";
76 - $this->output( "delete: ", $title->getPrefixedText(), "\n" );
 76+ $this->output( "delete: " . $title->getPrefixedText() . "\n" );
7777
7878 //as much as I hate to cut & paste this, it's a little different, and
7979 //I already have the id & revs
@@ -86,23 +86,25 @@
8787 $n_deleted ++;
8888 }
8989 } else {
90 - $this->output( "skip: ", $title->getPrefixedText(), "\n" );
 90+ $this->output( "skip: " . $title->getPrefixedText() . "\n" );
9191 }
9292 }
9393 $dbw->commit();
9494
95 - if ($n_deleted > 0) {
96 - #update statistics - better to decrement existing count, or just count
97 - #the page table?
98 - $pages = $dbw->selectField('site_stats', 'ss_total_pages');
99 - $pages -= $n_deleted;
100 - $dbw->update( 'site_stats',
101 - array('ss_total_pages' => $pages ),
102 - array( 'ss_row_id' => 1),
103 - __METHOD__ );
 95+ if ( $n_deleted > 0 ) {
 96+ #update statistics - better to decrement existing count, or just count
 97+ #the page table?
 98+ $pages = $dbw->selectField( 'site_stats', 'ss_total_pages' );
 99+ $pages -= $n_deleted;
 100+ $dbw->update(
 101+ 'site_stats',
 102+ array( 'ss_total_pages' => $pages ),
 103+ array( 'ss_row_id' => 1 ),
 104+ __METHOD__
 105+ );
104106 }
105107
106 - if (!$delete) {
 108+ if ( !$delete ) {
107109 $this->output( "To update the database, run the script with the --delete option.\n" );
108110 }
109111 }
Index: trunk/phase3/maintenance/orphans.php
@@ -84,7 +84,7 @@
8585 global $wgContLang;
8686 $this->output( "$orphans orphan revisions...\n" );
8787 $this->output( sprintf( "%10s %10s %14s %20s %s\n", 'rev_id', 'rev_page', 'rev_timestamp', 'rev_user_text', 'rev_comment' ) );
88 - while( $row = $dbw->fetchObject( $result ) ) {
 88+ foreach( $result as $row ) {
8989 $comment = ( $row->rev_comment == '' )
9090 ? ''
9191 : '(' . $wgContLang->truncate( $row->rev_comment, 40 ) . ')';
@@ -136,7 +136,7 @@
137137 global $wgContLang;
138138 $this->output( "$widows childless pages...\n" );
139139 $this->output( sprintf( "%10s %11s %2s %s\n", 'page_id', 'page_latest', 'ns', 'page_title' ) );
140 - while( $row = $dbw->fetchObject( $result ) ) {
 140+ foreach( $result as $row ) {
141141 printf( "%10d %11d %2d %s\n",
142142 $row->page_id,
143143 $row->page_latest,
@@ -178,7 +178,7 @@
179179 FROM $page LEFT OUTER JOIN $revision ON page_latest=rev_id
180180 ");
181181 $found = 0;
182 - while( $row = $dbw->fetchObject( $result ) ) {
 182+ foreach( $result as $row ) {
183183 $result2 = $dbw->query( "
184184 SELECT MAX(rev_timestamp) as max_timestamp
185185 FROM $revision
Index: trunk/phase3/maintenance/convertUserOptions.php
@@ -55,7 +55,7 @@
5656
5757 function convertOptionBatch( $res, $dbw ) {
5858 $id = null;
59 - while ($row = $dbw->fetchObject( $res ) ) {
 59+ foreach ( $res as $row ) {
6060 $this->mConversionCount++;
6161
6262 $u = User::newFromRow( $row );
Index: trunk/phase3/maintenance/populateLogUsertext.php
@@ -52,7 +52,7 @@
5353 array('log_id','user_name'), $cond, __METHOD__ );
5454 $batch = array();
5555 $db->begin();
56 - while( $row = $db->fetchObject( $res ) ) {
 56+ foreach( $res as $row ) {
5757 $db->update( 'logging', array('log_user_text' => $row->user_name),
5858 array('log_id' => $row->log_id), __METHOD__ );
5959 }
Index: trunk/phase3/maintenance/updateSearchIndex.php
@@ -99,7 +99,7 @@
100100 }
101101
102102 # Loop through the results and do a search update
103 - while ( $row = $dbw->fetchObject( $res ) ) {
 103+ foreach ( $res as $row ) {
104104 # Allow reads to be processed
105105 if ( $maxLockTime && time() > $lockTime + $maxLockTime ) {
106106 $this->output( " --- Relocking ---" );
Index: trunk/phase3/maintenance/dumpLinks.php
@@ -51,7 +51,7 @@
5252 array( 'ORDER BY' => 'page_id' ) );
5353
5454 $lastPage = null;
55 - while( $row = $dbr->fetchObject( $result ) ) {
 55+ foreach( $result as $row ) {
5656 if( $lastPage != $row->page_id ) {
5757 if( isset( $lastPage ) ) {
5858 $this->output( "\n" );
Index: trunk/phase3/maintenance/deleteOrphanedRevisions.php
@@ -49,7 +49,7 @@
5050
5151 # Stash 'em all up for deletion (if needed)
5252 $revisions = array();
53 - while( $row = $dbw->fetchObject( $res ) )
 53+ foreach( $res as $row )
5454 $revisions[] = $row->rev_id;
5555 $dbw->freeResult( $res );
5656 $count = count( $revisions );
Index: trunk/phase3/maintenance/deleteArchivedFiles.php
@@ -50,7 +50,7 @@
5151 $this->output( "Searching for and deleting archived files...\n" );
5252 $res = $dbw->query( "SELECT fa_id,fa_storage_group,fa_storage_key FROM $tbl_arch" );
5353 $count = 0;
54 - while( $row = $dbw->fetchObject( $res ) ) {
 54+ foreach( $res as $row ) {
5555 $key = $row->fa_storage_key;
5656 $group = $row->fa_storage_group;
5757 $id = $row->fa_id;
Index: trunk/phase3/maintenance/clear_interwiki_cache.php
@@ -35,7 +35,7 @@
3636 $dbr = wfGetDB( DB_SLAVE );
3737 $res = $dbr->select( 'interwiki', array( 'iw_prefix' ), false );
3838 $prefixes = array();
39 - while ( $row = $dbr->fetchObject( $res ) ) {
 39+ foreach ( $res as $row ) {
4040 $prefixes[] = $row->iw_prefix;
4141 }
4242
Index: trunk/phase3/maintenance/sql.php
@@ -61,7 +61,7 @@
6262 if ( !$res ) {
6363 // Do nothing
6464 } elseif ( is_object( $res ) && $res->numRows() ) {
65 - while ( $row = $res->fetchObject() ) {
 65+ foreach ( $res as $row ) {
6666 $this->output( print_r( $row, true ) );
6767 }
6868 } else {
Index: trunk/phase3/maintenance/checkUsernames.php
@@ -41,7 +41,7 @@
4242 __METHOD__
4343 );
4444
45 - while ( $row = $dbr->fetchObject( $res ) ) {
 45+ foreach ( $res as $row ) {
4646 if ( ! User::isValidUserName( $row->user_name ) ) {
4747 $this->error( sprintf( "%s: %6d: '%s'\n", wfWikiID(), $row->user_id, $row->user_name ) );
4848 wfDebugLog( 'checkUsernames', $out );
Index: trunk/phase3/maintenance/rebuildFileCache.php
@@ -70,7 +70,7 @@
7171 "page_id BETWEEN $blockStart AND $blockEnd" ),
7272 array('ORDER BY' => 'page_id ASC','USE INDEX' => 'PRIMARY')
7373 );
74 - while( $row = $dbr->fetchObject( $res ) ) {
 74+ foreach( $res as $row ) {
7575 $rebuilt = false;
7676 $wgTitle = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
7777 if( null == $wgTitle ) {
Index: trunk/phase3/maintenance/rebuildrecentchanges.php
@@ -106,7 +106,7 @@
107107
108108 $lastCurId = 0;
109109 $lastOldId = 0;
110 - while ( $obj = $dbw->fetchObject( $res ) ) {
 110+ foreach ( $res as $obj ) {
111111 $new = 0;
112112 if( $obj->rc_cur_id != $lastCurId ) {
113113 # Switch! Look up the previous last edit, if any
@@ -233,7 +233,7 @@
234234 "WHERE ug_group IN($botwhere) AND user_id = ug_user";
235235 $res = $dbw->query( $sql, DB_MASTER );
236236
237 - while( $obj = $dbw->fetchObject( $res ) ) {
 237+ foreach( $res as $obj ) {
238238 $botusers[] = $dbw->addQuotes( $obj->user_name );
239239 }
240240 # Fill in the rc_bot field
@@ -257,7 +257,7 @@
258258 "WHERE ug_group IN($patrolwhere) AND user_id = ug_user";
259259 $res = $dbw->query( $sql, DB_MASTER );
260260
261 - while( $obj = $dbw->fetchObject( $res ) ) {
 261+ foreach( $res as $obj ) {
262262 $patrolusers[] = $dbw->addQuotes( $obj->user_name );
263263 }
264264
Index: trunk/phase3/maintenance/attachLatest.php
@@ -43,7 +43,7 @@
4444 __METHOD__ );
4545
4646 $n = 0;
47 - while( $row = $dbw->fetchObject( $result ) ) {
 47+ foreach( $result as $row ) {
4848 $pageId = intval( $row->page_id );
4949 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
5050 $name = $title->getPrefixedText();

Comments

#Comment by Tbleher (talk | contribs)   11:01, 18 August 2009

Hmm, I found the old way easier to read, because there was less magic going on behind the scenes.

Status & tagging log