Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 47 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ConvertLqtPageOnLocalWiki | |
0.00% |
0 / 41 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 35 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace Flow\Maintenance; |
4 | |
5 | use Flow\Container; |
6 | use Flow\Import\Converter; |
7 | use Flow\Import\LiquidThreadsApi\ConversionStrategy; |
8 | use Flow\Import\LiquidThreadsApi\LocalApiBackend; |
9 | use Flow\Import\SourceStore\FileImportSourceStore; |
10 | use Flow\OccupationController; |
11 | use MediaWiki\Maintenance\Maintenance; |
12 | use MediaWiki\MediaWikiServices; |
13 | use MediaWiki\Title\Title; |
14 | use Psr\Log\LogLevel; |
15 | |
16 | $IP = getenv( 'MW_INSTALL_PATH' ); |
17 | if ( $IP === false ) { |
18 | $IP = __DIR__ . '/../../..'; |
19 | } |
20 | |
21 | require_once "$IP/maintenance/Maintenance.php"; |
22 | |
23 | /** |
24 | * This is intended for use both in testing and in production. It converts a single LQT |
25 | * page on the current wiki to a Flow page on the current wiki, handling archiving. |
26 | */ |
27 | class ConvertLqtPageOnLocalWiki extends Maintenance { |
28 | public function __construct() { |
29 | parent::__construct(); |
30 | $this->addDescription( "Converts LiquidThreads data to Flow data on the current wiki, using a ConversionStrategy" ); |
31 | $this->addOption( 'srcpage', 'Page name of the source page to import from.', true, true ); |
32 | $this->addOption( 'logfile', 'File to read and store associations between imported items and their sources', true, true ); |
33 | $this->addOption( 'debug', 'Include debug information to progress report' ); |
34 | $this->requireExtension( 'Flow' ); |
35 | } |
36 | |
37 | public function execute() { |
38 | /** @var OccupationController $occupationController */ |
39 | $occupationController = MediaWikiServices::getInstance()->getService( 'FlowTalkpageManager' ); |
40 | $talkPageManagerUser = $occupationController->getTalkpageManager(); |
41 | |
42 | $api = new LocalApiBackend( $talkPageManagerUser ); |
43 | |
44 | $importer = Container::get( 'importer' ); |
45 | |
46 | $srcPageName = $this->getOption( 'srcpage' ); |
47 | |
48 | $logFilename = $this->getOption( 'logfile' ); |
49 | $sourceStore = new FileImportSourceStore( $logFilename ); |
50 | |
51 | $dbw = $this->getPrimaryDB(); |
52 | |
53 | $logger = new MaintenanceDebugLogger( $this ); |
54 | if ( $this->getOption( 'debug' ) ) { |
55 | $logger->setMaximumLevel( LogLevel::DEBUG ); |
56 | } else { |
57 | $logger->setMaximumLevel( LogLevel::INFO ); |
58 | } |
59 | |
60 | $strategy = new ConversionStrategy( |
61 | $dbw, |
62 | $sourceStore, |
63 | $api, |
64 | Container::get( 'url_generator' ), |
65 | $talkPageManagerUser, |
66 | Container::get( 'controller.notification' ) |
67 | ); |
68 | |
69 | $importer->setLogger( $logger ); |
70 | $api->setLogger( $logger ); |
71 | |
72 | $converter = new Converter( |
73 | $dbw, |
74 | $importer, |
75 | $logger, |
76 | $talkPageManagerUser, |
77 | $strategy |
78 | ); |
79 | |
80 | $logger->info( "Starting LQT conversion of page $srcPageName" ); |
81 | |
82 | $srcTitle = Title::newFromText( $srcPageName ); |
83 | $converter->convertAll( [ |
84 | $srcTitle, |
85 | ] ); |
86 | |
87 | $logger->info( "Finished LQT conversion of page $srcPageName" ); |
88 | } |
89 | } |
90 | |
91 | $maintClass = ConvertLqtPageOnLocalWiki::class; |
92 | require_once RUN_MAINTENANCE_IF_MAIN; |