+ # Don't use HTML tidy
+ $wgUseTidy = false;
+
+ $what = $redirectsOnly ? "redirects" : "links";
+
+ if ( $oldRedirectsOnly ) {
+ # This entire code path is cut-and-pasted from below. Hurrah.
+ $res = $dbr->query(
+ "SELECT page_id " .
+ "FROM page " .
+ "LEFT JOIN redirect ON page_id=rd_from " .
+ "WHERE page_is_redirect=1 AND rd_from IS NULL AND " .
+ ( $end == 0 ? "page_id >= $start"
+ : "page_id BETWEEN $start AND $end" ),
+ __METHOD__
+ );
+ $num = $dbr->numRows( $res );
+ $this->output( "Refreshing $num old redirects from $start...\n" );
+
+ foreach ( $res as $row ) {
+ if ( !( ++$i % $reportingInterval ) ) {
+ $this->output( "$i\n" );
+ wfWaitForSlaves( $maxLag );
+ }
+ $this->fixRedirect( $row->page_id );
+ }
+ } elseif ( $newOnly ) {
+ $this->output( "Refreshing $what from " );
+ $res = $dbr->select( 'page',
+ array( 'page_id' ),
+ array(
+ 'page_is_new' => 1,
+ "page_id >= $start" ),
+ __METHOD__
+ );
+ $num = $dbr->numRows( $res );
+ $this->output( "$num new articles...\n" );
+
+ $i = 0;
+ foreach ( $res as $row ) {
+ if ( !( ++$i % $reportingInterval ) ) {
+ $this->output( "$i\n" );
+ wfWaitForSlaves( $maxLag );
+ }
+ if ( $redirectsOnly )
+ $this->fixRedirect( $row->page_id );
+ else
+ self::fixLinksFromArticle( $row->page_id );
+ }
+ } else {
+ if ( !$end ) {
+ $maxPage = $dbr->selectField( 'page', 'max(page_id)', false );
+ $maxRD = $dbr->selectField( 'redirect', 'max(rd_from)', false );
+ $end = max( $maxPage, $maxRD );
+ }
+ $this->output( "Refreshing redirects table.\n" );
+ $this->output( "Starting from page_id $start of $end.\n" );