24 require_once __DIR__ .
'/Maintenance.php';
36 'callback' =>
'processRow',
46 parent::__construct();
47 $this->
addOption(
'dry-run',
'Perform a dry run' );
52 $this->dryrun = $this->
hasOption(
'dry-run' );
53 if ( $this->dryrun ) {
55 $this->
output(
"Checking for bad titles...\n" );
58 $this->
output(
"Checking and fixing bad titles...\n" );
60 $this->
runTable( $this->defaultParams );
63 protected function init( $count, $table ) {
67 $this->startTime = microtime(
true );
77 if ( $this->processed % $this->reportInterval != 0 ) {
83 $now = microtime(
true );
85 $estimatedTotalTime = $delta / $portion;
86 $eta = $this->startTime + $estimatedTotalTime;
89 sprintf(
"%s %s: %6.2f%% done on %s; ETA %s [%d/%d] %.2f/sec <%.2f%% updated>\n",
97 $this->processed / $delta,
111 if ( array_diff( array_keys(
$params ),
112 [
'table',
'conds',
'index',
'callback' ] )
114 throw new MWException( __METHOD__ .
': Missing parameter ' . implode(
', ',
$params ) );
119 $count =
$dbr->estimateRowCount( $table,
'*',
'', __METHOD__ );
120 $this->
init( $count, $table );
121 $this->
output(
"Processing $table...\n" );
126 'ORDER BY' => implode(
',', $index ),
129 $callback = [ $this,
$params[
'callback'] ];
132 $conds = array_merge( $params[
'conds'], $indexConds );
134 if ( !
$res->numRows() ) {
139 foreach (
$res as $row ) {
140 call_user_func( $callback, $row );
153 foreach ( array_reverse( $index )
as $field ) {
154 $encValue =
$dbr->addQuotes( $row->$field );
155 if ( $nextCond ===
'' ) {
156 $nextCond =
"$field > $encValue";
158 $nextCond =
"$field > $encValue OR ($field = $encValue AND ($nextCond))";
161 $indexConds = [ $nextCond ];
164 $this->
output(
"Finished $table... $this->updated of $this->processed rows updated\n" );
172 return sprintf(
"\\x%02x", ord(
$matches[1] ) );
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
the array() calling protocol came about after MediaWiki 1.4rc1.
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.
hasOption($name)
Checks to see if a particular param exists.
when a variable name is used in a it is silently declared as a new local masking the global
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
addOption($name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Generic class to cleanup a database table.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
static newSystemUser($name, $options=[])
Static factory method for creation of a "system" user from username.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
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
const TS_DB
MySQL DATETIME (YYYY-MM-DD HH:MM:SS)
output($out, $channel=null)
Throw some output to the user.
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
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if so it s not worth the trouble Since there is a job queue in the jobs table