public function execute() { global $wgLang, $wgParser; $provided = $this->getArg(0); $namespace = $wgLang->getNsIndex($provided); if (!$namespace) { $this->error("Invalid namespace provided: {$provided}"); return; } $namespaceName = $wgLang->getNsText($namespace); if (!MWNamespace::hasSubpages($namespace)) { $this->error("Subpages are not enabled in the {$namespaceName} namespace."); $this->error("In order to convert this namespace to Flow, you must enable subpages using:"); $this->error("\$wgNamespacesWithSubpages[{$namespace}] = true;"); return; } $noConvertTemplates = explode(',', $this->getOption('no-convert-templates', '')); if ($noConvertTemplates === array('')) { // explode( ',', '' ) returns array( '' ) $noConvertTemplates = array(); } // Convert to Title objects foreach ($noConvertTemplates as &$template) { $title = Title::newFromText($template, NS_TEMPLATE); if (!$title) { $this->error("Invalid template name: {$template}"); return; } $template = $title; } // @todo send to prod logger? $logger = new MaintenanceDebugLogger($this); $dbw = wfGetDB(DB_MASTER); $converter = new \Flow\Import\Converter($dbw, Flow\Container::get('importer'), $logger, FlowHooks::getOccupationController()->getTalkpageManager(), new Flow\Import\Wikitext\ConversionStrategy($wgParser, new Flow\Import\NullImportSourceStore(), $logger, $noConvertTemplates, $this->getOption('archive-pattern', null))); $logger->info("Starting conversion of {$namespaceName} namespace"); // Iterate over all existing pages of the namespace. $it = new NamespaceIterator($dbw, $namespace); // NamespaceIterator is an IteratorAggregate. Get an Iterator // so we can wrap that. $it = $it->getIterator(); $converter->convertAll($it); $logger->info("Finished conversion of {$namespaceName} namespace"); }
public function execute() { $logger = new MaintenanceDebugLogger($this); if ($this->getOption('debug')) { $logger->setMaximumLevel(LogLevel::DEBUG); } else { $logger->setMaximumLevel(LogLevel::INFO); } $importer = Flow\Container::get('importer'); $talkpageManagerUser = FlowHooks::getOccupationController()->getTalkpageManager(); $dbw = wfGetDB(DB_MASTER); $strategy = new ConversionStrategy($dbw, new FileImportSourceStore($this->getOption('logfile')), new LocalApiBackend($talkpageManagerUser), Container::get('url_generator'), $talkpageManagerUser, Container::get('controller.notification')); $converter = new \Flow\Import\Converter($dbw, $importer, $logger, $talkpageManagerUser, $strategy); $startId = $this->getOption('startId'); $stopId = $this->getOption('stopId'); $logger->info("Starting full wiki LQT conversion of all pages with use-liquid-threads property"); $titles = new PagesWithPropertyIterator($dbw, 'use-liquid-threads', $startId, $stopId); $converter->convertAll($titles); $logger->info("Finished conversion"); }
public function execute() { $cacheDir = $this->getOption('cacheremoteapidir'); if (!is_dir($cacheDir)) { if (!mkdir($cacheDir)) { throw new Flow\Exception\FlowException('Provided dir for caching remote api calls is not creatable.'); } } if (!is_writable($cacheDir)) { throw new Flow\Exception\FlowException('Provided dir for caching remote api calls is not writable.'); } $api = new RemoteApiBackend($this->getOption('remoteapi'), $cacheDir); $importer = Flow\Container::get('importer'); $importer->setAllowUnknownUsernames(true); $talkPageManagerUser = \FlowHooks::getOccupationController()->getTalkpageManager(); $srcPageName = $this->getOption('srcpage'); if ($this->hasOption('dstpage')) { $dstPageName = $this->getOption('dstpage'); } else { $dstPageName = $srcPageName; } $dstTitle = Title::newFromText($dstPageName); $source = new LiquidThreadsApiImportSource($api, $srcPageName, $talkPageManagerUser); $logFilename = $this->getOption('logfile'); $sourceStore = new FileImportSourceStore($logFilename); $logger = new MaintenanceDebugLogger($this); if ($this->getOption('debug')) { $logger->setMaximumLevel(LogLevel::DEBUG); } else { $logger->setMaximumLevel(LogLevel::INFO); } $importer->setLogger($logger); $api->setLogger($logger); $logger->info("Starting LQT conversion of page {$srcPageName}"); $importer->import($source, $dstTitle, $sourceStore); $logger->info("Finished LQT conversion of page {$srcPageName}"); }
public function execute() { $talkPageManagerUser = \FlowHooks::getOccupationController()->getTalkpageManager(); $api = new LocalApiBackend($talkPageManagerUser); $importer = Container::get('importer'); $srcPageName = $this->getOption('srcpage'); $logFilename = $this->getOption('logfile'); $sourceStore = new FileImportSourceStore($logFilename); $dbw = wfGetDB(DB_MASTER); $logger = new MaintenanceDebugLogger($this); if ($this->getOption('debug')) { $logger->setMaximumLevel(LogLevel::DEBUG); } else { $logger->setMaximumLevel(LogLevel::INFO); } $strategy = new LiquidThreadsApiConversionStrategy($dbw, $sourceStore, $api, Container::get('url_generator'), $talkPageManagerUser, Container::get('controller.notification')); $importer->setLogger($logger); $api->setLogger($logger); $converter = new \Flow\Import\Converter($dbw, $importer, $logger, $talkPageManagerUser, $strategy); $logger->info("Starting LQT conversion of page {$srcPageName}"); $srcTitle = \Title::newFromText($srcPageName); $converter->convertAll(array($srcTitle)); $logger->info("Finished LQT conversion of page {$srcPageName}"); }