Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
GlobalRenameUserDatabaseUpdates | |
0.00% |
0 / 15 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
update | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
2 |
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 | /** @var CentralAuthDatabaseManager */ |
15 | private $databaseManager; |
16 | |
17 | /** |
18 | * @param CentralAuthDatabaseManager $databaseManager |
19 | */ |
20 | public function __construct( CentralAuthDatabaseManager $databaseManager ) { |
21 | $this->databaseManager = $databaseManager; |
22 | } |
23 | |
24 | /** |
25 | * @param string $oldname |
26 | * @param string $newname |
27 | */ |
28 | public function update( $oldname, $newname ) { |
29 | $dbw = $this->databaseManager->getCentralPrimaryDB(); |
30 | |
31 | $dbw->startAtomic( __METHOD__ ); |
32 | $dbw->newUpdateQueryBuilder() |
33 | ->update( 'globaluser' ) |
34 | ->set( [ 'gu_name' => $newname ] ) |
35 | ->where( [ 'gu_name' => $oldname ] ) |
36 | ->caller( __METHOD__ ) |
37 | ->execute(); |
38 | |
39 | $dbw->newDeleteQueryBuilder() |
40 | ->deleteFrom( 'localuser' ) |
41 | ->where( [ 'lu_name' => $oldname ] ) |
42 | ->caller( __METHOD__ ) |
43 | ->execute(); |
44 | |
45 | $dbw->endAtomic( __METHOD__ ); |
46 | } |
47 | } |