API: Normalize input URL in ApiQueryExtLinksUsage
[mediawiki.git] / maintenance / rebuildSitesCache.php
blob044bafd4312f80e916c88a50659d1330a9b84176
1 <?php
3 /**
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
19 * @file
20 * @ingroup Maintenance
23 require_once __DIR__ . '/Maintenance.php';
25 /**
26 * Maintenance script to dump a SiteStore as a static json file.
28 * @ingroup Maintenance
30 class RebuildSitesCache extends Maintenance {
32 public function __construct() {
33 parent::__construct();
35 $this->addDescription( 'Cache sites as json for file-based lookup.' );
36 $this->addOption( 'file', 'File to output the json to', false, true );
39 public function execute() {
40 $sitesCacheFileBuilder = new SitesCacheFileBuilder(
41 new DBSiteStore(),
42 $this->getCacheFile()
45 $sitesCacheFileBuilder->build();
48 /**
49 * @return string
51 private function getCacheFile() {
52 if ( $this->hasOption( 'file' ) ) {
53 $jsonFile = $this->getOption( 'file' );
54 } else {
55 $jsonFile = $this->getConfig()->get( 'SitesCacheFile' );
57 if ( $jsonFile === false ) {
58 $this->error( 'Error: No file set in configuration for SitesCacheFile.', 1 );
62 return $jsonFile;
67 $maintClass = "RebuildSitesCache";
68 require_once RUN_MAINTENANCE_IF_MAIN;