Esempio n. 1
0
 /**
  * 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");
 }
Esempio n. 2
0
 /**
  * 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);
     $siteLookup = \MediaWiki\MediaWikiServices::getInstance()->getSiteLookup();
     $exporter->exportSites($siteLookup->getSites());
     fclose($handle);
     $this->output("Exported sites to " . realpath($file) . ".\n");
 }
 /**
  * @dataProvider provideRoundTrip()
  */
 public function testRoundTrip(SiteList $sites)
 {
     $tmp = tmpfile();
     $exporter = new SiteExporter($tmp);
     $exporter->exportSites($sites);
     fseek($tmp, 0);
     $xml = fread($tmp, 16 * 1024);
     $actualSites = new SiteList();
     $store = $this->newSiteStore($actualSites);
     $importer = new SiteImporter($store);
     $importer->importFromXML($xml);
     $this->assertEquals($sites, $actualSites);
 }