require_once __DIR__ . '/Maintenance.php';
use Wikimedia\Rdbms\IDatabase;
+use MediaWiki\MediaWikiServices;
/**
* Usage:
public function execute() {
$dbw = $this->getDB( DB_MASTER );
- $this->wikiId = $dbw->getWikiID();
-
- $this->wanCache = ObjectCache::getMainWANInstance();
+ $this->wikiId = $dbw->getDomainID();
+ $this->wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$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' );
$this->populatePage( $dbw, $ns );
break;
default:
- $this->error( "Invalid table name: $table", 1 );
+ $this->fatalError( "Invalid table name: $table" );
}
}
protected function clearCache( $page_id, $rev_id ) {
- $contentModelKey = $this->wanCache->makeKey( 'page', 'content-model', $rev_id );
+ $contentModelKey = $this->wanCache->makeKey( 'page-content-model', $rev_id );
$revisionKey =
$this->wanCache->makeGlobalKey( 'revision', $this->wikiId, $page_id, $rev_id );
$toSave = [];
$lastId = 0;
$nsCondition = $ns === 'all' ? [] : [ 'page_namespace' => $ns ];
+ $batchSize = $this->getBatchSize();
do {
$rows = $dbw->select(
'page',
'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 );
}
$toSave = [];
$idsToClear = [];
$lastId = 0;
+ $batchSize = $this->getBatchSize();
do {
$rows = $dbw->select(
$selectTables,
"$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" );
}
}
- 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 );
}
}
}
-$maintClass = 'PopulateContentModel';
+$maintClass = PopulateContentModel::class;
require_once RUN_MAINTENANCE_IF_MAIN;