Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
WMUserMergeLogFormatter | |
0.00% |
0 / 17 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
getMessageKey | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getParameter | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
extractParameters | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\WikimediaMessages\LogFormatter; |
4 | |
5 | use LogFormatter; |
6 | |
7 | /** |
8 | * A snapshot of the log formatter from the UserMerge |
9 | * extension, git revision e42022c82c8a0224aca9a2fab884259133f48df4. |
10 | * |
11 | * @see https://phabricator.wikimedia.org/T218160 |
12 | */ |
13 | class WMUserMergeLogFormatter extends LogFormatter { |
14 | |
15 | /** @var int[] */ |
16 | private static $mapLegacy = [ |
17 | 'oldName' => 0, |
18 | 'oldId' => 1, |
19 | 'newName' => 2, |
20 | 'newId' => 3, |
21 | ]; |
22 | |
23 | /** |
24 | * @return string |
25 | */ |
26 | protected function getMessageKey() { |
27 | if ( $this->entry->getSubtype() === 'deleteuser' ) { |
28 | return 'wikimedia-logentry-usermerge-deleteuser'; |
29 | } else { |
30 | return 'wikimedia-logentry-usermerge-mergeuser'; |
31 | } |
32 | } |
33 | |
34 | /** |
35 | * @param string $param |
36 | * @return mixed |
37 | */ |
38 | private function getParameter( $param ) { |
39 | $parameters = $this->entry->getParameters(); |
40 | if ( $this->entry->isLegacy() ) { |
41 | $param = self::$mapLegacy[$param]; |
42 | } |
43 | return $parameters[$param]; |
44 | } |
45 | |
46 | /** |
47 | * @return array |
48 | */ |
49 | protected function extractParameters() { |
50 | $params = []; |
51 | // 0-2 are set in LogFormatter::getMessageParameters() |
52 | $params[3] = $this->getParameter( 'oldName' ); |
53 | $params[4] = $this->getParameter( 'oldId' ); |
54 | if ( $this->entry->getSubtype() !== 'deleteuser' ) { |
55 | $params[5] = $this->formatParameterValue( |
56 | 'user-link', $this->getParameter( 'newName' ) ); |
57 | $params[6] = $this->getParameter( 'newId' ); |
58 | $params[7] = $this->formatParameterValue( |
59 | 'user', $this->getParameter( 'newName' ) ); |
60 | } |
61 | return $params; |
62 | } |
63 | |
64 | } |