3 $basePath = getenv( 'MW_INSTALL_PATH' ) !== false ?
getenv( 'MW_INSTALL_PATH' ) : __DIR__
. '/..';
5 require_once $basePath . '/maintenance/Maintenance.php';
8 * Maintenance script for importing site definitions from XML into the sites table.
12 * @license GNU GPL v2+
13 * @author Daniel Kinzler
15 class ImportSites
extends Maintenance
{
17 public function __construct() {
18 $this->addDescription( '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();
30 public function execute() {
31 $file = $this->getArg( 0 );
33 $importer = new SiteImporter( SiteSQLStore
::newInstance() );
34 $importer->setExceptionCallback( [ $this, 'reportException' ] );
36 $importer->importFromFile( $file );
38 $this->output( "Done.\n" );
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
;