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