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\Title\Title; |
27 | use MediaWiki\User\User; |
28 | |
29 | /** |
30 | * This class formats new user log entries. |
31 | * |
32 | * @since 1.19 |
33 | */ |
34 | class NewUsersLogFormatter extends LogFormatter { |
35 | protected function getMessageParameters() { |
36 | $params = parent::getMessageParameters(); |
37 | $subtype = $this->entry->getSubtype(); |
38 | if ( $subtype === 'create2' || $subtype === 'byemail' ) { |
39 | if ( isset( $params[3] ) ) { |
40 | $target = User::newFromId( $params[3] ); |
41 | } else { |
42 | $target = User::newFromName( $this->entry->getTarget()->getText(), false ); |
43 | } |
44 | $params[2] = Message::rawParam( $this->makeUserLink( $target ) ); |
45 | $params[3] = $target->getName(); |
46 | } |
47 | |
48 | return $params; |
49 | } |
50 | |
51 | public function getComment() { |
52 | $timestamp = wfTimestamp( TS_MW, $this->entry->getTimestamp() ); |
53 | if ( $timestamp < '20080129000000' ) { |
54 | # Suppress $comment from old entries (before 2008-01-29), |
55 | # not needed and can contain incorrect links |
56 | return ''; |
57 | } |
58 | |
59 | return parent::getComment(); |
60 | } |
61 | |
62 | public function getPreloadTitles() { |
63 | $subtype = $this->entry->getSubtype(); |
64 | if ( $subtype === 'create2' || $subtype === 'byemail' ) { |
65 | // add the user talk to LinkBatch for the userLink |
66 | return [ Title::makeTitle( NS_USER_TALK, $this->entry->getTarget()->getText() ) ]; |
67 | } |
68 | |
69 | return []; |
70 | } |
71 | } |