Don't do any backlink batches if there are no backlinks.
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 19 Feb 2009 02:10:55 +0000 (02:10 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 19 Feb 2009 02:10:55 +0000 (02:10 +0000)
includes/BacklinkCache.php
includes/LinksUpdate.php

index 84f09f8..b48a34a 100644 (file)
@@ -206,28 +206,24 @@ class BacklinkCache {
                $batches = array();
                $numRows = $res->numRows();
                $numBatches = ceil( $numRows / $batchSize );
-               if ( !$numRows ) {
-                       $batches = array( array( false, false ) );
-               } else {
-                       for ( $i = 0; $i < $numBatches; $i++ ) {
-                               if ( $i == 0  ) {
-                                       $start = false;
-                               } else {
-                                       $rowNum = intval( $numRows * $i / $numBatches );
-                                       $res->seek( $rowNum );
-                                       $row = $res->fetchObject();
-                                       $start = $row->page_id;
-                               }
-                               if ( $i == $numBatches - 1 ) {
-                                       $end = false;
-                               } else {
-                                       $rowNum = intval( $numRows * ( $i + 1 ) / $numBatches );
-                                       $res->seek( $rowNum );
-                                       $row = $res->fetchObject();
-                                       $end = $row->page_id - 1;
-                               }
-                               $batches[] = array( $start, $end );
+               for ( $i = 0; $i < $numBatches; $i++ ) {
+                       if ( $i == 0  ) {
+                               $start = false;
+                       } else {
+                               $rowNum = intval( $numRows * $i / $numBatches );
+                               $res->seek( $rowNum );
+                               $row = $res->fetchObject();
+                               $start = $row->page_id;
+                       }
+                       if ( $i == $numBatches - 1 ) {
+                               $end = false;
+                       } else {
+                               $rowNum = intval( $numRows * ( $i + 1 ) / $numBatches );
+                               $res->seek( $rowNum );
+                               $row = $res->fetchObject();
+                               $end = $row->page_id - 1;
                        }
+                       $batches[] = array( $start, $end );
                }
                return array( 'numRows' => $numRows, 'batches' => $batches );
        }
index f566260..92856e9 100644 (file)
@@ -198,6 +198,9 @@ class LinksUpdate {
 
                $cache = $this->mTitle->getBacklinkCache();
                $batches = $cache->partition( 'templatelinks', $wgUpdateRowsPerJob );
+               if ( !$batches ) {
+                       return;
+               }
                $jobs = array();
                foreach ( $batches as $batch ) {
                        list( $start, $end ) = $batch;