From: Tim Starling Date: Thu, 19 Feb 2009 02:10:55 +0000 (+0000) Subject: Don't do any backlink batches if there are no backlinks. X-Git-Tag: 1.31.0-rc.0~42793 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=4f3efbf4065a98ea0a9b5d2bcbf8223207f12d7d;p=lhc%2Fweb%2Fwiklou.git Don't do any backlink batches if there are no backlinks. --- diff --git a/includes/BacklinkCache.php b/includes/BacklinkCache.php index 84f09f8fc8..b48a34a9ac 100644 --- a/includes/BacklinkCache.php +++ b/includes/BacklinkCache.php @@ -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 ); } diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index f566260a0c..92856e9f42 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -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;