90 if ( $this->processed % $this->reportInterval != 0 ) {
96 $now = microtime(
true );
98 $estimatedTotalTime = $delta / $portion;
99 $eta = $this->startTime + $estimatedTotalTime;
102 sprintf(
"%s %s: %6.2f%% done on %s; ETA %s [%d/%d] %.2f/sec <%.2f%% updated>\n",
103 WikiMap::getCurrentWikiDbDomain()->getId(),
110 $this->processed / $delta,
121 $dbr = $this->getReplicaDB();
123 if ( array_diff( array_keys(
$params ),
124 [
'table',
'conds',
'index',
'callback' ] )
126 $this->fatalError( __METHOD__ .
': Missing parameter ' . implode(
', ',
$params ) );
131 $count = $dbr->newSelectQueryBuilder()
133 ->caller( __METHOD__ )
134 ->estimateRowCount();
136 $this->output(
"Processing $table...\n" );
138 $index = (array)
$params[
'index'];
140 $callback = [ $this,
$params[
'callback'] ];
143 $conds = array_merge(
$params[
'conds'], $indexConds );
144 $res = $dbr->newSelectQueryBuilder()
148 ->orderBy( implode(
',', $index ) )
149 ->limit( $this->getBatchSize() )
150 ->caller( __METHOD__ )->fetchResultSet();
151 if ( !$res->numRows() ) {
156 foreach ( $res as $row ) {
157 call_user_func( $callback, $row );
160 if ( $res->numRows() < $this->getBatchSize() ) {
167 foreach ( $index as $field ) {
169 $conds[ $field ] = $row->$field;
171 $indexConds = [ $dbr->buildComparison(
'>', $conds ) ];
174 $this->output(
"Finished $table... $this->updated of $this->processed rows updated\n" );