Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
81.82% |
9 / 11 |
|
75.00% |
6 / 8 |
CRAP | |
0.00% |
0 / 1 |
| TemplateLinksTable | |
81.82% |
9 / 11 |
|
75.00% |
6 / 8 |
9.49 | |
0.00% |
0 / 1 |
| setParserOutput | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| getTableName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getFromField | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getNamespaceField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTitleField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getFromNamespaceField | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getTargetIdField | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| virtualDomain | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Deferred\LinksUpdate; |
| 4 | |
| 5 | use LogicException; |
| 6 | use MediaWiki\Parser\ParserOutput; |
| 7 | use MediaWiki\Parser\ParserOutputLinkTypes; |
| 8 | |
| 9 | /** |
| 10 | * templatelinks |
| 11 | * |
| 12 | * @since 1.38 |
| 13 | */ |
| 14 | class TemplateLinksTable extends GenericPageLinksTable { |
| 15 | public const VIRTUAL_DOMAIN = 'virtual-templatelinks'; |
| 16 | |
| 17 | public function setParserOutput( ParserOutput $parserOutput ) { |
| 18 | // Convert the format of the template links |
| 19 | $this->newLinks = []; |
| 20 | foreach ( |
| 21 | $parserOutput->getLinkList( ParserOutputLinkTypes::TEMPLATE ) |
| 22 | as [ 'link' => $link, 'pageid' => $pageid ] |
| 23 | ) { |
| 24 | $this->newLinks[$link->getNamespace()][$link->getDBkey()] = $pageid; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | /** @inheritDoc */ |
| 29 | protected function getTableName() { |
| 30 | return 'templatelinks'; |
| 31 | } |
| 32 | |
| 33 | /** @inheritDoc */ |
| 34 | protected function getFromField() { |
| 35 | return 'tl_from'; |
| 36 | } |
| 37 | |
| 38 | /** @inheritDoc */ |
| 39 | protected function getNamespaceField() { |
| 40 | // @phan-suppress-previous-line PhanPluginNeverReturnMethod |
| 41 | throw new LogicException( 'not supported' ); |
| 42 | } |
| 43 | |
| 44 | /** @inheritDoc */ |
| 45 | protected function getTitleField() { |
| 46 | // @phan-suppress-previous-line PhanPluginNeverReturnMethod |
| 47 | throw new LogicException( 'not supported' ); |
| 48 | } |
| 49 | |
| 50 | /** @inheritDoc */ |
| 51 | protected function getFromNamespaceField() { |
| 52 | return 'tl_from_namespace'; |
| 53 | } |
| 54 | |
| 55 | /** @inheritDoc */ |
| 56 | protected function getTargetIdField() { |
| 57 | return 'tl_target_id'; |
| 58 | } |
| 59 | |
| 60 | /** @inheritDoc */ |
| 61 | protected function virtualDomain() { |
| 62 | return self::VIRTUAL_DOMAIN; |
| 63 | } |
| 64 | } |