Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
47.06% |
8 / 17 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
NewUsersLogFormatter | |
47.06% |
8 / 17 |
|
0.00% |
0 / 3 |
21.02 | |
0.00% |
0 / 1 |
getMessageParameters | |
88.89% |
8 / 9 |
|
0.00% |
0 / 1 |
4.02 | |||
getComment | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getPreloadTitles | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | /** |
3 | * Formatter for new user log entries. |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License along |
16 | * with this program; if not, write to the Free Software Foundation, Inc., |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
18 | * http://www.gnu.org/copyleft/gpl.html |
19 | * |
20 | * @file |
21 | * @author Niklas Laxström |
22 | * @license GPL-2.0-or-later |
23 | * @since 1.22 |
24 | */ |
25 | |
26 | use MediaWiki\Message\Message; |
27 | use MediaWiki\Title\Title; |
28 | use MediaWiki\User\User; |
29 | |
30 | /** |
31 | * This class formats new user log entries. |
32 | * |
33 | * @since 1.19 |
34 | */ |
35 | class NewUsersLogFormatter extends LogFormatter { |
36 | protected function getMessageParameters() { |
37 | $params = parent::getMessageParameters(); |
38 | $subtype = $this->entry->getSubtype(); |
39 | if ( $subtype === 'create2' || $subtype === 'byemail' ) { |
40 | if ( isset( $params[3] ) ) { |
41 | $target = User::newFromId( $params[3] ); |
42 | } else { |
43 | $target = User::newFromName( $this->entry->getTarget()->getText(), false ); |
44 | } |
45 | $params[2] = Message::rawParam( $this->makeUserLink( $target ) ); |
46 | $params[3] = $target->getName(); |
47 | } |
48 | |
49 | return $params; |
50 | } |
51 | |
52 | public function getComment() { |
53 | $timestamp = wfTimestamp( TS_MW, $this->entry->getTimestamp() ); |
54 | if ( $timestamp < '20080129000000' ) { |
55 | # Suppress $comment from old entries (before 2008-01-29), |
56 | # not needed and can contain incorrect links |
57 | return ''; |
58 | } |
59 | |
60 | return parent::getComment(); |
61 | } |
62 | |
63 | public function getPreloadTitles() { |
64 | $subtype = $this->entry->getSubtype(); |
65 | if ( $subtype === 'create2' || $subtype === 'byemail' ) { |
66 | // add the user talk to LinkBatch for the userLink |
67 | return [ Title::makeTitle( NS_USER_TALK, $this->entry->getTarget()->getText() ) ]; |
68 | } |
69 | |
70 | return []; |
71 | } |
72 | } |