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" );
83 if ( !$this->
hasOption(
'only' ) || $this->
getOption(
'only' ) == $queryPage->getName() ) {
84 $this->
output( sprintf(
'%-30s [QueryPage] ', $special ) );
85 if ( $queryPage->isExpensive() ) {
86 $t1 = microtime(
true );
89 $t2 = microtime(
true );
90 if ( $num ===
false ) {
91 $this->
output(
"FAILED: database error\n" );
93 $this->
output(
"got $num rows in " );
96 $hours = intval( $elapsed / 3600 );
97 $minutes = intval( $elapsed % 3600 / 60 );
98 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
100 $this->
output( $hours .
'h ' );
103 $this->
output( $minutes .
'm ' );
105 $this->
output( sprintf(
"%.2fs\n", $seconds ) );
107 # Reopen any connections that have closed
110 $this->
output(
"cheap, skipped\n" );
126 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
127 $lb = $lbFactory->getMainLB();
128 if ( !$lb->pingAll() ) {
131 $this->
error(
"Connection failed, reconnecting in 10 seconds..." );
133 }
while ( !$lb->pingAll() );
134 $this->
output(
"Reconnected\n\n" );
137 $lbFactory->waitForReplication();
144 # --list : just show the name of pages
146 $this->
output(
"$special [callback]\n" );
151 if ( !is_callable( $call ) ) {
152 $this->
error(
"Uncallable function $call!" );
155 $this->
output( sprintf(
'%-30s [callback] ', $special ) );
156 $t1 = microtime(
true );
157 call_user_func( $call, $dbw );
158 $t2 = microtime(
true );
160 $this->
output(
"completed in " );
161 $elapsed = $t2 - $t1;
162 $hours = intval( $elapsed / 3600 );
163 $minutes = intval( $elapsed % 3600 / 60 );
164 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
166 $this->
output( $hours .
'h ' );
169 $this->
output( $minutes .
'm ' );
171 $this->
output( sprintf(
"%.2fs\n", $seconds ) );
172 # Wait for the replica DB to catch up
$wgQueryCacheLimit
Number of rows to cache in 'querycache' table when miser mode is on.
$wgSpecialPageCacheUpdates
Additional functions to be performed with updateSpecialPages.
const RUN_MAINTENANCE_IF_MAIN
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 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 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.