X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FrecountCategories.php;h=8ec648ff39d6bc60c7c7ff468d44af3ea15876ed;hb=7afced64454ad30d688540f7626448ac2faefebb;hp=a4bfa989921d70b0cd356a2e03414002c8b94def;hpb=9bf927316dfca8700b9fa62daae534c591f7c128;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/recountCategories.php b/maintenance/recountCategories.php index a4bfa98992..8ec648ff39 100644 --- a/maintenance/recountCategories.php +++ b/maintenance/recountCategories.php @@ -36,6 +36,12 @@ use MediaWiki\MediaWikiServices; * @ingroup Maintenance */ class RecountCategories extends Maintenance { + /** @var string */ + private $mode; + + /** @var int */ + private $minimumId; + public function __construct() { parent::__construct(); $this->addDescription( <<<'TEXT' @@ -75,7 +81,7 @@ TEXT public function execute() { $this->mode = $this->getOption( 'mode' ); if ( !in_array( $this->mode, [ 'pages', 'subcats', 'files' ] ) ) { - $this->error( 'Please specify a valid mode: one of "pages", "subcats" or "files".', 1 ); + $this->fatalError( 'Please specify a valid mode: one of "pages", "subcats" or "files".' ); } $this->minimumId = intval( $this->getOption( 'begin', 0 ) ); @@ -97,8 +103,8 @@ TEXT } protected function doWork() { - $this->output( "Finding up to {$this->mBatchSize} drifted rows " . - "starting at cat_id {$this->minimumId}...\n" ); + $this->output( "Finding up to {$this->getBatchSize()} drifted rows " . + "starting at cat_id {$this->getBatchSize()}...\n" ); $countingConds = [ 'cl_to = cat_title' ]; if ( $this->mode === 'subcats' ) { @@ -124,7 +130,7 @@ TEXT "cat_{$this->mode} != ($countingSubquery)" ], __METHOD__, - [ 'LIMIT' => $this->mBatchSize ] + [ 'LIMIT' => $this->getBatchSize() ] ); if ( !$idsToUpdate ) { return false; @@ -156,7 +162,7 @@ TEXT [ "cat_{$this->mode}" => $row->count ], [ 'cat_id' => $row->cat_id, - "cat_{$this->mode} != {$row->count}", + "cat_{$this->mode} != " . (int)( $row->count ), ], __METHOD__ ); $affectedRows += $dbw->affectedRows(); @@ -168,5 +174,5 @@ TEXT } } -$maintClass = 'RecountCategories'; +$maintClass = RecountCategories::class; require_once RUN_MAINTENANCE_IF_MAIN;