50 $builder = $dbr->newSelectQueryBuilder()
51 ->caller( __METHOD__ )
53 ->where( [
'page_is_redirect' => 1 ] );
55 $this->
output(
"Fixing inconsistent redirects ...\n" );
57 $estimateCount = $builder->estimateRowCount();
58 $this->
output(
"Estimated redirect page count: $estimateCount\n" );
62 ->leftJoin(
'redirect',
null,
'page_id=rd_from' )
63 ->select( [
'rd_from',
'rd_interwiki',
'rd_fragment' ] );
66 $index = [
'page_is_redirect',
'page_namespace',
'page_len',
'page_id' ];
67 $builder->select( $index )->orderBy( $index );
73 $res = ( clone $builder )
74 ->where( $prevRow ? [ $dbr->buildComparison(
'>', $prevRow ) ] : [] )
75 ->caller( __METHOD__ )->fetchResultSet();
77 foreach ( $res as $row ) {
80 if ( $row->rd_from ===
null || $row->rd_interwiki ===
null || $row->rd_fragment ===
null ) {
81 RefreshLinks::fixRedirect( $this, $row->page_id );
85 if ( isset( $row ) ) {
87 foreach ( $index as $field ) {
88 $prevRow[ $field ] = $row->$field;
93 $total += $res->numRows();
94 $this->
output(
"$updated/$total\n" );
96 }
while ( $res->numRows() == $this->getBatchSize() );
98 $this->
output(
"Done, updated $updated of $total rows.\n" );