14require_once __DIR__ .
'/Maintenance.php';
26 parent::__construct();
27 $this->
addOption(
"user",
"The username to operate on",
false,
true );
28 $this->
addOption(
"userid",
"The user id to operate on",
false,
true );
29 $this->
addOption(
"password",
"The password to use",
false,
true );
31 $this->
addOption(
"passwordstdin",
"Makes the script read the password from stdin instead. Cannot be used alongside --password",
false,
false );
36 $user = $this->
validateUserOption(
"A \"user\" or \"userid\" must be set to change the password for" );
38 $password = $this->validatePasswordOption(
'Set either --password or --passwordstdin',
'Either --password or --passwordstdin must be set, not both at once' );
39 $status = $user->changeAuthenticationData( [
40 'username' => $user->getName(),
41 'password' => $password,
42 'retype' => $password,
44 if ( $status->isGood() ) {
45 $this->
output(
"Password set for " . $user->getName() .
"\n" );
59 private function validatePasswordOption( $errorMsgNoPassword, $errorMsgBothPasswords ) {
65 } elseif ( $this->
hasOption(
'passwordstdin' ) ) {
66 return $this->
getStdin( Maintenance::STDIN_ALL );
75require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script to change the password of a given user.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
validateUserOption( $errorMsg)
output( $out, $channel=null)
Throw some output to the user.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
hasOption( $name)
Checks to see if a particular option was set.
getOption( $name, $default=null)
Get an option, or return the default.
getStdin( $len=null)
Return input from stdin.
addDescription( $text)
Set the description text.