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' );
53 list( , $special ) = $page;
54 $limit = $page[2] ??
null;
56 # --list : just show the name of pages
58 $this->
output(
"$special [QueryPage]\n" );
63 && isset( $disabledQueryPages[$special] )
65 $this->
output( sprintf(
"%-30s [QueryPage] disabled\n", $special ) );
69 $specialObj = MediaWikiServices::getInstance()->getSpecialPageFactory()->
72 $this->
output(
"No such special page: $special\n" );
76 $queryPage = $specialObj;
78 $class = get_class( $specialObj );
79 $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
110 $cached = $queryPage->getCachedTimestamp();
112 $queryPage->deleteAllCachedData();
114 $this->
output(
"cheap, but deleted cached data\n" );
116 $this->
output(
"cheap, skipped\n" );
133 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
134 $lb = $lbFactory->getMainLB();
135 if ( !$lb->pingAll() ) {
138 $this->
error(
"Connection failed, reconnecting in 10 seconds..." );
140 }
while ( !$lb->pingAll() );
141 $this->
output(
"Reconnected\n\n" );
144 $lbFactory->waitForReplication();
151 # --list : just show the name of pages
153 $this->
output(
"$special [callback]\n" );
158 if ( !is_callable( $call ) ) {
159 $this->
error(
"Uncallable function $call!" );
162 $this->
output( sprintf(
'%-30s [callback] ', $special ) );
163 $t1 = microtime(
true );
164 call_user_func( $call, $dbw );
165 $t2 = microtime(
true );
167 $this->
output(
"completed in " );
168 $elapsed = $t2 - $t1;
169 $hours = intval( $elapsed / 3600 );
170 $minutes = intval( $elapsed % 3600 / 60 );
171 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
173 $this->
output( $hours .
'h ' );
176 $this->
output( $minutes .
'm ' );
178 $this->
output( sprintf(
"%.2fs\n", $seconds ) );
179 # Wait for the replica DB to catch up
187require_once RUN_MAINTENANCE_IF_MAIN;
$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...
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular option was set.
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 getDisabledQueryPages(Config $config)
Get a list of query pages disabled and with it's run mode.
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.