Hide file links in action=info's 'Number of redirects to this page'
[mediawiki.git] / maintenance / rebuildSitesCache.php
blob862a983d4485b25b0618eee459c04a6a503536dc
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 the SiteStore as a static json file.
28 * @ingroup Maintenance
30 class RebuildSitesCache extends Maintenance {
32 public function __construct() {
33 parent::__construct();
35 $this->mDescription = "Dumps site store as json";
36 $this->addOption( 'file', 'File to output the json to', false, true );
39 public function execute() {
40 $siteListFileCacheBuilder = new SiteListFileCacheBuilder(
41 SiteSQLStore::newInstance(),
42 $this->getCacheFile()
45 $siteListFileCacheBuilder->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 sites cache file is set in configuration.', 1 );
62 return $jsonFile;
67 $maintClass = "RebuildSitesCache";
68 require_once RUN_MAINTENANCE_IF_MAIN;