Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
GlobalRenameUserDatabaseUpdates | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
update | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\CentralAuth\GlobalRename; |
4 | |
5 | use MediaWiki\Extension\CentralAuth\CentralAuthDatabaseManager; |
6 | |
7 | /** |
8 | * Update the rows in the CentralAuth tables during a rename |
9 | * |
10 | * @license GPL-2.0-or-later |
11 | * @author Marius Hoch < hoo@online.de > |
12 | */ |
13 | class GlobalRenameUserDatabaseUpdates { |
14 | |
15 | private CentralAuthDatabaseManager $databaseManager; |
16 | |
17 | public function __construct( CentralAuthDatabaseManager $databaseManager ) { |
18 | $this->databaseManager = $databaseManager; |
19 | } |
20 | |
21 | /** |
22 | * @param string $oldname |
23 | * @param string $newname |
24 | * @param int|null $type |
25 | */ |
26 | public function update( $oldname, $newname, $type = GlobalRenameRequest::RENAME ) { |
27 | $dbw = $this->databaseManager->getCentralPrimaryDB(); |
28 | |
29 | $data = [ 'gu_name' => $newname ]; |
30 | if ( $type === GlobalRenameRequest::VANISH ) { |
31 | // Vanish requests need to remove user's email |
32 | $data[ 'gu_email' ] = ''; |
33 | } |
34 | |
35 | $dbw->startAtomic( __METHOD__ ); |
36 | $dbw->newUpdateQueryBuilder() |
37 | ->update( 'globaluser' ) |
38 | ->set( $data ) |
39 | ->where( [ 'gu_name' => $oldname ] ) |
40 | ->caller( __METHOD__ ) |
41 | ->execute(); |
42 | |
43 | $dbw->newDeleteQueryBuilder() |
44 | ->deleteFrom( 'localuser' ) |
45 | ->where( [ 'lu_name' => $oldname ] ) |
46 | ->caller( __METHOD__ ) |
47 | ->execute(); |
48 | |
49 | $dbw->endAtomic( __METHOD__ ); |
50 | } |
51 | } |