Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| InvalidateBotPasswords | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| execute | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Invalidates the bot passwords of a given user |
| 4 | * |
| 5 | * @license GPL-2.0-or-later |
| 6 | * @file |
| 7 | * @ingroup Maintenance |
| 8 | */ |
| 9 | |
| 10 | use MediaWiki\Maintenance\Maintenance; |
| 11 | use MediaWiki\User\BotPassword; |
| 12 | |
| 13 | // @codeCoverageIgnoreStart |
| 14 | require_once __DIR__ . '/Maintenance.php'; |
| 15 | // @codeCoverageIgnoreEnd |
| 16 | |
| 17 | /** |
| 18 | * Maintenance script to invalidate the bot passwords of a given user. |
| 19 | * |
| 20 | * @ingroup Maintenance |
| 21 | */ |
| 22 | class InvalidateBotPasswords extends Maintenance { |
| 23 | public function __construct() { |
| 24 | parent::__construct(); |
| 25 | $this->addOption( "user", "The username to operate on", false, true ); |
| 26 | $this->addOption( "userid", "The user id to operate on", false, true ); |
| 27 | $this->addDescription( "Invalidate a user's bot passwords" ); |
| 28 | } |
| 29 | |
| 30 | public function execute() { |
| 31 | $user = $this->validateUserOption( "A \"user\" or \"userid\" must be set to invalidate the bot passwords for" ); |
| 32 | |
| 33 | $res = BotPassword::invalidateAllPasswordsForUser( $user->getName() ); |
| 34 | |
| 35 | if ( $res ) { |
| 36 | $this->output( "Bot passwords invalidated for " . $user->getName() . "\n" ); |
| 37 | } else { |
| 38 | $this->output( "No bot passwords invalidated for " . $user->getName() . "\n" ); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | // @codeCoverageIgnoreStart |
| 44 | $maintClass = InvalidateBotPasswords::class; |
| 45 | require_once RUN_MAINTENANCE_IF_MAIN; |
| 46 | // @codeCoverageIgnoreEnd |