3 $basePath = getenv( 'MW_INSTALL_PATH' ) !== false ?
getenv( 'MW_INSTALL_PATH' ) : __DIR__
. '/..';
5 require_once $basePath . '/maintenance/Maintenance.php';
8 * Maintenance script for exporting site definitions from XML into the sites table.
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();
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' ) {
37 $handle = fopen( $file, 'w' );
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 );
50 $this->output( "Exported sites to " . realpath( $file ) . ".\n" );
55 $maintClass = 'ExportSites';
56 require_once RUN_MAINTENANCE_IF_MAIN
;