24require_once __DIR__ .
'/Maintenance.php';
39 parent::__construct();
41 $this->
addOption(
'ns',
'Namespace to run in, or "all" for all namespaces',
true,
true );
42 $this->
addOption(
'table',
'Table to run in',
true,
true );
49 $this->wikiId = $dbw->getDomainID();
50 $this->wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
53 if ( !ctype_digit( $ns ) && $ns !==
'all' ) {
54 $this->
error(
'Invalid namespace', 1 );
56 $ns = $ns ===
'all' ?
'all' : (int)$ns;
67 $this->
error(
"Invalid table name: $table", 1 );
72 $contentModelKey = $this->wanCache->makeKey(
'page',
'content-model', $rev_id );
74 $this->wanCache->makeGlobalKey(
'revision', $this->wikiId, $page_id, $rev_id );
77 $this->wanCache->delete( $contentModelKey );
80 $this->wanCache->delete( $revisionKey );
84 $count = count( $pageIds );
85 $this->
output(
"Setting $count rows to $model..." );
88 [
'page_content_model' => $model ],
89 [
'page_id' => $pageIds ],
93 $this->
output(
"done.\n" );
99 $nsCondition = $ns ===
'all' ? [] : [
'page_namespace' => $ns ];
103 [
'page_namespace',
'page_title',
'page_id' ],
105 'page_content_model' =>
null,
106 'page_id > ' . $dbw->
addQuotes( $lastId ),
109 [
'LIMIT' => $this->mBatchSize,
'ORDER BY' =>
'page_id ASC' ]
111 $this->
output(
"Fetched {$rows->numRows()} rows.\n" );
112 foreach (
$rows as $row ) {
113 $title = Title::newFromRow( $row );
115 $toSave[$model][] = $row->page_id;
116 if ( count( $toSave[$model] ) >= $this->mBatchSize ) {
118 unset( $toSave[$model] );
120 $lastId = $row->page_id;
122 }
while (
$rows->numRows() >= $this->mBatchSize );
123 foreach ( $toSave as $model => $pages ) {
129 $prefix = $table ===
'archive' ?
'ar' :
'rev';
130 $model_column =
"{$prefix}_content_model";
131 $format_column =
"{$prefix}_content_format";
132 $key =
"{$prefix}_id";
134 $count = count( $ids );
136 $this->
output(
"Setting $count rows to $model / $format..." );
139 [ $model_column => $model, $format_column => $format ],
144 $this->
output(
"done.\n" );
148 $prefix = $table ===
'archive' ?
'ar' :
'rev';
149 $model_column =
"{$prefix}_content_model";
150 $format_column =
"{$prefix}_content_format";
151 $key =
"{$prefix}_id";
152 if ( $table ===
'archive' ) {
153 $selectTables =
'archive';
154 $fields = [
'ar_namespace',
'ar_title' ];
156 $where = $ns ===
'all' ? [] : [
'ar_namespace' => $ns ];
157 $page_id_column =
'ar_page_id';
158 $rev_id_column =
'ar_rev_id';
160 $selectTables = [
'revision',
'page' ];
161 $fields = [
'page_title',
'page_namespace' ];
162 $join_conds = [
'page' => [
'INNER JOIN',
'rev_page=page_id' ] ];
163 $where = $ns ===
'all' ? [] : [
'page_namespace' => $ns ];
164 $page_id_column =
'rev_page';
165 $rev_id_column =
'rev_id';
176 [ $model_column, $format_column, $key, $page_id_column, $rev_id_column ]
180 $model_column =>
null,
184 [
'LIMIT' => $this->mBatchSize,
'ORDER BY' =>
"$key ASC" ],
187 $this->
output(
"Fetched {$rows->numRows()} rows.\n" );
188 foreach (
$rows as $row ) {
189 if ( $table ===
'archive' ) {
190 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
192 $title = Title::newFromRow( $row );
194 $lastId = $row->{$key};
198 $this->
error(
"Invalid content model for $title" );
201 $defaultModel =
$handler->getModelID();
202 $defaultFormat =
$handler->getDefaultFormat();
203 $dbModel = $row->{$model_column};
204 $dbFormat = $row->{$format_column};
206 if ( $dbModel ===
null && $dbFormat ===
null ) {
208 $toSave[$defaultModel][] = $row->{$key};
210 'page_id' => $row->{$page_id_column},
211 'rev_id' => $row->{$rev_id_column},
214 if ( $dbFormat === $defaultFormat ) {
215 $toSave[$defaultModel][] = $row->{$key};
217 'page_id' => $row->{$page_id_column},
218 'rev_id' => $row->{$rev_id_column},
221 $this->
output(
"Updating model to match format for $table $id of $title... " );
224 [ $model_column => $defaultModel ],
229 $this->clearCache( $row->{$page_id_column}, $row->{$rev_id_column} );
230 $this->
output(
"done.\n" );
235 if ( count( $toSave[$defaultModel] ) >= $this->mBatchSize ) {
236 $this->updateRevisionOrArchiveRows( $dbw, $toSave[$defaultModel], $defaultModel, $table );
237 unset( $toSave[$defaultModel] );
240 }
while (
$rows->numRows() >= $this->mBatchSize );
241 foreach ( $toSave as $model => $ids ) {
242 $this->updateRevisionOrArchiveRows( $dbw, $ids, $model, $table );
245 foreach ( $idsToClear as $idPair ) {
246 $this->clearCache( $idPair[
'page_id'], $idPair[
'rev_id'] );
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
setBatchSize( $s=0)
Set the batch size.
Usage: populateContentModel.php –ns=1 –table=page.
clearCache( $page_id, $rev_id)
populateRevisionOrArchive(IDatabase $dbw, $table, $ns)
execute()
Do the actual work.
__construct()
Default constructor.
updateRevisionOrArchiveRows(IDatabase $dbw, $ids, $model, $table)
updatePageRows(IDatabase $dbw, $pageIds, $model)
populatePage(IDatabase $dbw, $ns)
Multi-datacenter aware caching interface.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
returning false will NOT prevent logging $e
require_once RUN_MAINTENANCE_IF_MAIN