36 $builder = $dbr->newSelectQueryBuilder()
37 ->caller( __METHOD__ )
39 ->where( [
'page_is_redirect' => 1 ] );
41 $this->
output(
"Fixing inconsistent redirects ...\n" );
43 $estimateCount = $builder->estimateRowCount();
44 $this->
output(
"Estimated redirect page count: $estimateCount\n" );
48 ->leftJoin(
'redirect',
null,
'page_id=rd_from' )
49 ->select( [
'rd_from',
'rd_interwiki',
'rd_fragment' ] );
52 $index = [
'page_is_redirect',
'page_namespace',
'page_len',
'page_id' ];
53 $builder->select( $index )->orderBy( $index );
59 $res = ( clone $builder )
60 ->where( $prevRow ? [ $dbr->buildComparison(
'>', $prevRow ) ] : [] )
61 ->caller( __METHOD__ )->fetchResultSet();
63 foreach ( $res as $row ) {
66 if ( $row->rd_from ===
null || $row->rd_interwiki ===
null || $row->rd_fragment ===
null ) {
67 RefreshLinks::fixRedirect( $this, $row->page_id );
71 if ( isset( $row ) ) {
73 foreach ( $index as $field ) {
74 $prevRow[ $field ] = $row->$field;
79 $total += $res->numRows();
80 $this->
output(
"$updated/$total\n" );
82 }
while ( $res->numRows() == $this->getBatchSize() );
84 $this->
output(
"Done, updated $updated of $total rows.\n" );