X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FpopulateIpChanges.php;h=c173270d21fc0dffee08004aa898d3d56c8f2695;hb=4c15a41b3364ba34787d2cc17147a7b9512827ff;hp=ffb8c43b300cfe3f41f45ea8255e8616180f83f3;hpb=870eaf7c95b407f139c441f2528b2132fd9015a8;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateIpChanges.php b/maintenance/populateIpChanges.php index ffb8c43b30..c173270d21 100644 --- a/maintenance/populateIpChanges.php +++ b/maintenance/populateIpChanges.php @@ -46,6 +46,12 @@ then be available when querying for IP ranges at Special:Contributions. TEXT ); $this->addOption( 'rev-id', 'The rev_id to start copying from. Default: 0', false, true ); + $this->addOption( + 'max-rev-id', + 'The rev_id to stop at. Default: result of MAX(rev_id)', + false, + true + ); $this->addOption( 'throttle', 'Wait this many milliseconds after copying each batch of revisions. Default: 0', @@ -57,20 +63,25 @@ TEXT public function doDBUpdates() { $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + $dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] ); $dbw = $this->getDB( DB_MASTER ); $throttle = intval( $this->getOption( 'throttle', 0 ) ); + $maxRevId = intval( $this->getOption( 'max-rev-id', 0 ) ); $start = $this->getOption( 'rev-id', 0 ); - $end = $dbw->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ ); + $end = $maxRevId > 0 + ? $maxRevId + : $dbw->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ ); $blockStart = $start; $revCount = 0; $this->output( "Copying IP revisions to ip_changes, from rev_id $start to rev_id $end\n" ); while ( $blockStart <= $end ) { - $rows = $dbw->select( + $blockEnd = min( $blockStart + 200, $end ); + $rows = $dbr->select( 'revision', [ 'rev_id', 'rev_timestamp', 'rev_user_text' ], - [ "rev_id >= $blockStart", 'rev_user' => 0 ], + [ "rev_id BETWEEN $blockStart AND $blockEnd", 'rev_user' => 0 ], __METHOD__, [ 'ORDER BY' => 'rev_id ASC', 'LIMIT' => $this->mBatchSize ] ); @@ -80,7 +91,7 @@ TEXT } $this->output( "...checking $this->mBatchSize revisions for IP edits that need copying, " . - "starting with rev_id $blockStart\n" ); + "between rev_ids $blockStart and $blockEnd\n" ); $insertRows = []; foreach ( $rows as $row ) {