24require_once __DIR__ .
'/Maintenance.php';
32 parent::__construct();
34 $this->
addOption(
'ns',
'Namespace to run in, or "all" for all namespaces',
true,
true );
35 $this->
addOption(
'table',
'Table to run in',
true,
true );
42 if ( !ctype_digit( $ns ) && $ns !==
'all' ) {
43 $this->
error(
'Invalid namespace', 1 );
45 $ns = $ns ===
'all' ?
'all' : (int)$ns;
56 $this->
error(
"Invalid table name: $table", 1 );
61 $count = count( $pageIds );
62 $this->
output(
"Setting $count rows to $model..." );
65 [
'page_content_model' => $model ],
66 [
'page_id' => $pageIds ],
70 $this->
output(
"done.\n" );
76 $nsCondition = $ns ===
'all' ? [] : [
'page_namespace' => $ns ];
80 [
'page_namespace',
'page_title',
'page_id' ],
82 'page_content_model' =>
null,
83 'page_id > ' . $dbw->
addQuotes( $lastId ),
86 [
'LIMIT' => $this->mBatchSize,
'ORDER BY' =>
'page_id ASC' ]
88 $this->
output(
"Fetched {$rows->numRows()} rows.\n" );
89 foreach ( $rows
as $row ) {
90 $title = Title::newFromRow( $row );
92 $toSave[$model][] = $row->page_id;
93 if ( count( $toSave[$model] ) >= $this->mBatchSize ) {
95 unset( $toSave[$model] );
97 $lastId = $row->page_id;
99 }
while ( $rows->numRows() >= $this->mBatchSize );
100 foreach ( $toSave
as $model => $pages ) {
106 $prefix = $table ===
'archive' ?
'ar' :
'rev';
107 $model_column =
"{$prefix}_content_model";
108 $format_column =
"{$prefix}_content_format";
109 $key =
"{$prefix}_id";
113 $this->
output(
"Setting $count rows to $model / $format..." );
116 [ $model_column => $model, $format_column => $format ],
120 $this->
output(
"done.\n" );
124 $prefix = $table ===
'archive' ?
'ar' :
'rev';
125 $model_column =
"{$prefix}_content_model";
126 $format_column =
"{$prefix}_content_format";
127 $key =
"{$prefix}_id";
128 if ( $table ===
'archive' ) {
129 $selectTables =
'archive';
130 $fields = [
'ar_namespace',
'ar_title' ];
132 $where = $ns ===
'all' ? [] : [
'ar_namespace' => $ns ];
134 $selectTables = [
'revision',
'page' ];
135 $fields = [
'page_title',
'page_namespace' ];
136 $join_conds = [
'page' => [
'INNER JOIN',
'rev_page=page_id' ] ];
137 $where = $ns ===
'all' ? [] : [
'page_namespace' => $ns ];
145 array_merge( $fields, [ $model_column, $format_column, $key ] ),
148 $model_column =>
null,
152 [
'LIMIT' => $this->mBatchSize,
'ORDER BY' =>
"$key ASC" ],
155 $this->
output(
"Fetched {$rows->numRows()} rows.\n" );
156 foreach ( $rows
as $row ) {
157 if ( $table ===
'archive' ) {
158 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
160 $title = Title::newFromRow( $row );
162 $lastId = $row->{$key};
166 $this->
error(
"Invalid content model for $title" );
169 $defaultModel =
$handler->getModelID();
170 $defaultFormat =
$handler->getDefaultFormat();
171 $dbModel = $row->{$model_column};
172 $dbFormat = $row->{$format_column};
174 if ( $dbModel ===
null && $dbFormat ===
null ) {
176 $toSave[$defaultModel][] = $row->{$key};
178 if ( $dbFormat === $defaultFormat ) {
179 $toSave[$defaultModel][] = $row->{$key};
181 $this->
output(
"Updating model to match format for $table $id of $title... " );
184 [ $model_column => $defaultModel ],
189 $this->
output(
"done.\n" );
194 if ( count( $toSave[$defaultModel] ) >= $this->mBatchSize ) {
195 $this->updateRevisionOrArchiveRows( $dbw, $toSave[$defaultModel], $defaultModel, $table );
196 unset( $toSave[$defaultModel] );
199 }
while ( $rows->numRows() >= $this->mBatchSize );
200 foreach ( $toSave as $model => $ids ) {
201 $this->updateRevisionOrArchiveRows( $dbw, $ids, $model, $table );
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.
Relational database abstraction object.
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
addQuotes( $s)
Adds quotes and backslashes.
update( $table, $values, $conds, $fname=__METHOD__, $options=[])
UPDATE wrapper.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
error( $err, $die=0)
Throw an error to the user.
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.
populateRevisionOrArchive(Database $dbw, $table, $ns)
updatePageRows(Database $dbw, $pageIds, $model)
populatePage(Database $dbw, $ns)
execute()
Do the actual work.
__construct()
Default constructor.
updateRevisionOrArchiveRows(Database $dbw, $ids, $model, $table)
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
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
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