-class CapsCleanup extends FiveUpgrade {
- function CapsCleanup( $dryrun = false, $namespace=0 ) {
- parent::FiveUpgrade();
-
- $this->maxLag = 10; # if slaves are lagged more than 10 secs, wait
- $this->dryrun = $dryrun;
- $this->namespace = intval( $namespace );
- }
-
- function cleanup() {
- global $wgCapitalLinks;
- if( $wgCapitalLinks ) {
- echo "\$wgCapitalLinks is on -- no need for caps links cleanup.\n";
- return false;
- }
-
- $this->runTable( 'page', 'WHERE page_namespace=' . $this->namespace,
- array( &$this, 'processPage' ) );
- }
-
- function init( $count, $table ) {
- $this->processed = 0;
- $this->updated = 0;
- $this->count = $count;
- $this->startTime = wfTime();
- $this->table = $table;
- }
-
- function progress( $updated ) {
- $this->updated += $updated;
- $this->processed++;
- if( $this->processed % 100 != 0 ) {
- return;
- }
- $portion = $this->processed / $this->count;
- $updateRate = $this->updated / $this->processed;
-
- $now = wfTime();
- $delta = $now - $this->startTime;
- $estimatedTotalTime = $delta / $portion;
- $eta = $this->startTime + $estimatedTotalTime;
-
- printf( "%s: %6.2f%% done on %s; ETA %s [%d/%d] %.2f/sec <%.2f%% updated>\n",
- wfTimestamp( TS_DB, intval( $now ) ),
- $portion * 100.0,
- $this->table,
- wfTimestamp( TS_DB, intval( $eta ) ),
- $this->processed,
- $this->count,
- $this->processed / $delta,
- $updateRate * 100.0 );
- flush();
+/**
+ * Maintenance script to clean up broken page links when somebody turns on $wgCapitalLinks.
+ *
+ * @ingroup Maintenance
+ */
+class CapsCleanup extends TableCleanup {
+ public function __construct() {
+ parent::__construct();
+ $this->mDescription = "Script to cleanup capitalization";
+ $this->addOption( 'namespace', 'Namespace number to run caps cleanup on', false, true );