From: Sam Reed Date: Sun, 31 Oct 2010 23:08:38 +0000 (+0000) Subject: Switch last few uses of while loops to foreach in phase3 X-Git-Tag: 1.31.0-rc.0~34174 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=b5c9c3ddd6f49d61da7e1308f0bf49a46f58df2f;p=lhc%2Fweb%2Fwiklou.git Switch last few uses of while loops to foreach in phase3 --- diff --git a/includes/Export.php b/includes/Export.php index ae2427fdfa..bdb9d4af1f 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -167,7 +167,7 @@ class WikiExporter { WHERE page_id=rev_page AND $nothidden AND " . $cond ; $result = $this->db->query( $sql, __METHOD__ ); $resultset = $this->db->resultObject( $result ); - while( $row = $resultset->fetchObject() ) { + foreach ( $resultset as $row ) { $this->author_list .= "" . "" . htmlentities( $row->rev_user_text ) . diff --git a/includes/ImagePage.php b/includes/ImagePage.php index ea3ba16727..69f17d8811 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -644,7 +644,7 @@ EOT $sk = $wgUser->getSkin(); $count = 0; $elements = array(); - while ( $s = $res->fetchObject() ) { + foreach ( $res as $s ) { $count++; if ( $count <= $limit ) { // We have not yet reached the extra one that tells us there is more to fetch diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index b9113970f3..cc2f8ac4d6 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -416,7 +416,7 @@ class SpecialContributions extends SpecialPage { $feed->outHeader(); if( $pager->getNumRows() > 0 ) { - while( $row = $pager->mResult->fetchObject() ) { + foreach ( $pager->mResult as $row ) { $feed->outItem( $this->feedItem( $row ) ); } } diff --git a/includes/specials/SpecialListusers.php b/includes/specials/SpecialListusers.php index 007f058c64..abc0363a36 100644 --- a/includes/specials/SpecialListusers.php +++ b/includes/specials/SpecialListusers.php @@ -167,7 +167,7 @@ class UsersPager extends AlphabeticPager { } $this->mResult->rewind(); $batch = new LinkBatch; - while ( $row = $this->mResult->fetchObject() ) { + foreach ( $this->mResult as $row ) { $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) ); } $batch->execute(); diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index 8da2c08e44..498fa235f2 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -366,7 +366,7 @@ class SpecialNewpages extends IncludableSpecialPage { $feed->outHeader(); if( $pager->getNumRows() > 0 ) { - while( $row = $pager->mResult->fetchObject() ) { + foreach ( $pager->mResult->fetchObject() as $row ) { $feed->outItem( $this->feedItem( $row ) ); } } diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 69390f557a..1cf61d2653 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -492,7 +492,7 @@ class PageArchive { $revision = null; $restored = 0; - while( $row = $ret->fetchObject() ) { + foreach ( $ret as $row ) { // Check for key dupes due to shitty archive integrity. if( $row->ar_rev_id ) { $exists = $dbw->selectField( 'revision', '1', array('rev_id' => $row->ar_rev_id), __METHOD__ ); diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 3164e48977..859927ba10 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -294,13 +294,14 @@ class SpecialVersion extends SpecialPage { } if ( $cnt = count( $tags = $wgParser->getTags() ) ) { - for ( $i = 0; $i < $cnt; ++$i ) + for ( $i = 0; $i < $cnt; ++$i ) { $tags[$i] = "<{$tags[$i]}>"; + } $out .= $this->openExtType( wfMsg( 'version-parser-extensiontags' ), 'parser-tags' ); $out .= '' . $this->listToText( $tags ). "\n"; } - if( $cnt = count( $fhooks = $wgParser->getFunctionHooks() ) ) { + if( count( $fhooks = $wgParser->getFunctionHooks() ) ) { $out .= $this->openExtType( wfMsg( 'version-parser-function-hooks' ), 'parser-function-hooks' ); $out .= '' . $this->listToText( $fhooks ) . "\n"; }