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