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
20 * @ingroup Maintenance
23 require_once __DIR__
. '/Maintenance.php';
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(),
45 $siteListFileCacheBuilder->build();
51 private function getCacheFile() {
52 if ( $this->hasOption( 'file' ) ) {
53 $jsonFile = $this->getOption( 'file' );
55 $jsonFile = $this->getConfig()->get( 'SitesCacheFile' );
57 if ( $jsonFile === false ) {
58 $this->error( 'Error: No sites cache file is set in configuration.', 1 );
67 $maintClass = "RebuildSitesCache";
68 require_once RUN_MAINTENANCE_IF_MAIN
;