Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CreateLocalAccount | |
0.00% |
0 / 15 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\CentralAuth\Maintenance; |
4 | |
5 | $IP = getenv( 'MW_INSTALL_PATH' ); |
6 | if ( $IP === false ) { |
7 | $IP = __DIR__ . '/../../..'; |
8 | } |
9 | require_once "$IP/maintenance/Maintenance.php"; |
10 | |
11 | use MediaWiki\Extension\CentralAuth\CentralAuthServices; |
12 | use MediaWiki\Maintenance\Maintenance; |
13 | use MediaWiki\Permissions\UltimateAuthority; |
14 | use MediaWiki\User\User; |
15 | |
16 | class CreateLocalAccount extends Maintenance { |
17 | |
18 | public function __construct() { |
19 | parent::__construct(); |
20 | $this->requireExtension( 'CentralAuth' ); |
21 | $this->addDescription( 'Creates a local account on this wiki for a global user' ); |
22 | $this->addArg( 'username', 'User name', true ); |
23 | } |
24 | |
25 | public function execute() { |
26 | $username = $this->getArg( 0 ); |
27 | $status = CentralAuthServices::getForcedLocalCreationService() |
28 | ->attemptAutoCreateLocalUserFromName( |
29 | $username, |
30 | new UltimateAuthority( User::newSystemUser( User::MAINTENANCE_SCRIPT_USER, [ 'steal' => true ] ) ) |
31 | ); |
32 | |
33 | if ( !$status->isGood() ) { |
34 | $this->error( "autoCreateUser failed for $username:" ); |
35 | $this->error( $status ); |
36 | return; |
37 | } |
38 | |
39 | $this->output( "User '$username' created\n" ); |
40 | } |
41 | } |
42 | |
43 | $maintClass = CreateLocalAccount::class; |
44 | require_once RUN_MAINTENANCE_IF_MAIN; |