Moved JobQueueFederated partition exceptions to their own log
[mediawiki.git] / maintenance / importSites.php
blob7abb8d72b864a5bcd25656e225449844438cfc18
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). Use "php://stdin" to read from stdin.', true );
22 parent::__construct();
26 /**
27 * Do the import.
29 public function execute() {
30 $file = $this->getArg( 0 );
32 $importer = new SiteImporter( SiteSQLStore::newInstance() );
33 $importer->setExceptionCallback( array( $this, 'reportException' ) );
35 $importer->importFromFile( $file );
37 $this->output( "Done.\n" );
40 /**
41 * Outputs a message via the output() method.
43 * @param Exception $ex
45 public function reportException( Exception $ex ) {
46 $msg = $ex->getMessage();
47 $this->output( "$msg\n" );
51 $maintClass = 'ImportSites';
52 require_once( RUN_MAINTENANCE_IF_MAIN );