Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
MovedImportRevision | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
getText | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace Flow\Import\LiquidThreadsApi; |
4 | |
5 | use Flow\Import\ImportException; |
6 | use MediaWiki\MediaWikiServices; |
7 | use MediaWiki\Utils\MWTimestamp; |
8 | |
9 | class MovedImportRevision extends ImportRevision { |
10 | /** |
11 | * Rewrites the '#REDIRECT [[...]]' of an autogenerated lqt moved |
12 | * thread stub into a template. While we don't re-write the link |
13 | * here, after importing the referenced thread LqtRedirector will |
14 | * make that Thread page a redirect to the Flow topic, essentially |
15 | * making these links still work. |
16 | * @return string |
17 | * @throws ImportException |
18 | */ |
19 | public function getText() { |
20 | $text = parent::getText(); |
21 | $content = MediaWikiServices::getInstance() |
22 | ->getContentHandlerFactory() |
23 | ->getContentHandler( CONTENT_MODEL_WIKITEXT ) |
24 | ->unserializeContent( $text ); |
25 | $target = $content->getRedirectTarget(); |
26 | if ( !$target ) { |
27 | throw new ImportException( "Could not detect redirect within: $text" ); |
28 | } |
29 | |
30 | // To get the new talk page that this belongs to we would need to query the api |
31 | // for the new topic, for now not bothering. |
32 | $template = wfMessage( 'flow-importer-lqt-moved-thread-template' )->inContentLanguage( |
33 | )->plain(); |
34 | $arguments = implode( |
35 | '|', |
36 | [ |
37 | 'author=' . parent::getAuthor(), |
38 | 'date=' . MWTimestamp::getInstance( |
39 | $this->apiResponse['timestamp'] |
40 | )->timestamp->format( 'Y-m-d' ), |
41 | 'title=' . $target->getPrefixedText(), |
42 | ] |
43 | ); |
44 | |
45 | return "{{{$template}|$arguments}}"; |
46 | } |
47 | } |