From: Sam Reed Date: Wed, 13 Oct 2010 23:11:40 +0000 (+0000) Subject: Assignment in loop conditions suck X-Git-Tag: 1.31.0-rc.0~34516 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=a2589ff8c6718dc170db8eb6c08ce656d38df46b;p=lhc%2Fweb%2Fwiklou.git Assignment in loop conditions suck while ( $row = $dbw->fetchObject( $res ) ) { to foreach ( $res as $row ) in includes Add some braces --- diff --git a/includes/Article.php b/includes/Article.php index 211a0da11e..07f3e5da08 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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; } diff --git a/includes/Block.php b/includes/Block.php index d5169ef9f8..7c1b5d5c9e 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -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 ); } diff --git a/includes/CacheDependency.php b/includes/CacheDependency.php index afc1ab86ed..74ca2864e2 100644 --- a/includes/CacheDependency.php +++ b/includes/CacheDependency.php @@ -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; } } diff --git a/includes/Categoryfinder.php b/includes/Categoryfinder.php index 50fe1f0a1c..1f08b7f837 100644 --- a/includes/Categoryfinder.php +++ b/includes/Categoryfinder.php @@ -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; diff --git a/includes/ChangeTags.php b/includes/ChangeTags.php index 58f56efbc2..1091aaa1db 100644 --- a/includes/ChangeTags.php +++ b/includes/ChangeTags.php @@ -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; } diff --git a/includes/EditPage.php b/includes/EditPage.php index a334a89324..d71dfce53f 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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; } diff --git a/includes/Export.php b/includes/Export.php index b4f28be209..23b7849ef0 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -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 ); } diff --git a/includes/LinkBatch.php b/includes/LinkBatch.php index 5b8e23710a..e689f9660e 100644 --- a/includes/LinkBatch.php +++ b/includes/LinkBatch.php @@ -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; diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index c80c07d1ab..f5fa378646 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -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; diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index dd20d50ac0..62c3184ec5 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -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 ) ); diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 15e86aa4cd..a30157487c 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -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 diff --git a/includes/SquidUpdate.php b/includes/SquidUpdate.php index d0fe51bc5b..31f7aa68b1 100644 --- a/includes/SquidUpdate.php +++ b/includes/SquidUpdate.php @@ -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(); } diff --git a/includes/Title.php b/includes/Title.php index cd9289f6e9..0cdcfeb016 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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; } diff --git a/includes/User.php b/includes/User.php index a3f6cddbe2..ec6dad577f 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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; } diff --git a/includes/UserMailer.php b/includes/UserMailer.php index f2e92ffd76..edcdcc53bb 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -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) { diff --git a/includes/UserRightsProxy.php b/includes/UserRightsProxy.php index 0642bb16c8..6c2a5f1201 100644 --- a/includes/UserRightsProxy.php +++ b/includes/UserRightsProxy.php @@ -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; diff --git a/includes/WatchedItem.php b/includes/WatchedItem.php index 1fd6e31382..0cf8a77cb3 100644 --- a/includes/WatchedItem.php +++ b/includes/WatchedItem.php @@ -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, diff --git a/includes/WatchlistEditor.php b/includes/WatchlistEditor.php index 8b089d083e..99f7a56e28 100644 --- a/includes/WatchlistEditor.php +++ b/includes/WatchlistEditor.php @@ -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 diff --git a/includes/Wiki.php b/includes/Wiki.php index 0c65b4aaa2..366dd887ea 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -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 ); diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index bfae025b64..8202c60176 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -232,7 +232,7 @@ class ApiDelete extends ApiBase { ApiBase::PARAM_DFLT => false, ApiBase::PARAM_DEPRECATED => true, ), - 'oldimage' => null + 'oldimage' => null, ); } diff --git a/includes/db/Database.php b/includes/db/Database.php index d29d142f70..444b800c4c 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -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; } diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index 1284ce5461..23efcfceaa 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -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; } diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index 041ebd16d3..75e28f379f 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -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; diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 672e022b4c..d3c3eb57e5 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -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; diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index a1f5276c6d..c01837a17c 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -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]) { diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index 34de8b7421..77b1b16bdf 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -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; diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index 3ce2415867..51b5ab8a09 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -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 ); diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index 96ec28f215..50a83f6c9a 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -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; } diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index fb97f87f2a..ce363745be 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -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], diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index 9175b5af0c..f879a65f09 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -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(); diff --git a/includes/specials/SpecialAllmessages.php b/includes/specials/SpecialAllmessages.php index c36ed2b7bf..01065a3388 100644 --- a/includes/specials/SpecialAllmessages.php +++ b/includes/specials/SpecialAllmessages.php @@ -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 ); diff --git a/includes/specials/SpecialCategories.php b/includes/specials/SpecialCategories.php index 35dadf9fac..5cf567b882 100644 --- a/includes/specials/SpecialCategories.php +++ b/includes/specials/SpecialCategories.php @@ -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(); diff --git a/includes/specials/SpecialDisambiguations.php b/includes/specials/SpecialDisambiguations.php index 08d8e12d5a..3e706189e4 100644 --- a/includes/specials/SpecialDisambiguations.php +++ b/includes/specials/SpecialDisambiguations.php @@ -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 )); } } diff --git a/includes/specials/SpecialExport.php b/includes/specials/SpecialExport.php index 2c26576713..5f56befd89 100644 --- a/includes/specials/SpecialExport.php +++ b/includes/specials/SpecialExport.php @@ -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 ) { diff --git a/includes/specials/SpecialIpblocklist.php b/includes/specials/SpecialIpblocklist.php index a6d5ba2b25..2fee3f2f50 100644 --- a/includes/specials/SpecialIpblocklist.php +++ b/includes/specials/SpecialIpblocklist.php @@ -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 ); diff --git a/includes/specials/SpecialListfiles.php b/includes/specials/SpecialListfiles.php index 9a5d91e4b7..ed48f56c70 100644 --- a/includes/specials/SpecialListfiles.php +++ b/includes/specials/SpecialListfiles.php @@ -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 ) ); } diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index 9eb8820a49..b59f80eb85 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -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 ) ); diff --git a/includes/specials/SpecialMostlinked.php b/includes/specials/SpecialMostlinked.php index 387bb54ab5..c731588a76 100644 --- a/includes/specials/SpecialMostlinked.php +++ b/includes/specials/SpecialMostlinked.php @@ -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(); } diff --git a/includes/specials/SpecialMostlinkedcategories.php b/includes/specials/SpecialMostlinkedcategories.php index d18c5b738d..e1fc1d9550 100644 --- a/includes/specials/SpecialMostlinkedcategories.php +++ b/includes/specials/SpecialMostlinkedcategories.php @@ -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 diff --git a/includes/specials/SpecialMostlinkedtemplates.php b/includes/specials/SpecialMostlinkedtemplates.php index cfc791d0ad..71df9044c5 100644 --- a/includes/specials/SpecialMostlinkedtemplates.php +++ b/includes/specials/SpecialMostlinkedtemplates.php @@ -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(); diff --git a/includes/specials/SpecialNewimages.php b/includes/specials/SpecialNewimages.php index 53a92fc181..596221501a 100644 --- a/includes/specials/SpecialNewimages.php +++ b/includes/specials/SpecialNewimages.php @@ -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 { diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index d42aabde53..f053fe3a9c 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -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 ); diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index 2b01412128..96a53c5635 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -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(); diff --git a/includes/specials/SpecialProtectedtitles.php b/includes/specials/SpecialProtectedtitles.php index b2166c3d5f..5e3ad6c8f6 100644 --- a/includes/specials/SpecialProtectedtitles.php +++ b/includes/specials/SpecialProtectedtitles.php @@ -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 ); } diff --git a/includes/specials/SpecialStatistics.php b/includes/specials/SpecialStatistics.php index 1d06d89bd1..7eb1a2fb05 100644 --- a/includes/specials/SpecialStatistics.php +++ b/includes/specials/SpecialStatistics.php @@ -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 ), diff --git a/includes/specials/SpecialTags.php b/includes/specials/SpecialTags.php index b0368c7ccf..c2aecf4731 100644 --- a/includes/specials/SpecialTags.php +++ b/includes/specials/SpecialTags.php @@ -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 ); } diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 8563f1b931..c98caebc47 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -739,7 +739,7 @@ class UndeleteForm extends SpecialPage { $sk = $wgUser->getSkin(); $undelete = $this->getTitle(); $wgOut->addHTML( "