31require_once __DIR__ .
'/../Maintenance.php';
55 parent::__construct();
59 $this->
addOption(
'user',
'If specified, only checks the given user',
false,
true );
60 $this->
addOption(
'delete',
'Really delete. To prevent accidents, you must provide this flag.' );
61 $this->
addOption(
'prefix',
"Instead of deleting, make passwords invalid by prefixing with "
62 .
"':null:'. Make sure PasswordConfig has a 'null' entry. This is meant for testing before "
64 $this->
addOption(
'unprefix',
'Instead of deleting, undo the effect of --prefix.' );
70 + (
int)$this->
hasOption(
'unprefix' ) !== 1
72 $this->
fatalError(
"Exactly one of the 'delete', 'prefix', 'unprefix' options must be used\n" );
77 !isset( $passwordHashTypes[
'null'] )
78 || $passwordHashTypes[
'null'][
'class'] !== InvalidPassword::class
82'null' password entry missing. To use password prefixing, add
84to your configuration (and
remove once the passwords were deleted).
91 if (
$user !==
false ) {
93 $this->user = $userNameUtils->getCanonical(
$user );
94 if ( $this->user ===
false ) {
107 $this->
output(
"done. (wrote $this->total rows)\n" );
126 ->set( [
'user_password' => PasswordFactory::newInvalidPassword()->toString() ] )
127 ->where( [
'user_name' => $userBatch ] )
128 ->caller( __METHOD__ )->execute();
129 } elseif ( $this->
getOption(
'prefix' ) ) {
139 $dbw->
expr(
'user_password',
'!=', PasswordFactory::newInvalidPassword()->toString() ),
140 $dbw->
expr(
'user_password',
'!=',
null ),
141 'user_name' => $userBatch,
143 ->caller( __METHOD__ )->execute();
144 } elseif ( $this->
getOption(
'unprefix' ) ) {
154 'user_name' => $userBatch,
156 ->caller( __METHOD__ )->execute();
172 if ( $this->user !==
null ) {
173 $this->
output(
"\t ... querying '$this->user'\n" );
181 $this->
output(
"\t ... querying from '$lastUsername'\n" );
182 $users = $dbw->newSelectQueryBuilder()
183 ->select(
'user_name' )
185 ->where( $dbw->expr(
'user_name',
'>', $lastUsername ) )
186 ->orderBy(
'user_name ASC' )
188 ->caller( __METHOD__ )->fetchFieldValues();
191 $lastUsername = end( $users );
Delete unused local passwords.
execute()
Do the actual work.
__construct()
Default constructor.
string null $user
User to run on, or null for all.
int $total
Number of deleted passwords.
processUsers(array $userBatch, IDatabase $dbw)
getUserBatches()
This method iterates through the requested users and returns their names in batches of self::$mBatchS...
getUserDB()
Get the primary DB handle for the current user batch.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
waitForReplication()
Wait for replica DBs to catch up.
hasOption( $name)
Checks to see if a particular option was set.
getServiceContainer()
Returns the main service container.
getBatchSize()
Returns batch size.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
$wgPasswordConfig
Config variable stub for the PasswordConfig setting, for use by phpdoc and IDEs.