Switch last few uses of while loops to foreach in phase3
authorSam Reed <reedy@users.mediawiki.org>
Sun, 31 Oct 2010 23:08:38 +0000 (23:08 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 31 Oct 2010 23:08:38 +0000 (23:08 +0000)
includes/Export.php
includes/ImagePage.php
includes/specials/SpecialContributions.php
includes/specials/SpecialListusers.php
includes/specials/SpecialNewpages.php
includes/specials/SpecialUndelete.php
includes/specials/SpecialVersion.php

index ae2427f..bdb9d4a 100644 (file)
@@ -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 .= "<contributor>" .
                                "<username>" .
                                htmlentities( $row->rev_user_text )  .
index ea3ba16..69f17d8 100644 (file)
@@ -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
index b911397..cc2f8ac 100644 (file)
@@ -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 ) );
                        }
                }
index 007f058..abc0363 100644 (file)
@@ -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();
index 8da2c08..498fa23 100644 (file)
@@ -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 ) );
                        }
                }
index 69390f5..1cf61d2 100644 (file)
@@ -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__ );
index 3164e48..859927b 100644 (file)
@@ -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] = "&lt;{$tags[$i]}&gt;";
+            }
                        $out .= $this->openExtType( wfMsg( 'version-parser-extensiontags' ), 'parser-tags' );
                        $out .= '<tr><td colspan="4">' . $this->listToText( $tags ). "</td></tr>\n";
                }
 
-               if( $cnt = count( $fhooks = $wgParser->getFunctionHooks() ) ) {
+               if( count( $fhooks = $wgParser->getFunctionHooks() ) ) {
                        $out .= $this->openExtType( wfMsg( 'version-parser-function-hooks' ), 'parser-function-hooks' );
                        $out .= '<tr><td colspan="4">' . $this->listToText( $fhooks ) . "</td></tr>\n";
                }