diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:31:04 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:58:39 +0200 |
commit | f6d65e533c62f6deb21342d4901ece24497b433e (patch) | |
tree | f28adf0362d14bcd448f7b65a7aaf38650f923aa /maintenance/exportSites.php | |
parent | c27b2e832fe25651ef2410fae85b41072aae7519 (diff) |
Update to MediaWiki 1.25.1
Diffstat (limited to 'maintenance/exportSites.php')
-rw-r--r-- | maintenance/exportSites.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/maintenance/exportSites.php b/maintenance/exportSites.php new file mode 100644 index 00000000..1c71dc0e --- /dev/null +++ b/maintenance/exportSites.php @@ -0,0 +1,54 @@ +<?php + +$basePath = getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' ) : __DIR__ . '/..'; + +require_once $basePath . '/maintenance/Maintenance.php'; + +/** + * Maintenance script for exporting site definitions from XML into the sites table. + * + * @since 1.25 + * + * @licence GNU GPL v2+ + * @author Daniel Kinzler + */ +class ExportSites extends Maintenance { + + public function __construct() { + $this->mDescription = 'Exports site definitions the sites table to XML file'; + + $this->addArg( 'file', 'A file to write the XML to (see docs/sitelist.txt). Use "php://stdout" to write to stdout.', true ); + + parent::__construct(); + } + + /** + * Do the actual work. All child classes will need to implement this + */ + public function execute() { + $file = $this->getArg( 0 ); + + if ( $file === 'php://output' || $file === 'php://stdout' ) { + $this->mQuiet = true; + } + + $handle = fopen( $file, 'w' ); + + if ( !$handle ) { + $this->error( "Failed to open $file for writing.\n", 1 ); + } + + $exporter = new SiteExporter( $handle ); + + $sites = SiteSQLStore::newInstance()->getSites( 'recache' ); + $exporter->exportSites( $sites ); + + fclose( $handle ); + + $this->output( "Exported sites to " . realpath( $file ) . ".\n" ); + } + +} + +$maintClass = 'ExportSites'; +require_once( RUN_MAINTENANCE_IF_MAIN ); |