SessionManager: Notify AuthPlugin when auto-creating accounts
[mediawiki.git] / maintenance / exportSites.php
blob145c9249236952f7e6c80515414c415aa80838f5
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 exporting site definitions from XML into the sites table.
10 * @since 1.25
12 * @licence GNU GPL v2+
13 * @author Daniel Kinzler
15 class ExportSites extends Maintenance {
17 public function __construct() {
18 $this->mDescription = 'Exports site definitions the sites table to XML file';
20 $this->addArg( 'file', 'A file to write the XML to (see docs/sitelist.txt). ' .
21 'Use "php://stdout" to write to stdout.', true
24 parent::__construct();
27 /**
28 * Do the actual work. All child classes will need to implement this
30 public function execute() {
31 $file = $this->getArg( 0 );
33 if ( $file === 'php://output' || $file === 'php://stdout' ) {
34 $this->mQuiet = true;
37 $handle = fopen( $file, 'w' );
39 if ( !$handle ) {
40 $this->error( "Failed to open $file for writing.\n", 1 );
43 $exporter = new SiteExporter( $handle );
45 $sites = SiteSQLStore::newInstance()->getSites( 'recache' );
46 $exporter->exportSites( $sites );
48 fclose( $handle );
50 $this->output( "Exported sites to " . realpath( $file ) . ".\n" );
55 $maintClass = 'ExportSites';
56 require_once RUN_MAINTENANCE_IF_MAIN;