MediaWiki REL1_31
rebuildSitesCache.php
Go to the documentation of this file.
1<?php
2
23require_once __DIR__ . '/Maintenance.php';
24
31
32 public function __construct() {
33 parent::__construct();
34
35 $this->addDescription( 'Cache sites as json for file-based lookup.' );
36 $this->addOption( 'file', 'File to output the json to', false, true );
37 }
38
39 public function execute() {
40 $sitesCacheFileBuilder = new SitesCacheFileBuilder(
41 \MediaWiki\MediaWikiServices::getInstance()->getSiteLookup(),
42 $this->getCacheFile()
43 );
44
45 $sitesCacheFileBuilder->build();
46 }
47
51 private function getCacheFile() {
52 if ( $this->hasOption( 'file' ) ) {
53 $jsonFile = $this->getOption( 'file' );
54 } else {
55 $jsonFile = $this->getConfig()->get( 'SitesCacheFile' );
56
57 if ( $jsonFile === false ) {
58 $this->fatalError( 'Error: No file set in configuration for SitesCacheFile.' );
59 }
60 }
61
62 return $jsonFile;
63 }
64
65}
66
67$maintClass = RebuildSitesCache::class;
68require_once RUN_MAINTENANCE_IF_MAIN;
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
hasOption( $name)
Checks to see if a particular param exists.
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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Maintenance script to dump a SiteStore as a static json file.
__construct()
Default constructor.
execute()
Do the actual work.
require_once RUN_MAINTENANCE_IF_MAIN
A helper class for throttling authentication attempts.