Yet another attempt to fix the populateIpChanges script
[lhc/web/wiklou.git] / maintenance / populateCategory.php
index ab0ca1e..5dccdd6 100644 (file)
@@ -25,7 +25,7 @@
 require_once __DIR__ . '/Maintenance.php';
 
 /**
- * Mainteance script to populate the category table.
+ * Maintenance script to populate the category table.
  *
  * @ingroup Maintenance
  */
@@ -35,7 +35,8 @@ class PopulateCategory extends Maintenance {
 
        public function __construct() {
                parent::__construct();
-               $this->mDescription = <<<TEXT
+               $this->addDescription(
+                       <<<TEXT
 This script will populate the category table, added in MediaWiki 1.13.  It will
 print out progress indicators every 1000 categories it adds to the table.  The
 script is perfectly safe to run on large, live wikis, and running it multiple
@@ -49,20 +50,15 @@ added after the software update and so will be populated anyway.
 
 When the script has finished, it will make a note of this in the database, and
 will not run again without the --force option.
-TEXT;
-# '
+TEXT
+               );
+
                $this->addOption(
                        'begin',
                        'Only do categories whose names are alphabetically after the provided name',
                        false,
                        true
                );
-               $this->addOption(
-                       'max-slave-lag',
-                       'If slave lag exceeds this many seconds, wait until it drops before continuing. Default: 10',
-                       false,
-                       true
-               );
                $this->addOption(
                        'throttle',
                        'Wait this many milliseconds after each category. Default: 0',
@@ -74,20 +70,16 @@ TEXT;
 
        public function execute() {
                $begin = $this->getOption( 'begin', '' );
-               $maxSlaveLag = $this->getOption( 'max-slave-lag', 10 );
                $throttle = $this->getOption( 'throttle', 0 );
-               $force = $this->getOption( 'force', false );
-               $this->doPopulateCategory( $begin, $maxSlaveLag, $throttle, $force );
-       }
+               $force = $this->hasOption( 'force' );
 
-       private function doPopulateCategory( $begin, $maxlag, $throttle, $force ) {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                if ( !$force ) {
                        $row = $dbw->selectRow(
                                'updatelog',
                                '1',
-                               array( 'ul_key' => 'populate category' ),
+                               [ 'ul_key' => 'populate category' ],
                                __METHOD__
                        );
                        if ( $row ) {
@@ -114,9 +106,9 @@ TEXT;
                                'cl_to',
                                $where,
                                __METHOD__,
-                               array(
+                               [
                                        'ORDER BY' => 'cl_to'
-                               )
+                               ]
                        );
                        if ( !$row ) {
                                # Done, hopefully.
@@ -143,7 +135,7 @@ TEXT;
 
                if ( $dbw->insert(
                        'updatelog',
-                       array( 'ul_key' => 'populate category' ),
+                       [ 'ul_key' => 'populate category' ],
                        __METHOD__,
                        'IGNORE'
                ) ) {