Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Hooks
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 onLocalUserCreated
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 onRenameUserComplete
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 */
18
19namespace MediaWiki\Extension\AntiSpoof;
20
21use MediaWiki\Auth\Hook\LocalUserCreatedHook;
22use MediaWiki\RenameUser\Hook\RenameUserCompleteHook;
23use User;
24
25class Hooks implements
26    LocalUserCreatedHook,
27    RenameUserCompleteHook
28{
29    /**
30     * On new account creation, record the username's thing-bob.
31     * Replaces AddNewAccountHook for more modern MediaWiki versions-
32     *
33     * @param User $user
34     * @param bool $autocreated
35     */
36    public function onLocalUserCreated( $user, $autocreated ) {
37        if ( !$user->isTemp() ) {
38            $spoof = new SpoofUser( $user->getName() );
39            $spoof->record();
40        }
41    }
42
43    /**
44     * On rename, remove the old entry and add the new
45     * (After a successful user rename)
46     *
47     * @param int $uid
48     * @param string $oldName
49     * @param string $newName
50     */
51    public function onRenameUserComplete( int $uid, string $oldName, string $newName ): void {
52        $spoof = new SpoofUser( $newName );
53        $spoof->update( $oldName );
54    }
55}