Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
81.82% covered (warning)
81.82%
9 / 11
77.78% covered (warning)
77.78%
7 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
TemplateLinksTable
81.82% covered (warning)
81.82%
9 / 11
77.78% covered (warning)
77.78%
7 / 9
9.49
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 setParserOutput
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 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
 linksTargetNormalizationStage
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Deferred\LinksUpdate;
4
5use MediaWiki\Config\Config;
6use MediaWiki\Config\ServiceOptions;
7use MediaWiki\MainConfigNames;
8use MediaWiki\Parser\ParserOutput;
9
10/**
11 * templatelinks
12 *
13 * @since 1.38
14 */
15class TemplateLinksTable extends GenericPageLinksTable {
16    private const CONSTRUCTOR_OPTIONS = [
17        MainConfigNames::TemplateLinksSchemaMigrationStage,
18    ];
19
20    /** @var int */
21    private $migrationStage;
22
23    public function __construct( Config $config ) {
24        $options = new ServiceOptions( self::CONSTRUCTOR_OPTIONS, $config );
25        $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
26
27        $this->migrationStage = $options->get( MainConfigNames::TemplateLinksSchemaMigrationStage );
28    }
29
30    public function setParserOutput( ParserOutput $parserOutput ) {
31        $this->newLinks = $parserOutput->getTemplates();
32    }
33
34    protected function getTableName() {
35        return 'templatelinks';
36    }
37
38    protected function getFromField() {
39        return 'tl_from';
40    }
41
42    protected function getNamespaceField() {
43        return 'tl_namespace';
44    }
45
46    protected function getTitleField() {
47        return 'tl_title';
48    }
49
50    protected function getFromNamespaceField() {
51        return 'tl_from_namespace';
52    }
53
54    protected function getTargetIdField() {
55        return 'tl_target_id';
56    }
57
58    /**
59     * Normalization stage of the links table (see T222224)
60     * @return int
61     */
62    protected function linksTargetNormalizationStage(): int {
63        return $this->migrationStage;
64    }
65}