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' ) {
56 $ns = $ns ===
'all' ?
'all' : (int)$ns;
67 $this->
fatalError(
"Invalid table name: $table" );
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 ];
104 [
'page_namespace',
'page_title',
'page_id' ],
106 'page_content_model' =>
null,
107 'page_id > ' . $dbw->
addQuotes( $lastId ),
110 [
'LIMIT' => $batchSize,
'ORDER BY' =>
'page_id ASC' ]
112 $this->
output(
"Fetched {$rows->numRows()} rows.\n" );
114 $title = Title::newFromRow( $row );
115 $model = ContentHandler::getDefaultModelFor(
$title );
116 $toSave[$model][] = $row->page_id;
117 if ( count( $toSave[$model] ) >= $batchSize ) {
119 unset( $toSave[$model] );
121 $lastId = $row->page_id;
123 }
while (
$rows->numRows() >= $batchSize );
124 foreach ( $toSave
as $model => $pages ) {
130 $prefix = $table ===
'archive' ?
'ar' :
'rev';
131 $model_column =
"{$prefix}_content_model";
132 $format_column =
"{$prefix}_content_format";
133 $key =
"{$prefix}_id";
135 $count = count( $ids );
136 $format = ContentHandler::getForModelID( $model )->getDefaultFormat();
137 $this->
output(
"Setting $count rows to $model / $format..." );
140 [ $model_column => $model, $format_column => $format ],
145 $this->
output(
"done.\n" );
149 $prefix = $table ===
'archive' ?
'ar' :
'rev';
150 $model_column =
"{$prefix}_content_model";
151 $format_column =
"{$prefix}_content_format";
152 $key =
"{$prefix}_id";
153 if ( $table ===
'archive' ) {
154 $selectTables =
'archive';
155 $fields = [
'ar_namespace',
'ar_title' ];
157 $where = $ns ===
'all' ? [] : [
'ar_namespace' => $ns ];
158 $page_id_column =
'ar_page_id';
159 $rev_id_column =
'ar_rev_id';
161 $selectTables = [
'revision',
'page' ];
162 $fields = [
'page_title',
'page_namespace' ];
163 $join_conds = [
'page' => [
'INNER JOIN',
'rev_page=page_id' ] ];
164 $where = $ns ===
'all' ? [] : [
'page_namespace' => $ns ];
165 $page_id_column =
'rev_page';
166 $rev_id_column =
'rev_id';
178 [ $model_column, $format_column, $key, $page_id_column, $rev_id_column ]
182 $model_column =>
null,
186 [
'LIMIT' => $batchSize,
'ORDER BY' =>
"$key ASC" ],
189 $this->
output(
"Fetched {$rows->numRows()} rows.\n" );
191 if ( $table ===
'archive' ) {
192 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
194 $title = Title::newFromRow( $row );
196 $lastId = $row->{$key};
200 $this->
error(
"Invalid content model for $title" );
203 $defaultModel =
$handler->getModelID();
204 $defaultFormat =
$handler->getDefaultFormat();
205 $dbModel = $row->{$model_column};
206 $dbFormat = $row->{$format_column};
208 if ( $dbModel ===
null && $dbFormat ===
null ) {
210 $toSave[$defaultModel][] = $row->{$key};
212 'page_id' => $row->{$page_id_column},
213 'rev_id' => $row->{$rev_id_column},
216 if ( $dbFormat === $defaultFormat ) {
217 $toSave[$defaultModel][] = $row->{$key};
219 'page_id' => $row->{$page_id_column},
220 'rev_id' => $row->{$rev_id_column},
223 $this->output(
"Updating model to match format for $table $id of $title... " );
226 [ $model_column => $defaultModel ],
231 $this->clearCache( $row->{$page_id_column}, $row->{$rev_id_column} );
232 $this->output(
"done.\n" );
237 if ( count( $toSave[$defaultModel] ) >= $batchSize ) {
238 $this->updateRevisionOrArchiveRows( $dbw, $toSave[$defaultModel], $defaultModel, $table );
239 unset( $toSave[$defaultModel] );
242 }
while (
$rows->numRows() >= $batchSize );
243 foreach ( $toSave as $model => $ids ) {
244 $this->updateRevisionOrArchiveRows( $dbw, $ids, $model, $table );
247 foreach ( $idsToClear as $idPair ) {
248 $this->clearCache( $idPair[
'page_id'], $idPair[
'rev_id'] );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
getBatchSize()
Returns batch size.
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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
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.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
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
namespace and then decline to actually register it file or subcat img or subcat $title
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
require_once RUN_MAINTENANCE_IF_MAIN