r70656 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70655‎ | r70656 | r70657 >
Date:23:43, 7 August 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Use for loops for iterating query results
Modified paths:
  • /trunk/phase3/includes/MessageCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/MessageCache.php
@@ -343,10 +343,9 @@
344344
345345 # Load titles for all oversized pages in the MediaWiki namespace
346346 $res = $dbr->select( 'page', 'page_title', $bigConds, __METHOD__ . "($code)-big" );
347 - while ( $row = $dbr->fetchObject( $res ) ) {
 347+ foreach ( $res as $row ) {
348348 $cache[$row->page_title] = '!TOO BIG';
349349 }
350 - $dbr->freeResult( $res );
351350
352351 # Conditions to load the remaining pages with their contents
353352 $smallConds = $conds;
@@ -358,10 +357,9 @@
359358 array( 'page_title', 'old_text', 'old_flags' ),
360359 $smallConds, __METHOD__ . "($code)-small" );
361360
362 - for ( $row = $dbr->fetchObject( $res ); $row; $row = $dbr->fetchObject( $res ) ) {
 361+ foreach ( $res as $row ) {
363362 $cache[$row->page_title] = ' ' . Revision::getRevisionText( $row );
364363 }
365 - $dbr->freeResult( $res );
366364
367365 $cache['VERSION'] = MSG_CACHE_VERSION;
368366 wfProfileOut( __METHOD__ );

Status & tagging log