X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FpopulateIpChanges.php;h=4becf6dd4d400d76eb3e5936358266d6b96dc92b;hb=f53e975b3463197abdd6a4bff476e47f03f4bb0e;hp=2b2a2b433d9bc0095e4925a54afc334da645e599;hpb=c379c9cb6a606322d7e1e47abf002d0b3438b26e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateIpChanges.php b/maintenance/populateIpChanges.php index 2b2a2b433d..4becf6dd4d 100644 --- a/maintenance/populateIpChanges.php +++ b/maintenance/populateIpChanges.php @@ -62,9 +62,14 @@ TEXT } public function doDBUpdates() { + $dbw = $this->getDB( DB_MASTER ); + + if ( !$dbw->tableExists( 'ip_changes' ) ) { + $this->fatalError( 'ip_changes table does not exist' ); + } + $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 ); @@ -78,7 +83,7 @@ TEXT $this->output( "Copying IP revisions to ip_changes, from rev_id $start to rev_id $end\n" ); while ( $blockStart <= $end ) { - $blockEnd = min( $blockStart + $this->mBatchSize, $end ); + $blockEnd = min( $blockStart + $this->getBatchSize(), $end ); $rows = $dbr->select( 'revision', [ 'rev_id', 'rev_timestamp', 'rev_user_text' ], @@ -110,14 +115,11 @@ TEXT } } - $dbw->insert( - 'ip_changes', - $insertRows, - __METHOD__, - 'IGNORE' - ); + if ( $insertRows ) { + $dbw->insert( 'ip_changes', $insertRows, __METHOD__, 'IGNORE' ); - $inserted += $dbw->affectedRows(); + $inserted += $dbw->affectedRows(); + } $lbFactory->waitForReplication(); usleep( $throttle * 1000 );