Assignment in loop conditions suck
authorSam Reed <reedy@users.mediawiki.org>
Wed, 13 Oct 2010 23:11:40 +0000 (23:11 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Wed, 13 Oct 2010 23:11:40 +0000 (23:11 +0000)
while ( $row = $dbw->fetchObject( $res ) ) { to foreach ( $res as $row ) in includes

Add some braces

49 files changed:
includes/Article.php
includes/Block.php
includes/CacheDependency.php
includes/Categoryfinder.php
includes/ChangeTags.php
includes/EditPage.php
includes/Export.php
includes/LinkBatch.php
includes/LinksUpdate.php
includes/LogEventsList.php
includes/QueryPage.php
includes/SquidUpdate.php
includes/Title.php
includes/User.php
includes/UserMailer.php
includes/UserRightsProxy.php
includes/WatchedItem.php
includes/WatchlistEditor.php
includes/Wiki.php
includes/api/ApiDelete.php
includes/db/Database.php
includes/db/DatabaseMssql.php
includes/db/DatabaseMysql.php
includes/db/DatabasePostgres.php
includes/diff/DifferenceEngine.php
includes/filerepo/File.php
includes/filerepo/LocalFile.php
includes/filerepo/LocalRepo.php
includes/installer/PostgresUpdater.php
includes/parser/LinkHolderArray.php
includes/specials/SpecialAllmessages.php
includes/specials/SpecialCategories.php
includes/specials/SpecialDisambiguations.php
includes/specials/SpecialExport.php
includes/specials/SpecialIpblocklist.php
includes/specials/SpecialListfiles.php
includes/specials/SpecialMergeHistory.php
includes/specials/SpecialMostlinked.php
includes/specials/SpecialMostlinkedcategories.php
includes/specials/SpecialMostlinkedtemplates.php
includes/specials/SpecialNewimages.php
includes/specials/SpecialNewpages.php
includes/specials/SpecialProtectedpages.php
includes/specials/SpecialProtectedtitles.php
includes/specials/SpecialStatistics.php
includes/specials/SpecialTags.php
includes/specials/SpecialUndelete.php
includes/specials/SpecialWatchlist.php
includes/specials/SpecialWhatlinkshere.php

index 211a0da..07f3e5d 100644 (file)
@@ -1590,7 +1590,7 @@ class Article {
                }
 
                $tbtext = "";
-               while ( $o = $dbr->fetchObject( $tbs ) ) {
+               foreach ( $tbs as $o ) {
                        $rmvtxt = "";
 
                        if ( $wgUser->isAllowed( 'trackback' ) ) {
@@ -2992,7 +2992,7 @@ class Article {
 
                $authors = array( $row->rev_user_text );
 
-               while ( $row = $db->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $authors[] = $row->rev_user_text;
                }
 
index d5169ef..7c1b5d5 100644 (file)
@@ -531,7 +531,7 @@ class Block {
                                # No results, don't autoblock anything
                                wfDebug( "No IP found to retroactively autoblock\n" );
                        } else {
-                               while ( $row = $dbr->fetchObject( $res ) ) {
+                               foreach ( $res as $row ) {
                                        if ( $row->rc_ip ) {
                                                $this->doAutoblock( $row->rc_ip );
                                        }
index afc1ab8..74ca286 100644 (file)
@@ -280,7 +280,7 @@ class TitleListDependency extends CacheDependency {
                                __METHOD__
                        );
 
-                       while ( $row = $dbr->fetchObject( $res ) ) {
+                       foreach ( $res as $row ) {
                                $timestamps[$row->page_namespace][$row->page_title] = $row->page_touched;
                        }
                }
index 50fe1f0..1f08b7f 100644 (file)
@@ -154,7 +154,7 @@ class Categoryfinder {
                        /* WHERE  */ array( 'cl_from' => $this->next ),
                        __METHOD__ . '-1'
                );
-               while ( $o = $this->dbr->fetchObject( $res ) ) {
+               foreach ( $res as $o ) {
                        $k = $o->cl_to;
 
                        # Update parent tree
@@ -186,7 +186,7 @@ class Categoryfinder {
                                /* WHERE  */ array( 'page_namespace' => NS_CATEGORY , 'page_title' => $layer ),
                                __METHOD__ . '-2'
                        );
-                       while ( $o = $this->dbr->fetchObject( $res ) ) {
+                       foreach ( $res as $o ) {
                                $id = $o->page_id;
                                $name = $o->page_title;
                                $this->name2id[$name] = $id;
index 58f56ef..1091aaa 100644 (file)
@@ -181,15 +181,16 @@ class ChangeTags {
                global $wgMemc;
                $key = wfMemcKey( 'valid-tags' );
 
-               if ( $tags = $wgMemc->get( $key ) )
+               if ( $tags = $wgMemc->get( $key ) ) {
                        return $tags;
+               }
 
                $emptyTags = array();
 
                // Some DB stuff
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( 'valid_tag', 'vt_tag', array(), __METHOD__ );
-               while( $row = $res->fetchObject() ) {
+               foreach ( $res as $row ) {
                        $emptyTags[] = $row->vt_tag;
                }
 
index a334a89..d71dfce 100644 (file)
@@ -1079,7 +1079,7 @@ class EditPage {
                        ),
                        __METHOD__,
                        array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 50 ) );
-               while( $row = $res->fetchObject() ) {
+               foreach ( $res as $row ) {
                        if( $row->rev_user != $id ) {
                                return false;
                        }
index b4f28be..23b7849 100644 (file)
@@ -300,7 +300,7 @@ class WikiExporter {
         */
        protected function outputPageStream( $resultset ) {
                $last = null;
-               while( $row = $resultset->fetchObject() ) {
+               foreach ( $resultset as $row ) {
                        if( is_null( $last ) ||
                                $last->page_namespace != $row->page_namespace ||
                                $last->page_title     != $row->page_title ) {
@@ -331,7 +331,7 @@ class WikiExporter {
        }
        
        protected function outputLogStream( $resultset ) {
-               while( $row = $resultset->fetchObject() ) {
+               foreach ( $resultset as $row ) {
                        $output = $this->writer->writeLogItem( $row );
                        $this->sink->writeLogItem( $row, $output );
                }
index 5b8e237..e689f96 100644 (file)
@@ -109,7 +109,7 @@ class LinkBatch {
 
                $ids = array();
                $remaining = $this->data;
-               while ( $row = $res->fetchObject() ) {
+               foreach ( $res as $row ) {
                        $title = Title::makeTitle( $row->page_namespace, $row->page_title );
                        $cache->addGoodLinkObj( $row->page_id, $title, $row->page_len, $row->page_is_redirect, $row->page_latest );
                        $ids[$title->getPrefixedDBkey()] = $row->page_id;
index c80c07d..f5fa378 100644 (file)
@@ -247,7 +247,7 @@ class LinksUpdate {
                                'page_touched < ' . $this->mDb->addQuotes( $now )
                        ), __METHOD__
                );
-               while ( $row = $this->mDb->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $ids[] = $row->page_id;
                }
                if ( !count( $ids ) ) {
@@ -628,7 +628,7 @@ class LinksUpdate {
                $res = $this->mDb->select( 'pagelinks', array( 'pl_namespace', 'pl_title' ),
                        array( 'pl_from' => $this->mId ), __METHOD__, $this->mOptions );
                $arr = array();
-               while ( $row = $this->mDb->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        if ( !isset( $arr[$row->pl_namespace] ) ) {
                                $arr[$row->pl_namespace] = array();
                        }
@@ -645,7 +645,7 @@ class LinksUpdate {
                $res = $this->mDb->select( 'templatelinks', array( 'tl_namespace', 'tl_title' ),
                        array( 'tl_from' => $this->mId ), __METHOD__, $this->mOptions );
                $arr = array();
-               while ( $row = $this->mDb->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        if ( !isset( $arr[$row->tl_namespace] ) ) {
                                $arr[$row->tl_namespace] = array();
                        }
@@ -662,7 +662,7 @@ class LinksUpdate {
                $res = $this->mDb->select( 'imagelinks', array( 'il_to' ),
                        array( 'il_from' => $this->mId ), __METHOD__, $this->mOptions );
                $arr = array();
-               while ( $row = $this->mDb->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $arr[$row->il_to] = 1;
                }
                return $arr;
@@ -676,7 +676,7 @@ class LinksUpdate {
                $res = $this->mDb->select( 'externallinks', array( 'el_to' ),
                        array( 'el_from' => $this->mId ), __METHOD__, $this->mOptions );
                $arr = array();
-               while ( $row = $this->mDb->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $arr[$row->el_to] = 1;
                }
                return $arr;
@@ -690,7 +690,7 @@ class LinksUpdate {
                $res = $this->mDb->select( 'categorylinks', array( 'cl_to', 'cl_sortkey' ),
                        array( 'cl_from' => $this->mId ), __METHOD__, $this->mOptions );
                $arr = array();
-               while ( $row = $this->mDb->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $arr[$row->cl_to] = $row->cl_sortkey;
                }
                return $arr;
@@ -705,7 +705,7 @@ class LinksUpdate {
                $res = $this->mDb->select( 'langlinks', array( 'll_lang', 'll_title' ),
                        array( 'll_from' => $this->mId ), __METHOD__, $this->mOptions );
                $arr = array();
-               while ( $row = $this->mDb->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $arr[$row->ll_lang] = $row->ll_title;
                }
                return $arr;
@@ -719,7 +719,7 @@ class LinksUpdate {
                $res = $this->mDb->select( 'iwlinks', array( 'iwl_prefix', 'iwl_title' ),
                        array( 'iwl_from' => $this->mId ), __METHOD__, $this->mOptions );
                $arr = array();
-               while ( $row = $this->mDb->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        if ( !isset( $arr[$row->iwl_prefix] ) ) {
                                $arr[$row->iwl_prefix] = array();
                        }
@@ -736,7 +736,7 @@ class LinksUpdate {
                $res = $this->mDb->select( 'page_props', array( 'pp_propname', 'pp_value' ),
                        array( 'pp_page' => $this->mId ), __METHOD__, $this->mOptions );
                $arr = array();
-               while ( $row = $this->mDb->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $arr[$row->pp_propname] = $row->pp_value;
                }
                return $arr;
index dd20d50..62c3184 100644 (file)
@@ -971,7 +971,7 @@ class LogPager extends ReverseChronologicalPager {
                # Do a link batch query
                if( $this->getNumRows() > 0 ) {
                        $lb = new LinkBatch;
-                       while( $row = $this->mResult->fetchObject() ) {
+                       foreach ( $this->mResult as $row ) {
                                $lb->add( $row->log_namespace, $row->log_title );
                                $lb->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
                                $lb->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
index 15e86aa..a301574 100644 (file)
@@ -482,9 +482,11 @@ class QueryPage {
                        $sql = $this->getSQL() . $this->getOrder();
                        $sql = $dbr->limitResult( $sql, $limit, 0 );
                        $res = $dbr->query( $sql, 'QueryPage::doFeed' );
-                       while( $obj = $dbr->fetchObject( $res ) ) {
+                       foreach ( $res as $obj ) {
                                $item = $this->feedResult( $obj );
-                               if( $item ) $feed->outItem( $item );
+                               if( $item ) {
+                                       $feed->outItem( $item );
+                               }
                        }
 
                        $feed->outFooter();
@@ -567,8 +569,9 @@ abstract class WantedQueryPage extends QueryPage {
         */
        function preprocessResults( $db, $res ) {
                $batch = new LinkBatch;
-               while ( $row = $db->fetchObject( $res ) )
+               foreach ( $res as $row ) {
                        $batch->add( $row->namespace, $row->title );
+               }
                $batch->execute();
 
                // Back to start for display
index d0fe51b..31f7aa6 100644 (file)
@@ -40,8 +40,7 @@ class SquidUpdate {
                        __METHOD__ );
                $blurlArr = $title->getSquidURLs();
                if ( $dbr->numRows( $res ) <= $wgMaxSquidPurgeTitles ) {
-                       while ( $BL = $dbr->fetchObject ( $res ) )
-                       {
+                       foreach ( $res as $BL ) {
                                $tobj = Title::makeTitle( $BL->page_namespace, $BL->page_title ) ;
                                $blurlArr[] = $tobj->getInternalURL();
                        }
index cd9289f..0cdcfeb 100644 (file)
@@ -2106,9 +2106,8 @@ class Title {
         */
        private function loadRestrictionsFromResultWrapper( $res, $oldFashionedRestrictions = null ) {
                $rows = array();
-               $dbr = wfGetDB( DB_SLAVE );
 
-               while ( $row = $dbr->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $rows[] = $row;
                }
 
index a3f6cdd..ec6dad5 100644 (file)
@@ -976,7 +976,7 @@ class User {
                                array( 'ug_user' => $this->mId ),
                                __METHOD__ );
                        $this->mGroups = array();
-                       while( $row = $dbr->fetchObject( $res ) ) {
+                       foreach ( $res as $row ) {
                                $this->mGroups[] = $row->ug_group;
                        }
                }
@@ -3633,7 +3633,7 @@ class User {
                                __METHOD__
                        );
 
-                       while( $row = $dbr->fetchObject( $res ) ) {
+                       foreach ( $res as $row ) {
                                $this->mOptionOverrides[$row->up_property] = $row->up_value;
                                $this->mOptions[$row->up_property] = $row->up_value;
                        }
index f2e92ff..edcdcc5 100644 (file)
@@ -306,7 +306,7 @@ class EmailNotification {
                                        'wl_notificationtimestamp IS NULL',
                                ), __METHOD__
                        );
-                       while ($row = $dbw->fetchObject( $res ) ) {
+                       foreach ( $res as $row ) {
                                $watchers[] = intval( $row->wl_user );
                        }
                        if ($watchers) {
index 0642bb1..6c2a5f1 100644 (file)
@@ -157,7 +157,7 @@ class UserRightsProxy {
                        array( 'ug_user' => $this->id ),
                        __METHOD__ );
                $groups = array();
-               while( $row = $this->db->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $groups[] = $row->ug_group;
                }
                return $groups;
index 1fd6e31..0cf8a77 100644 (file)
@@ -143,7 +143,7 @@ class WatchedItem {
                );
                # Construct array to replace into the watchlist
                $values = array();
-               while ( $s = $dbw->fetchObject( $res ) ) {
+               foreach ( $res as $s ) {
                        $values[] = array(
                                'wl_user' => $s->wl_user,
                                'wl_namespace' => $newnamespace,
index 8b089d0..99f7a56 100644 (file)
@@ -186,7 +186,7 @@ class WatchlistEditor {
                        __METHOD__
                );
                if( $res->numRows() > 0 ) {
-                       while( $row = $res->fetchObject() ) {
+                       foreach ( $res as $row ) {
                                $title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
                                if( $title instanceof Title && !$title->isTalkPage() )
                                        $list[] = $title->getPrefixedText();
@@ -218,7 +218,7 @@ class WatchlistEditor {
                $res = $dbr->query( $sql, __METHOD__ );
                if( $res && $dbr->numRows( $res ) > 0 ) {
                        $cache = LinkCache::singleton();
-                       while( $row = $dbr->fetchObject( $res ) ) {
+                       foreach ( $res as $row ) {                      
                                $title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
                                if( $title instanceof Title ) {
                                        // Update the link cache while we're at it
index 0c65b4a..366dd88 100644 (file)
@@ -108,7 +108,7 @@ class MediaWiki {
                if( $wgRequest->getVal( 'printable' ) === 'yes' ) {
                        $wgOut->setPrintable();
                }
-               $ret = null;
+
                if( $curid = $wgRequest->getInt( 'curid' ) ) {
                        // URLs like this are generated by RC, because rc_title isn't always accurate
                        $ret = Title::newFromID( $curid );
index bfae025..8202c60 100644 (file)
@@ -232,7 +232,7 @@ class ApiDelete extends ApiBase {
                                ApiBase::PARAM_DFLT => false,
                                ApiBase::PARAM_DEPRECATED => true,
                        ),
-                       'oldimage' => null
+                       'oldimage' => null,
                );
        }
 
index d29d142..444b800 100644 (file)
@@ -1217,7 +1217,7 @@ abstract class DatabaseBase implements DatabaseType {
 
                $result = array();
 
-               while ( $row = $this->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        if ( $row->Key_name == $index ) {
                                $result[] = $row;
                        }
@@ -2332,7 +2332,7 @@ abstract class DatabaseBase implements DatabaseType {
                $res = $this->query( "SHOW STATUS LIKE '{$which}'" );
                $status = array();
 
-               while ( $row = $this->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $status[$row->Variable_name] = $row->Value;
                }
 
index 1284ce5..23efcfc 100644 (file)
@@ -347,7 +347,7 @@ class DatabaseMssql extends DatabaseBase {
                }
 
                $result = array();
-               while ( $row = $res->FetchNextObj() ) {
+               foreach ( $res as $row ) {
                        if ( $row->index_name == $index ) {
                                $row->Non_unique = !stristr( $row->index_description, "unique" );
                                $cols = explode( ", ", $row->index_keys );
@@ -784,8 +784,9 @@ class DatabaseMssql extends DatabaseBase {
                        print( "Error in fieldInfo query: " . $this->getErrors() );
                        return false;
                }
-               if ( $meta = $this->fetchRow( $res ) )
+               if ( $meta = $this->fetchRow( $res ) ) {
                        return new MssqlField( $meta );
+               }
                return false;
        }
 
index 041ebd1..75e28f3 100644 (file)
@@ -260,7 +260,7 @@ class DatabaseMysql extends DatabaseBase {
                }
 
                $rows = 1;
-               while( $plan = $this->fetchObject( $res ) ) {
+               foreach ( $res as $plan ) {
                        $rows *= $plan->rows > 0 ? $plan->rows : 1; // avoid resetting to zero
                }
                return $rows;
index 672e022..d3c3eb5 100644 (file)
@@ -737,7 +737,7 @@ class DatabasePostgres extends DatabaseBase {
                if ( !$res ) {
                        return null;
                }
-               while ( $row = $this->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        if ( $row->indexname == $this->indexName( $index ) ) {
                                return $row;
                        }
@@ -754,7 +754,7 @@ class DatabasePostgres extends DatabaseBase {
                if ( !$res ) {
                        return null;
                }
-               while ( $row = $this->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        return true;
                }
                return false;
index a1f5276..c01837a 100644 (file)
@@ -312,12 +312,13 @@ class _DiffEngine {
                                continue;
                                $matches = $ymatches[$line];
                                reset($matches);
-                               while (list ($junk, $y) = each($matches))
-                               if (empty($this->in_seq[$y])) {
-                                       $k = $this->_lcs_pos($y);
-                                       assert($k > 0);
-                                       $ymids[$k] = $ymids[$k-1];
-                                       break;
+                               while ( list( $junk, $y ) = each( $matches ) ) {
+                                       if ( empty( $this->in_seq[$y] ) ) {
+                                               $k = $this->_lcs_pos( $y );
+                                               assert( $k > 0 );
+                                               $ymids[$k] = $ymids[$k-1];
+                                               break;
+                                       }
                                }
                                while (list ( /* $junk */, $y) = each($matches)) {
                                        if ($y > $this->seq[$k-1]) {
index 34de8b7..77b1b16 100644 (file)
@@ -892,7 +892,7 @@ abstract class File {
 
                $retVal = array();
                if ( $db->numRows( $res ) ) {
-                       while ( $row = $db->fetchObject( $res ) ) {
+                       foreach ( $res as $row ) {
                                if ( $titleObj = Title::newFromRow( $row ) ) {
                                        $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect, $row->page_latest );
                                        $retVal[] = $titleObj;
index 3ce2415..51b5ab8 100644 (file)
@@ -713,7 +713,7 @@ class LocalFile extends File {
                $res = $dbr->select( $tables, $fields, $conds, __METHOD__, $opts, $join_conds );
                $r = array();
 
-               while ( $row = $dbr->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        if ( $this->repo->oldFileFromRowFactory ) {
                                $r[] = call_user_func( $this->repo->oldFileFromRowFactory, $row, $this->repo );
                        } else {
@@ -1127,7 +1127,7 @@ class LocalFile extends File {
                $result = $dbw->select( 'oldimage',
                        array( 'oi_archive_name' ),
                        array( 'oi_name' => $this->getName() ) );
-               while ( $row = $dbw->fetchObject( $result ) ) {
+               foreach ( $result as $row ) {
                        $batch->addOld( $row->oi_archive_name );
                }
                $status = $batch->execute();
@@ -1341,7 +1341,7 @@ class LocalFileDeleteBatch {
                                __METHOD__
                        );
 
-                       while ( $row = $dbw->fetchObject( $res ) ) {
+                       foreach ( $res as $row ) {
                                if ( rtrim( $row->oi_sha1, "\0" ) === '' ) {
                                        // Get the hash from the file
                                        $oldUrl = $this->file->getArchiveVirtualUrl( $row->oi_archive_name );
@@ -1504,7 +1504,7 @@ class LocalFileDeleteBatch {
                                        $dbw->bitAnd( 'oi_deleted', File::DELETED_FILE ) => File::DELETED_FILE ),
                                __METHOD__ );
 
-                       while ( $row = $dbw->fetchObject( $res ) ) {
+                       foreach ( $res as $row ) {
                                $privateFiles[$row->oi_archive_name] = 1;
                        }
                }
@@ -1674,7 +1674,7 @@ class LocalFileRestoreBatch {
                $first = true;
                $archiveNames = array();
 
-               while ( $row = $dbw->fetchObject( $result ) ) {
+               foreach ( $result as $row ) {
                        $idsPresent[] = $row->fa_id;
 
                        if ( $row->fa_name != $this->file->getName() ) {
@@ -1958,7 +1958,7 @@ class LocalFileMoveBatch {
                        __METHOD__
                );
 
-               while ( $row = $this->db->fetchObject( $result ) ) {
+               foreach ( $result as $row ) {
                        $oldName = $row->oi_archive_name;
                        $bits = explode( '!', $oldName, 2 );
 
index 96ec28f..50a83f6 100644 (file)
@@ -164,9 +164,10 @@ class LocalRepo extends FSRepo {
                );
                
                $result = array();
-               while ( $row = $res->fetchObject() )
+               foreach ( $res as $row ) {
                        $result[] = $this->newFileFromRow( $row );
-               $res->free();
+               }
+
                return $result;
        }
 
index fb97f87..ce36374 100644 (file)
@@ -280,7 +280,7 @@ END;
                }
 
                $cols = array();
-               while ( $r = $this->db->fetchRow( $res ) ) {
+               foreach ( $res as $r ) {
                        $cols[] = array(
                                        "name" => $r[0],
                                        "ord" => $r[1],
index 9175b5a..f879a65 100644 (file)
@@ -204,7 +204,7 @@ class LinkHolderArray {
 
                        # Fetch data and form into an associative array
                        # non-existent = broken
-                       while ( $s = $dbr->fetchObject($res) ) {
+                       foreach ( $res as $s ) {
                                $title = Title::makeTitle( $s->page_namespace, $s->page_title );
                                $pdbk = $title->getPrefixedDBkey();
                                $linkCache->addGoodLinkObj( $s->page_id, $title, $s->page_len, $s->page_is_redirect, $s->page_latest );
@@ -337,9 +337,9 @@ class LinkHolderArray {
                foreach ( $titlesAllVariants as &$titlesVariant ) {
                        $titlesVariant = explode( "\0", $titlesVariant );
                }
-               
+               $l = count( $titlesAttrs );
                // Then add variants of links to link batch
-               for ( $i = 0; $l = count( $titlesAttrs ), $i < $l; $i ++ ) {
+               for ( $i = 0; $i < $l; $i ++ ) {
                        foreach ( $allVariantsName as $variantName ) {
                                $textVariant = $titlesAllVariants[$variantName][$i];
                                extract( $titlesAttrs[$i] );
@@ -381,7 +381,7 @@ class LinkHolderArray {
                        $linkcolour_ids = array();
 
                        // for each found variants, figure out link holders and replace
-                       while ( $s = $dbr->fetchObject($varRes) ) {
+                       foreach ( $varRes as $s ) {
 
                                $variantTitle = Title::makeTitle( $s->page_namespace, $s->page_title );
                                $varPdbk = $variantTitle->getPrefixedDBkey();
index c36ed2b..01065a3 100644 (file)
@@ -227,7 +227,7 @@ class AllmessagesTablePager extends TablePager {
 
                $pageFlags = $talkFlags = array();
                
-               while( $s = $dbr->fetchObject( $res ) ) {
+               foreach ( $res as $s ) {
                        if( $s->page_namespace == NS_MEDIAWIKI ) {
                                if( $this->foreign ) {
                                        $title = explode( '/', $s->page_title );
index 35dadf9..5cf567b 100644 (file)
@@ -104,7 +104,7 @@ class CategoryPager extends AlphabeticPager {
 
                $this->mResult->rewind();
 
-               while ( $row = $this->mResult->fetchObject() ) {
+               foreach ( $this->mResult as $row ) {
                        $batch->addObj( Title::makeTitleSafe( NS_CATEGORY, $row->cat_title ) );
                }
                $batch->execute();
index 08d8e12..3e70618 100644 (file)
@@ -69,7 +69,7 @@ class DisambiguationsPage extends PageQueryPage {
                                                'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
                                        __METHOD__ );
 
-                               while ( $row = $dbr->fetchObject( $res ) ) {
+                               foreach ( $res as $row ) {
                                        $linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title ));
                                }
                }
index 2c26576..5f56bef 100644 (file)
@@ -315,7 +315,7 @@ class SpecialExport extends SpecialPage {
 
                $pages = array();
                
-               while ( $row = $dbr->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $n = $row->page_title;
                        if ($row->page_namespace) {
                                $ns = $wgContLang->getNsText( $row->page_namespace );
@@ -341,7 +341,7 @@ class SpecialExport extends SpecialPage {
 
                $pages = array();
                
-               while ( $row = $dbr->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $n = $row->page_title;
                        
                        if ( $row->page_namespace ) {
index a6d5ba2..2fee3f2 100644 (file)
@@ -544,7 +544,7 @@ class IPBlocklistPager extends ReverseChronologicalPager {
                # Faster way
                # Usernames and titles are in fact related by a simple substitution of space -> underscore
                # The last few lines of Title::secureAndSplit() tell the story.
-               while ( $row = $this->mResult->fetchObject() ) {
+               foreach ( $this->mResult as $row ) {
                        $name = str_replace( ' ', '_', $row->ipb_by_text );
                        $lb->add( NS_USER, $name );
                        $lb->add( NS_USER_TALK, $name );
index 9a5d91e..ed48f56 100644 (file)
@@ -139,7 +139,7 @@ class ImageListPager extends TablePager {
                if ( $this->mResult->numRows() ) {
                        $lb = new LinkBatch;
                        $this->mResult->seek( 0 );
-                       while ( $row = $this->mResult->fetchObject() ) {
+                       foreach ( $this->mResult as $row ) {
                                if ( $row->img_user ) {
                                        $lb->add( NS_USER, str_replace( ' ', '_', $row->img_user_text ) );
                                }
index 9eb8820..b59f80e 100644 (file)
@@ -438,7 +438,7 @@ class MergeHistoryPager extends ReverseChronologicalPager {
                $batch = new LinkBatch();
                # Give some pointers to make (last) links
                $this->mForm->prevId = array();
-               while( $row = $this->mResult->fetchObject() ) {
+               foreach ( $this->mResult as $row ) {
                        $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_text ) );
                        $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_text ) );
 
index 387bb54..c731588 100644 (file)
@@ -73,8 +73,9 @@ class MostlinkedPage extends QueryPage {
        function preprocessResults( $db, $res ) {
                if( $db->numRows( $res ) > 0 ) {
                        $linkBatch = new LinkBatch();
-                       while( $row = $db->fetchObject( $res ) )
+                       foreach ( $res as $row ) {
                                $linkBatch->add( $row->namespace, $row->title );
+                       }
                        $db->dataSeek( $res, 0 );
                        $linkBatch->execute();
                }
index d18c5b7..e1fc1d9 100644 (file)
@@ -58,8 +58,9 @@ class MostlinkedCategoriesPage extends QueryPage {
         */
        function preprocessResults( $db, $res ) {
                $batch = new LinkBatch;
-               while ( $row = $db->fetchObject( $res ) )
+               foreach ( $res as $row ) {
                        $batch->add( $row->namespace, $row->title );
+               }
                $batch->execute();
 
                // Back to start for display
index cfc791d..71df904 100644 (file)
@@ -92,7 +92,7 @@ class SpecialMostlinkedtemplates extends QueryPage {
         */
        public function preprocessResults( $db, $res ) {
                $batch = new LinkBatch();
-               while( $row = $db->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $batch->add( $row->namespace, $row->title );
                }
                $batch->execute();
index 53a92fc..5962215 100644 (file)
@@ -117,7 +117,7 @@ function wfSpecialNewimages( $par, $specialPage ) {
         * We have to flip things around to get the last N after a certain date
         */
        $images = array();
-       while ( $s = $dbr->fetchObject( $res ) ) {
+       foreach ( $res as $s ) {
                if( $invertSort ) {
                        array_unshift( $images, $s );
                } else {
index d42aabd..f053fe3 100644 (file)
@@ -511,7 +511,7 @@ class NewPagesPager extends ReverseChronologicalPager {
        function getStartBody() {
                # Do a batch existence check on pages
                $linkBatch = new LinkBatch();
-               while( $row = $this->mResult->fetchObject() ) {
+               foreach ( $this->mResult as $row ) {
                        $linkBatch->add( NS_USER, $row->rc_user_text );
                        $linkBatch->add( NS_USER_TALK, $row->rc_user_text );
                        $linkBatch->add( $row->rc_namespace, $row->rc_title );
index 2b01412..96a53c5 100644 (file)
@@ -309,7 +309,7 @@ class ProtectedPagesPager extends AlphabeticPager {
        function getStartBody() {
                # Do a link batch query
                $lb = new LinkBatch;
-               while( $row = $this->mResult->fetchObject() ) {
+               foreach ( $this->mResult as $row ) {
                        $lb->add( $row->page_namespace, $row->page_title );
                }
                $lb->execute();
index b2166c3..5e3ad6c 100644 (file)
@@ -196,7 +196,7 @@ class ProtectedTitlesPager extends AlphabeticPager {
                $this->mResult->seek( 0 );
                $lb = new LinkBatch;
 
-               while ( $row = $this->mResult->fetchObject() ) {
+               foreach ( $this->mResult as $row ) {
                        $lb->add( $row->pt_namespace, $row->pt_title );
                }
 
index 1d06d89..7eb1a2f 100644 (file)
@@ -278,7 +278,7 @@ class SpecialStatistics extends SpecialPage {
                                $text .= Xml::openElement( 'tr' );
                                $text .= Xml::tags( 'th', array( 'colspan' => '2' ), wfMsgExt( 'statistics-mostpopular', array( 'parseinline' ) ) );
                                $text .= Xml::closeElement( 'tr' );
-                               while( $row = $res->fetchObject() ) {
+                               foreach ( $res as $row ) {
                                        $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
                                        if( $title instanceof Title ) {
                                                $text .= $this->formatRow( $sk->link( $title ),
index b0368c7..c2aecf4 100644 (file)
@@ -50,7 +50,7 @@ class SpecialTags extends SpecialPage {
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( 'change_tag', array( 'ct_tag', 'count(*) as hitcount' ), array(), __METHOD__, array( 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'hitcount DESC' ) );
 
-               while ( $row = $res->fetchObject() ) {
+               foreach ( $res as $row ) {
                        $html .= $this->doTagRow( $row->ct_tag, $row->hitcount );
                }
 
index 8563f1b..c98caeb 100644 (file)
@@ -739,7 +739,7 @@ class UndeleteForm extends SpecialPage {
                $sk = $wgUser->getSkin();
                $undelete = $this->getTitle();
                $wgOut->addHTML( "<ul>\n" );
-               while( $row = $result->fetchObject() ) {
+               foreach ( $result as $row ) {
                        $title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
                        $link = $sk->linkKnown(
                                $undelete,
@@ -1059,7 +1059,7 @@ class UndeleteForm extends SpecialPage {
                # Batch existence check on user and talk pages
                if( $haveRevisions ) {
                        $batch = new LinkBatch();
-                       while( $row = $revisions->fetchObject() ) {
+                       foreach ( $revisions as $row ) {
                                $batch->addObj( Title::makeTitleSafe( NS_USER, $row->ar_user_text ) );
                                $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->ar_user_text ) );
                        }
@@ -1068,7 +1068,7 @@ class UndeleteForm extends SpecialPage {
                }
                if( $haveFiles ) {
                        $batch = new LinkBatch();
-                       while( $row = $files->fetchObject() ) {
+                       foreach ( $files as $row ) {
                                $batch->addObj( Title::makeTitleSafe( NS_USER, $row->fa_user_text ) );
                                $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->fa_user_text ) );
                        }
@@ -1146,7 +1146,7 @@ class UndeleteForm extends SpecialPage {
                        $remaining = $revisions->numRows();
                        $earliestLiveTime = $this->mTargetObj->getEarliestRevTime();
 
-                       while( $row = $revisions->fetchObject() ) {
+                       foreach ( $revisions as $row ) {
                                $remaining--;
                                $wgOut->addHTML( $this->formatRevisionRow( $row, $earliestLiveTime, $remaining, $sk ) );
                        }
@@ -1159,7 +1159,7 @@ class UndeleteForm extends SpecialPage {
                if( $haveFiles ) {
                        $wgOut->addHTML( Xml::element( 'h2', null, wfMsg( 'filehist' ) ) . "\n" );
                        $wgOut->addHTML( "<ul>" );
-                       while( $row = $files->fetchObject() ) {
+                       foreach ( $files as $row ) {
                                $wgOut->addHTML( $this->formatFileRow( $row, $sk ) );
                        }
                        $files->free();
index 5dc17ee..8d0523d 100644 (file)
@@ -341,7 +341,7 @@ function wfSpecialWatchlist( $par ) {
 
        /* Do link batch query */
        $linkBatch = new LinkBatch;
-       while ( $row = $dbr->fetchObject( $res ) ) {
+       foreach ( $res as $row ) {
                $userNameUnderscored = str_replace( ' ', '_', $row->rc_user_text );
                if ( $row->rc_user != 0 ) {
                        $linkBatch->add( NS_USER, $userNameUnderscored );
@@ -358,7 +358,7 @@ function wfSpecialWatchlist( $par ) {
        
        $s = $list->beginRecentChangesList();
        $counter = 1;
-       while ( $obj = $dbr->fetchObject( $res ) ) {
+       foreach ( $res as $obj ) {
                # Make RC entry
                $rc = RecentChange::newFromRow( $obj );
                $rc->counter = $counter++;
index 32c020b..74bc2f6 100644 (file)
@@ -187,21 +187,21 @@ class SpecialWhatLinksHere extends SpecialPage {
                // templatelinks comes second so that the templatelinks row overwrites the
                // pagelinks row, so we get (inclusion) rather than nothing
                if( $fetchlinks ) {
-                       while ( $row = $dbr->fetchObject( $plRes ) ) {
+                       foreach ( $plRes as $row ) {
                                $row->is_template = 0;
                                $row->is_image = 0;
                                $rows[$row->page_id] = $row;
                        }
                }
                if( !$hidetrans ) {
-                       while ( $row = $dbr->fetchObject( $tlRes ) ) {
+                       foreach ( $tlRes as $row ) {
                                $row->is_template = 1;
                                $row->is_image = 0;
                                $rows[$row->page_id] = $row;
                        }
                }
                if( !$hideimages ) {
-                       while ( $row = $dbr->fetchObject( $ilRes ) ) {
+                       foreach ( $ilRes as $row ) {
                                $row->is_template = 0;
                                $row->is_image = 1;
                                $rows[$row->page_id] = $row;