48 $builder = $dbr->newSelectQueryBuilder()
49 ->caller( __METHOD__ )
51 ->where( [
'page_is_redirect' => 1 ] );
53 $this->
output(
"Fixing inconsistent redirects ...\n" );
55 $estimateCount = $builder->estimateRowCount();
56 $this->
output(
"Estimated redirect page count: $estimateCount\n" );
60 ->leftJoin(
'redirect',
null,
'page_id=rd_from' )
61 ->select( [
'rd_from',
'rd_interwiki',
'rd_fragment' ] );
64 $index = [
'page_is_redirect',
'page_namespace',
'page_len',
'page_id' ];
65 $builder->select( $index )->orderBy( $index );
71 $res = ( clone $builder )
72 ->where( $prevRow ? [ $dbr->buildComparison(
'>', $prevRow ) ] : [] )
73 ->caller( __METHOD__ )->fetchResultSet();
75 foreach ( $res as $row ) {
78 if ( $row->rd_from ===
null || $row->rd_interwiki ===
null || $row->rd_fragment ===
null ) {
79 RefreshLinks::fixRedirect( $this, $row->page_id );
83 if ( isset( $row ) ) {
85 foreach ( $index as $field ) {
86 $prevRow[ $field ] = $row->$field;
91 $total += $res->numRows();
92 $this->
output(
"$updated/$total\n" );
94 }
while ( $res->numRows() == $this->getBatchSize() );
96 $this->
output(
"Done, updated $updated of $total rows.\n" );