Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
GlobalRenameLogFormatter | |
0.00% |
0 / 16 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
getMessageParameters | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
getCentralAuthLink | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getLocalWikiLink | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\CentralAuth\GlobalRename; |
4 | |
5 | use LogFormatter; |
6 | use MediaWiki\Message\Message; |
7 | use MediaWiki\SpecialPage\SpecialPage; |
8 | use MediaWiki\WikiMap\WikiMap; |
9 | |
10 | /** |
11 | * Handles the following log types: |
12 | * - gblrename/rename |
13 | * - gblrename/promote |
14 | * |
15 | * phan-taint-check gets very confused by $this->plaintext changing expected taint types everywhere, |
16 | * so manual annotations are needed. They should be correct for the non-plaintext mode (HTML output). |
17 | */ |
18 | class GlobalRenameLogFormatter extends LogFormatter { |
19 | |
20 | /** @inheritDoc */ |
21 | protected function getMessageParameters() { |
22 | parent::getMessageParameters(); |
23 | $params = $this->extractParameters(); |
24 | |
25 | if ( $this->entry->getSubtype() === 'promote' ) { |
26 | $this->parsedParameters[3] = Message::rawParam( $this->getLocalWikiLink( $params[3], $params[5] ) ); |
27 | } else { |
28 | // rename |
29 | $this->parsedParameters[3] = Message::rawParam( $this->getCentralAuthLink( $params[3] ) ); |
30 | } |
31 | $this->parsedParameters[4] = Message::rawParam( $this->getCentralAuthLink( $params[4] ) ); |
32 | |
33 | ksort( $this->parsedParameters ); |
34 | return $this->parsedParameters; |
35 | } |
36 | |
37 | /** |
38 | * @param string $name |
39 | * @param-taint $name none |
40 | * @return string wikitext or html |
41 | * @return-taint onlysafefor_html |
42 | */ |
43 | protected function getCentralAuthLink( $name ) { |
44 | $title = SpecialPage::getTitleFor( 'CentralAuth', $name ); |
45 | if ( $this->plaintext ) { |
46 | return '[[' . $title->getPrefixedText() . ']]'; |
47 | } |
48 | |
49 | return $this->getLinkRenderer()->makeLink( $title, $name ); |
50 | } |
51 | |
52 | /** |
53 | * @param string $name |
54 | * @param string $wiki |
55 | * @return string wikitext or html |
56 | * @return-taint onlysafefor_html |
57 | */ |
58 | protected function getLocalWikiLink( $name, $wiki ) { |
59 | $text = "User:$name@$wiki"; |
60 | if ( $this->plaintext ) { |
61 | return "[[$text]]"; |
62 | } |
63 | |
64 | return WikiMap::foreignUserLink( $wiki, $name, $text ); |
65 | } |
66 | } |