X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=maintenance%2FpopulateIpChanges.php;h=6e88dfaeac55ed05e310cb8223a28839342bb926;hp=fbe16de5418a5bb5264ad4775ad119142d28de77;hb=a2c8c2969420a0f150c03f76e3a0bf9028fcda43;hpb=095a2a05b2aaccff26d7b871194a4edccd092707 diff --git a/maintenance/populateIpChanges.php b/maintenance/populateIpChanges.php index fbe16de541..6e88dfaeac 100644 --- a/maintenance/populateIpChanges.php +++ b/maintenance/populateIpChanges.php @@ -75,20 +75,32 @@ TEXT $start = $this->getOption( 'rev-id', 0 ); $end = $maxRevId > 0 ? $maxRevId - : $dbw->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ ); + : $dbw->selectField( 'revision', 'MAX(rev_id)', '', __METHOD__ ); + + if ( empty( $end ) ) { + $this->output( "No revisions found, aborting.\n" ); + return true; + } + $blockStart = $start; $attempted = 0; $inserted = 0; $this->output( "Copying IP revisions to ip_changes, from rev_id $start to rev_id $end\n" ); + $actorMigration = ActorMigration::newMigration(); + $actorQuery = $actorMigration->getJoin( 'rev_user' ); + $revUserIsAnon = $actorMigration->isAnon( $actorQuery['fields']['rev_user'] ); + while ( $blockStart <= $end ) { $blockEnd = min( $blockStart + $this->getBatchSize(), $end ); $rows = $dbr->select( - 'revision', - [ 'rev_id', 'rev_timestamp', 'rev_user_text' ], - [ "rev_id BETWEEN " . (int)$blockStart . " AND " . (int)$blockEnd, 'rev_user' => 0 ], - __METHOD__ + [ 'revision' ] + $actorQuery['tables'], + [ 'rev_id', 'rev_timestamp', 'rev_user_text' => $actorQuery['fields']['rev_user_text'] ], + [ "rev_id BETWEEN " . (int)$blockStart . " AND " . (int)$blockEnd, $revUserIsAnon ], + __METHOD__, + [], + $actorQuery['joins'] ); $numRows = $rows->numRows();