Creating edits from random IPs for testing the "get edits" feature of the CheckUser extension. See T145912
Mixed languages...
1) Create the page "Test" on your devwiki
2) Log in as an admin or bot
3) Open the JavaScript console and run:
api = new mw.Api();
i = 0;
function testEdit() {
console.log(i);
if (i === 1000) return;
api.postWithToken( "edit", {
action: "edit",
title: "Test",
text: Math.random().toString()
}).then(() => {
i += 1;
testEdit();
});
}
testEdit();
That makes 1,000 random edits on the page "Test". You must be an admin/bot to get around throttling limitations.
4) In vagrant, run `mwscript maintenance/eval.php`
5) Then this code:
use \IP;
$dbr = wfGetDB( DB_MASTER );
// use the ID of the "Test" page. For me it was 3
$res = $dbr->select( 'cu_changes', [ 'cuc_id' ], 'cuc_page_id = 3' );
foreach( $res as $row ) { $randIP = "192.0.0." . mt_rand( 0, 255 ); $dbr->update( 'cu_changes', [ 'cuc_user_text' => $randIP, 'cuc_ip' => $randIP, 'cuc_ip_hex' => IP::toHex( $randIP ) ], [ 'cuc_id' => $row->cuc_id ] ); $dbr->update( 'revision', [ 'rev_user_text' => $randIP, 'rev_user' => 0 ], [ 'rev_id' => $row->cuc_this_oldid ] ); }
Each set of commands is jumbled onto one line because I can't figure out how to do multi-line stuff with maintenance/eval.php...
After the above you'll have 1,000 edits by random IPs in the range 192.0.0.0/24. Note this only updates the IPs of the cu_changes table. Your revision table will still have your username, but that does not need to be updated for our purposes.