X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FpopulateCategory.php;h=ce1506ca49d3e4287fec8d4f138208c1166faea7;hb=e8805741ed75a6f1fec01bc39962af75e6111c1c;hp=481e07363b35df27fad3e642a4717ff507d97419;hpb=77a8bbd406de8194432bbc92ce0b781ba44b43bc;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateCategory.php b/maintenance/populateCategory.php index 481e07363b..ce1506ca49 100644 --- a/maintenance/populateCategory.php +++ b/maintenance/populateCategory.php @@ -35,7 +35,8 @@ class PopulateCategory extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = <<addDescription( + <<addOption( 'begin', 'Only do categories whose names are alphabetically after the provided name', @@ -69,7 +71,7 @@ TEXT; public function execute() { $begin = $this->getOption( 'begin', '' ); $throttle = $this->getOption( 'throttle', 0 ); - $force = $this->getOption( 'force', false ); + $force = $this->hasOption( 'force' ); $dbw = $this->getDB( DB_MASTER ); @@ -77,7 +79,7 @@ TEXT; $row = $dbw->selectRow( 'updatelog', '1', - array( 'ul_key' => 'populate category' ), + [ 'ul_key' => 'populate category' ], __METHOD__ ); if ( $row ) { @@ -91,9 +93,9 @@ TEXT; $throttle = intval( $throttle ); if ( $begin !== '' ) { - $where = 'cl_to > ' . $dbw->addQuotes( $begin ); + $where = [ 'cl_to > ' . $dbw->addQuotes( $begin ) ]; } else { - $where = null; + $where = [ '1 = 1' ]; } $i = 0; @@ -104,9 +106,9 @@ TEXT; 'cl_to', $where, __METHOD__, - array( + [ 'ORDER BY' => 'cl_to' - ) + ] ); if ( !$row ) { # Done, hopefully. @@ -131,22 +133,16 @@ TEXT; usleep( $throttle * 1000 ); } - if ( $dbw->insert( + $dbw->insert( 'updatelog', - array( 'ul_key' => 'populate category' ), + [ 'ul_key' => 'populate category' ], __METHOD__, 'IGNORE' - ) ) { - $this->output( "Category population complete.\n" ); - - return true; - } else { - $this->output( "Could not insert category population row.\n" ); + ); - return false; - } + return true; } } -$maintClass = "PopulateCategory"; +$maintClass = PopulateCategory::class; require_once RUN_MAINTENANCE_IF_MAIN;