populateIpChanges.php: Insert rows in batches
authorReedy <reedy@wikimedia.org>
Wed, 13 Sep 2017 22:22:19 +0000 (23:22 +0100)
committerLegoktm <legoktm@member.fsf.org>
Wed, 13 Sep 2017 22:56:34 +0000 (22:56 +0000)
Change-Id: I0233b5a17fc64751514ec6d0701f155a73906873

maintenance/populateIpChanges.php

index e086c5e..ffb8c43 100644 (file)
@@ -82,19 +82,15 @@ TEXT
                        $this->output( "...checking $this->mBatchSize revisions for IP edits that need copying, " .
                                "starting with rev_id $blockStart\n" );
 
                        $this->output( "...checking $this->mBatchSize revisions for IP edits that need copying, " .
                                "starting with rev_id $blockStart\n" );
 
+                       $insertRows = [];
                        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 ) ) {
                        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 ) ) {
-                                       $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'
-                                       );
+                                       $insertRows[] = [
+                                               'ipc_rev_id' => $row->rev_id,
+                                               'ipc_rev_timestamp' => $row->rev_timestamp,
+                                               'ipc_hex' => IP::toHex( $row->rev_user_text ),
+                                       ];
 
                                        $revCount++;
                                }
 
                                        $revCount++;
                                }
@@ -104,6 +100,13 @@ TEXT
 
                        $blockStart++;
 
 
                        $blockStart++;
 
+                       $dbw->insert(
+                               'ip_changes',
+                               $insertRows,
+                               __METHOD__,
+                               'IGNORE'
+                       );
+
                        $lbFactory->waitForReplication();
                        usleep( $throttle * 1000 );
                }
                        $lbFactory->waitForReplication();
                        usleep( $throttle * 1000 );
                }