+ $this->output( "Deleting illegal entries from the links tables...\n" );
+ $dbr = wfGetDB( DB_SLAVE );
+ do {
+ // Find the start of the next chunk. This is based only
+ // on existent page_ids.
+ $nextStart = $dbr->selectField(
+ 'page',
+ 'page_id',
+ self::intervalCond( $dbr, 'page_id', $start, $end ),
+ __METHOD__,
+ array( 'ORDER BY' => 'page_id', 'OFFSET' => $chunkSize )
+ );
+
+ if ( $nextStart !== false ) {
+ // To find the end of the current chunk, subtract one.
+ // This will serve to limit the number of rows scanned in
+ // dfnCheckInterval(), per query, to at most the sum of
+ // the chunk size and deletion batch size.
+ $chunkEnd = $nextStart - 1;
+ } else {
+ // This is the last chunk. Check all page_ids up to $end.
+ $chunkEnd = $end;
+ }
+
+ $fmtStart = $start !== null ? "[$start" : '(-INF';
+ $fmtChunkEnd = $chunkEnd !== null ? "$chunkEnd]" : 'INF)';
+ $this->output( " Checking interval $fmtStart, $fmtChunkEnd\n" );
+ $this->dfnCheckInterval( $start, $chunkEnd, $batchSize );
+
+ $start = $nextStart;