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). Use "php://stdout" to write to stdout.', true );
22 parent
::__construct();
26 * Do the actual work. All child classes will need to implement this
28 public function execute() {
29 $file = $this->getArg( 0 );
31 if ( $file === 'php://output' ||
$file === 'php://stdout' ) {
35 $handle = fopen( $file, 'w' );
38 $this->error( "Failed to open $file for writing.\n", 1 );
41 $exporter = new SiteExporter( $handle );
43 $sites = SiteSQLStore
::newInstance()->getSites( 'recache' );
44 $exporter->exportSites( $sites );
48 $this->output( "Exported sites to " . realpath( $file ) . ".\n" );
53 $maintClass = 'ExportSites';
54 require_once( RUN_MAINTENANCE_IF_MAIN
);