Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
BatchCAAntiSpoof | |
0.00% |
0 / 9 |
|
0.00% |
0 / 6 |
56 | |
0.00% |
0 / 1 |
batchRecord | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDB | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getTableName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPrimaryKey | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getUserColumn | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
makeSpoofUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | // Go through all usernames and calculate and record spoof thingies |
3 | |
4 | namespace MediaWiki\Extension\CentralAuth\Maintenance; |
5 | |
6 | use BatchAntiSpoof; |
7 | use MediaWiki\Extension\CentralAuth\CentralAuthServices; |
8 | use MediaWiki\Extension\CentralAuth\User\CentralAuthSpoofUser; |
9 | use Wikimedia\Rdbms\IReadableDatabase; |
10 | |
11 | $IP = getenv( 'MW_INSTALL_PATH' ); |
12 | if ( $IP === false ) { |
13 | $IP = __DIR__ . '/../../..'; |
14 | } |
15 | require_once "$IP/extensions/AntiSpoof/maintenance/BatchAntiSpoofClass.php"; |
16 | |
17 | class BatchCAAntiSpoof extends BatchAntiSpoof { |
18 | |
19 | /** |
20 | * @param array $items |
21 | */ |
22 | protected function batchRecord( $items ) { |
23 | CentralAuthSpoofUser::batchRecord( CentralAuthServices::getDatabaseManager()->getCentralPrimaryDB(), $items ); |
24 | } |
25 | |
26 | /** |
27 | * @param int $db |
28 | * @param string|string[] $groups |
29 | * @param string|bool $wiki |
30 | * @return IReadableDatabase |
31 | * @suppress PhanParamSignatureMismatch |
32 | */ |
33 | protected function getDB( $db, $groups = [], $wiki = false ) { |
34 | if ( $db === DB_PRIMARY ) { |
35 | return CentralAuthServices::getDatabaseManager()->getCentralPrimaryDB(); |
36 | } else { |
37 | return CentralAuthServices::getDatabaseManager()->getCentralReplicaDB(); |
38 | } |
39 | } |
40 | |
41 | /** @inheritDoc */ |
42 | protected function getTableName() { |
43 | return 'globaluser'; |
44 | } |
45 | |
46 | /** @inheritDoc */ |
47 | protected function getPrimaryKey() { |
48 | return 'gu_id'; |
49 | } |
50 | |
51 | /** @inheritDoc */ |
52 | protected function getUserColumn() { |
53 | return 'gu_name'; |
54 | } |
55 | |
56 | /** |
57 | * @param string $name |
58 | * @return CentralAuthSpoofUser |
59 | */ |
60 | protected function makeSpoofUser( $name ) { |
61 | return CentralAuthServices::getAntiSpoofManager()->getSpoofUser( $name ); |
62 | } |
63 | } |
64 | |
65 | $maintClass = BatchCAAntiSpoof::class; |
66 | require_once RUN_MAINTENANCE_IF_MAIN; |