r112915 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112914‎ | r112915 | r112916 >
Date:20:35, 2 March 2012
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Don't execute the LinkBatch if there are now rows
* Call methods directly on ResultWrapper instead of DatabaseBase
Modified paths:
  • /trunk/phase3/includes/QueryPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/QueryPage.php
@@ -295,7 +295,7 @@
296296 $res = $this->reallyDoQuery( $limit, false );
297297 $num = false;
298298 if ( $res ) {
299 - $num = $dbr->numRows( $res );
 299+ $num = $res->numRows();
300300 # Fetch results
301301 $vals = array();
302302 while ( $res && $row = $dbr->fetchObject( $res ) ) {
@@ -733,6 +733,10 @@
734734 * Cache page existence for performance
735735 */
736736 function preprocessResults( $db, $res ) {
 737+ if ( !$res->numRows() ) {
 738+ return;
 739+ }
 740+
737741 $batch = new LinkBatch;
738742 foreach ( $res as $row ) {
739743 $batch->add( $row->namespace, $row->title );
@@ -740,9 +744,7 @@
741745 $batch->execute();
742746
743747 // Back to start for display
744 - if ( $db->numRows( $res ) > 0 )
745 - // If there are no rows we get an error seeking.
746 - $db->dataSeek( $res, 0 );
 748+ $res->seek( 0 );
747749 }
748750
749751 /**

Comments

#Comment by Nikerabbit (talk | contribs)   06:34, 5 March 2012

Can't the linkbatch itself check if it is empty?

Status & tagging log