Don't use deprecated User::checkPassword() in TestUser
[mediawiki.git] / maintenance / exportSites.php
blobb1e4fa943b96e33d8eaaf989f2dad353fbf19ae4
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->addDescription( '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 $siteLookup = \MediaWiki\MediaWikiServices::getInstance()->getSiteLookup();
46 $exporter->exportSites( $siteLookup->getSites() );
48 fclose( $handle );
50 $this->output( "Exported sites to " . realpath( $file ) . ".\n" );
55 $maintClass = 'ExportSites';
56 require_once RUN_MAINTENANCE_IF_MAIN;