From 159a34bc50d367debce16bca5dd9cb2dff236e6c Mon Sep 17 00:00:00 2001 From: MusikAnimal Date: Tue, 5 Sep 2017 17:21:55 -0400 Subject: [PATCH] Fix maintenance script that populates the ip_changes table Change-Id: Ice1bdae3d16cf365da14c6df0e8d91d2b914e065 --- maintenance/populateIpChanges.php | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/maintenance/populateIpChanges.php b/maintenance/populateIpChanges.php index 7a8bfc43e5..eb60f801cd 100644 --- a/maintenance/populateIpChanges.php +++ b/maintenance/populateIpChanges.php @@ -67,7 +67,7 @@ TEXT $this->output( "Copying IP revisions to ip_changes, from rev_id $start to rev_id $end\n" ); while ( $blockStart <= $end ) { - $cond = "rev_id > $blockStart AND rev_user = 0 ORDER BY rev_id ASC LIMIT " . $this->mBatchSize; + $cond = "rev_id >= $blockStart AND rev_user = 0 ORDER BY rev_id ASC LIMIT " . $this->mBatchSize; $rows = $dbw->select( 'revision', [ 'rev_id', 'rev_timestamp', 'rev_user_text' ], @@ -79,27 +79,27 @@ TEXT break; } - $this->output( "...copying $this->mBatchSize revisions starting with rev_id $blockStart\n" ); + $this->output( "...checking $this->mBatchSize revisions for IP edits that need copying, " . + "starting with rev_id $blockStart\n" ); foreach ( $rows as $row ) { // Double-check to make sure this is an IP, e.g. not maintenance user or imported revision. - if ( !IP::isValid( $row->rev_user_text ) ) { - continue; + if ( IP::isValid( $row->rev_user_text ) ) { + $dbw->insert( + 'ip_changes', + [ + 'ipc_rev_id' => $row->rev_id, + 'ipc_rev_timestamp' => $row->rev_timestamp, + 'ipc_hex' => IP::toHex( $row->rev_user_text ), + ], + __METHOD__, + 'IGNORE' + ); + + $revCount++; } - $dbw->insert( - 'ip_changes', - [ - 'ipc_rev_id' => $row->rev_id, - 'ipc_rev_timestamp' => $row->rev_timestamp, - 'ipc_hex' => IP::toHex( $row->rev_user_text ), - ], - __METHOD__, - 'IGNORE' - ); - $blockStart = (int)$row->rev_id; - $revCount++; } $blockStart++; -- 2.20.1