Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
81.82% covered (warning)
81.82%
9 / 11
75.00% covered (warning)
75.00%
6 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 1
ExistenceLinksTable
81.82% covered (warning)
81.82%
9 / 11
75.00% covered (warning)
75.00%
6 / 8
9.49
0.00% covered (danger)
0.00%
0 / 1
 setParserOutput
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 getTableName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFromField
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getNamespaceField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTitleField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFromNamespaceField
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTargetIdField
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 virtualDomain
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3// @phan-file-suppress PhanPluginNeverReturnMethod -- for getNamespaceField
4
5namespace MediaWiki\Deferred\LinksUpdate;
6
7use MediaWiki\Parser\ParserOutput;
8use MediaWiki\Parser\ParserOutputLinkTypes;
9
10/**
11 * References like {{#ifexist:Title}} that cause the parser output to change
12 * when the existence of the page changes, but are not shown in
13 * Special:WhatLinksHere.
14 *
15 * @since 1.45
16 */
17class ExistenceLinksTable extends GenericPageLinksTable {
18    public const VIRTUAL_DOMAIN = 'virtual-existencelinks';
19
20    public function setParserOutput( ParserOutput $parserOutput ) {
21        $this->newLinks = [];
22        foreach (
23            $parserOutput->getLinkList( ParserOutputLinkTypes::EXISTENCE )
24            as [ 'link' => $link ]
25        ) {
26            $this->newLinks[$link->getNamespace()][$link->getDBkey()] = true;
27        }
28    }
29
30    /** @inheritDoc */
31    protected function getTableName() {
32        return 'existencelinks';
33    }
34
35    /** @inheritDoc */
36    protected function getFromField() {
37        return 'exl_from';
38    }
39
40    /** @inheritDoc */
41    protected function getNamespaceField() {
42        throw new \LogicException( 'This table has no namespace field' );
43    }
44
45    /** @inheritDoc */
46    protected function getTitleField() {
47        throw new \LogicException( 'This table has no title field' );
48    }
49
50    /** @inheritDoc */
51    protected function getFromNamespaceField() {
52        return null;
53    }
54
55    /** @inheritDoc */
56    protected function getTargetIdField() {
57        return 'exl_target_id';
58    }
59
60    /** @inheritDoc */
61    protected function virtualDomain(): string {
62        return self::VIRTUAL_DOMAIN;
63    }
64}