X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FpopulateContentModel.php;h=8d64dae3ab87e0dd926859f754dcce9f42783b86;hb=c99e9beff7d7c1a5a48f8d6f869a42425021c62b;hp=d99f70a10ea2dd87f4373e235af91a51483dc5c1;hpb=0e4b7cef64e9ba1b10310f0fcd8d85bb189788f9;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateContentModel.php b/maintenance/populateContentModel.php index d99f70a10e..8d64dae3ab 100644 --- a/maintenance/populateContentModel.php +++ b/maintenance/populateContentModel.php @@ -51,7 +51,7 @@ class PopulateContentModel extends Maintenance { $ns = $this->getOption( 'ns' ); if ( !ctype_digit( $ns ) && $ns !== 'all' ) { - $this->error( 'Invalid namespace', 1 ); + $this->fatalError( 'Invalid namespace' ); } $ns = $ns === 'all' ? 'all' : (int)$ns; $table = $this->getOption( 'table' ); @@ -64,7 +64,7 @@ class PopulateContentModel extends Maintenance { $this->populatePage( $dbw, $ns ); break; default: - $this->error( "Invalid table name: $table", 1 ); + $this->fatalError( "Invalid table name: $table" ); } } @@ -97,6 +97,7 @@ class PopulateContentModel extends Maintenance { $toSave = []; $lastId = 0; $nsCondition = $ns === 'all' ? [] : [ 'page_namespace' => $ns ]; + $batchSize = $this->getBatchSize(); do { $rows = $dbw->select( 'page', @@ -106,20 +107,20 @@ class PopulateContentModel extends Maintenance { 'page_id > ' . $dbw->addQuotes( $lastId ), ] + $nsCondition, __METHOD__, - [ 'LIMIT' => $this->mBatchSize, 'ORDER BY' => 'page_id ASC' ] + [ 'LIMIT' => $batchSize, 'ORDER BY' => 'page_id ASC' ] ); $this->output( "Fetched {$rows->numRows()} rows.\n" ); foreach ( $rows as $row ) { $title = Title::newFromRow( $row ); $model = ContentHandler::getDefaultModelFor( $title ); $toSave[$model][] = $row->page_id; - if ( count( $toSave[$model] ) >= $this->mBatchSize ) { + if ( count( $toSave[$model] ) >= $batchSize ) { $this->updatePageRows( $dbw, $toSave[$model], $model ); unset( $toSave[$model] ); } $lastId = $row->page_id; } - } while ( $rows->numRows() >= $this->mBatchSize ); + } while ( $rows->numRows() >= $batchSize ); foreach ( $toSave as $model => $pages ) { $this->updatePageRows( $dbw, $pages, $model ); } @@ -168,6 +169,7 @@ class PopulateContentModel extends Maintenance { $toSave = []; $idsToClear = []; $lastId = 0; + $batchSize = $this->getBatchSize(); do { $rows = $dbw->select( $selectTables, @@ -181,7 +183,7 @@ class PopulateContentModel extends Maintenance { "$key > " . $dbw->addQuotes( $lastId ), ] + $where, __METHOD__, - [ 'LIMIT' => $this->mBatchSize, 'ORDER BY' => "$key ASC" ], + [ 'LIMIT' => $batchSize, 'ORDER BY' => "$key ASC" ], $join_conds ); $this->output( "Fetched {$rows->numRows()} rows.\n" ); @@ -232,12 +234,12 @@ class PopulateContentModel extends Maintenance { } } - if ( count( $toSave[$defaultModel] ) >= $this->mBatchSize ) { + if ( count( $toSave[$defaultModel] ) >= $batchSize ) { $this->updateRevisionOrArchiveRows( $dbw, $toSave[$defaultModel], $defaultModel, $table ); unset( $toSave[$defaultModel] ); } } - } while ( $rows->numRows() >= $this->mBatchSize ); + } while ( $rows->numRows() >= $batchSize ); foreach ( $toSave as $model => $ids ) { $this->updateRevisionOrArchiveRows( $dbw, $ids, $model, $table ); } @@ -248,5 +250,5 @@ class PopulateContentModel extends Maintenance { } } -$maintClass = 'PopulateContentModel'; +$maintClass = PopulateContentModel::class; require_once RUN_MAINTENANCE_IF_MAIN;