Merge "Remove not used private member variable mParserWarnings from OutputPage"
[mediawiki.git] / maintenance / importSites.php
blobc5c00aa24d64be2967d4b8cf8eafe795098c5cba
1 <?php
3 $basePath = getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' ) : __DIR__ . '/..';
5 require_once $basePath . '/maintenance/Maintenance.php';
7 /**
8 * Maintenance script for importing site definitions from XML into the sites table.
10 * @since 1.25
12 * @license GNU GPL v2+
13 * @author Daniel Kinzler
15 class ImportSites extends Maintenance {
17 public function __construct() {
18 $this->mDescription = 'Imports site definitions from XML into the sites table.';
20 $this->addArg( 'file', 'An XML file containing site definitions (see docs/sitelist.txt). ' .
21 'Use "php://stdin" to read from stdin.', true
24 parent::__construct();
27 /**
28 * Do the import.
30 public function execute() {
31 $file = $this->getArg( 0 );
33 $importer = new SiteImporter( SiteSQLStore::newInstance() );
34 $importer->setExceptionCallback( array( $this, 'reportException' ) );
36 $importer->importFromFile( $file );
38 $this->output( "Done.\n" );
41 /**
42 * Outputs a message via the output() method.
44 * @param Exception $ex
46 public function reportException( Exception $ex ) {
47 $msg = $ex->getMessage();
48 $this->output( "$msg\n" );
52 $maintClass = 'ImportSites';
53 require_once RUN_MAINTENANCE_IF_MAIN;