r91996 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91995‎ | r91996 | r91997 >
Date:20:07, 12 July 2011
Author:demon
Status:ok
Tags:
Comment:
Make the batch size configurable. Default behavior remains the same
Modified paths:
  • /trunk/extensions/Renameuser/renameUserCleanup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Renameuser/renameUserCleanup.php
@@ -30,13 +30,12 @@
3131 require( "$IP/maintenance/Maintenance.php" );
3232
3333 class RenameUserCleanup extends Maintenance {
34 - const BATCH_SIZE = 1000;
35 -
3634 public function __construct() {
3735 parent::__construct();
3836 $this->mDescription = "Maintenance script to finish incomplete rename user, in particular to reassign edits that were missed";
3937 $this->addOption( 'olduser', 'Old user name', true, true );
4038 $this->addOption( 'newuser', 'New user name', true, true );
 39+ $this->mBatchSize = 1000;
4140 }
4241
4342 public function execute() {
@@ -145,7 +144,7 @@
146145 }
147146
148147 while ($contribs > 0) {
149 - print("doing batch of up to approximately ".self::BATCH_SIZE."\n");
 148+ print("doing batch of up to approximately ".$this->mBatchSize."\n");
150149 print("do this batch? [N/y] ");
151150 $stdin = fopen ("php://stdin","rt");
152151 $line = fgets($stdin);
@@ -156,7 +155,7 @@
157156 }
158157 $dbw->begin();
159158 $result = $dbw->select( $table, $timestampfield, $selectConds , __METHOD__,
160 - array( 'ORDER BY' => $timestampfield.' DESC', 'LIMIT' => self::BATCH_SIZE ) );
 159+ array( 'ORDER BY' => $timestampfield.' DESC', 'LIMIT' => $this->mBatchSize ) );
161160 if (! $result) {
162161 print("There were rows for updating but now they are gone. Skipping.\n");
163162 $dbw->rollback();

Status & tagging log