r34638 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34637‎ | r34638 | r34639 >
Date:04:36, 12 May 2008
Author:aaron
Status:old
Tags:
Comment:
Add RENAMEUSER_CONTRIBJOB, and use jobqueue for the larger renames
Modified paths:
  • /trunk/extensions/Renameuser/SpecialRenameuser.php (modified) (history)
  • /trunk/extensions/Renameuser/SpecialRenameuser_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Renameuser/SpecialRenameuser_body.php
@@ -331,18 +331,23 @@
332332 'image' => 'img_user_text',
333333 'oldimage' => 'oi_user_text',
334334 'archive' => 'ar_user_text',
335 - 'revision' => 'rev_user_text'
 335+ // FIXME: 'filearchive' => 'fa_user_text'
336336 );
337337 $this->tablesJob = array();
338338 // See if this is for large tables on large, busy, wikis
339339 if( function_exists('wfQueriesMustScale') && wfQueriesMustScale() ) {
340 - #$this->tablesJob['revision'] = array('rev_user_text','rev_id');
 340+ // For users with many edits, be nice to servers
 341+ if( User::edits( $this->uid ) > RENAMEUSER_CONTRIBJOB ) {
 342+ $this->tablesJob['revision'] = array('rev_user_text','rev_id');
 343+ } else {
 344+ $this->tables['revision'] = 'rev_user_text';
 345+ }
 346+ // Recent changes is pretty hot, deadlocks occur if done all at once
341347 $this->tablesJob['recentchanges'] = array('rc_user_text','rc_id');
342348 } else {
343 - #$this->tables['revision'] = 'rev_user_text';
344349 $this->tables['recentchanges'] = 'rc_user_text';
 350+ $this->tables['revision'] = 'rev_user_text';
345351 }
346 -
347352 }
348353
349354 /**
@@ -353,7 +358,7 @@
354359
355360 wfProfileIn( __METHOD__ );
356361
357 - $dbw =& wfGetDB( DB_MASTER );
 362+ $dbw = wfGetDB( DB_MASTER );
358363 // Rename and touch the user before re-attributing edits,
359364 // this avoids users still being logged in and making new edits while
360365 // being renamed, which leaves edits at the old name.
@@ -384,15 +389,14 @@
385390 array( $field => $this->new ),
386391 array( $field => $this->old ),
387392 __METHOD__
388 - #,array( $dbw->lowPriorityOption() )
389393 );
390394 }
391395
392396 foreach( $this->tablesJob as $table => $params ) {
393397 $res = $dbw->select( $table,
394 - array( $params[0], $params[1] ),
395 - array( $params[0] => $this->old )
396 - );
 398+ array( $params[0], $params[1] ),
 399+ array( $params[0] => $this->old )
 400+ );
397401
398402 global $wgUpdateRowsPerJob;
399403
@@ -402,8 +406,8 @@
403407 $key = $params[1];
404408 $jobParams = array();
405409 $jobParams['table'] = $table;
406 - $jobParams['column'] = $params[0];
407 - $jobParams['uniqueKey'] = $key;
 410+ $jobParams['column'] = $params[0]; // some *_user_text column
 411+ $jobParams['uniqueKey'] = $key; // doesn't *have* to be unique
408412 $jobParams['oldname'] = $this->old;
409413 $jobParams['newname'] = $this->new;
410414
Index: trunk/extensions/Renameuser/SpecialRenameuser.php
@@ -32,8 +32,8 @@
3333 * The maximum number of edits a user can have and still be allowed renaming,
3434 * set it to 0 to disable the limit.
3535 */
36 -//define( 'RENAMEUSER_CONTRIBLIMIT', 6800 );
3736 define( 'RENAMEUSER_CONTRIBLIMIT', 200000 );
 37+define( 'RENAMEUSER_CONTRIBJOB', 50000 );
3838
3939 # Add a new log type
4040 global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions;

Status & tagging log