25require_once __DIR__ .
'/Maintenance.php';
36 parent::__construct();
37 $this->
addOption(
'list',
'List special page names' );
38 $this->
addOption(
'only',
'Only update "page"; case sensitive, ' .
39 'check correct case by calling this script with --list. ' .
40 'Ex: --only=BrokenRedirects',
false,
true );
41 $this->
addOption(
'override',
'Also update pages that have updates disabled' );
52 list( $class, $special ) = $page;
53 $limit = $page[2] ??
null;
55 # --list : just show the name of pages
57 $this->
output(
"$special [QueryPage]\n" );
64 $this->
output( sprintf(
"%-30s [QueryPage] disabled\n", $special ) );
68 $specialObj = MediaWikiServices::getInstance()->getSpecialPageFactory()->
71 $this->
output(
"No such special page: $special\n" );
75 $queryPage = $specialObj;
77 $class = get_class( $specialObj );
78 $this->
fatalError(
"$class is not an instance of QueryPage.\n" );
82 if ( !$this->
hasOption(
'only' ) || $this->
getOption(
'only' ) == $queryPage->getName() ) {
83 $this->
output( sprintf(
'%-30s [QueryPage] ', $special ) );
84 if ( $queryPage->isExpensive() ) {
85 $t1 = microtime(
true );
88 $t2 = microtime(
true );
89 if ( $num ===
false ) {
90 $this->
output(
"FAILED: database error\n" );
92 $this->
output(
"got $num rows in " );
95 $hours = intval( $elapsed / 3600 );
96 $minutes = intval( $elapsed % 3600 / 60 );
97 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
99 $this->
output( $hours .
'h ' );
102 $this->
output( $minutes .
'm ' );
104 $this->
output( sprintf(
"%.2fs\n", $seconds ) );
106 # Reopen any connections that have closed
109 $this->
output(
"cheap, skipped\n" );
125 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
126 $lb = $lbFactory->getMainLB();
127 if ( !$lb->pingAll() ) {
130 $this->
error(
"Connection failed, reconnecting in 10 seconds..." );
132 }
while ( !$lb->pingAll() );
133 $this->
output(
"Reconnected\n\n" );
136 $lbFactory->waitForReplication();
143 # --list : just show the name of pages
145 $this->
output(
"$special [callback]\n" );
150 if ( !is_callable( $call ) ) {
151 $this->
error(
"Uncallable function $call!" );
154 $this->
output( sprintf(
'%-30s [callback] ', $special ) );
155 $t1 = microtime(
true );
156 call_user_func( $call, $dbw );
157 $t2 = microtime(
true );
159 $this->
output(
"completed in " );
160 $elapsed = $t2 - $t1;
161 $hours = intval( $elapsed / 3600 );
162 $minutes = intval( $elapsed % 3600 / 60 );
163 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
165 $this->
output( $hours .
'h ' );
168 $this->
output( $minutes .
'm ' );
170 $this->
output( sprintf(
"%.2fs\n", $seconds ) );
171 # Wait for the replica DB to catch up
$wgDisableQueryPageUpdate
Set this to an array of special page names to prevent maintenance/updateSpecialPages....
$wgQueryCacheLimit
Number of rows to cache in 'querycache' table when miser mode is on.
$wgSpecialPageCacheUpdates
Additional functions to be performed with updateSpecialPages.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
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.
hasOption( $name)
Checks to see if a particular option exists.
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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
static getPages()
Get a list of query page classes and their associated special pages, for periodic updates.
Maintenance script to update cached special pages.
doSpecialPageCacheUpdates( $dbw)
__construct()
Default constructor.
reopenAndWaitForReplicas()
Re-open any closed db connection, and wait for replicas.
execute()
Do the actual work.
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 list
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
require_once RUN_MAINTENANCE_IF_MAIN