30require_once __DIR__ .
'/Maintenance.php';
41 parent::__construct();
43 'Invalidate the sessions of certain users on the wiki.'
45 $this->
addOption(
'user',
'Username',
false,
true,
'u' );
46 $this->
addOption(
'file',
'File with one username per line',
false,
true,
'f' );
54 if ( $username ===
null && $file ===
null ) {
55 $this->
fatalError(
'Either --user or --file is required' );
56 } elseif ( $username !==
null && $file !==
null ) {
57 $this->
fatalError(
'Cannot use both --user and --file' );
60 if ( $username !==
null ) {
61 $usernames = [ $username ];
63 $usernames = is_readable( $file ) ?
64 file( $file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) :
false;
65 if ( $usernames ===
false ) {
66 $this->
fatalError(
"Could not open $file", 2 );
71 $sessionManager = SessionManager::singleton();
72 foreach ( $usernames as $username ) {
74 $user = User::newFromName( $username );
76 $sessionManager->invalidateSessionsForUser( $user );
77 if ( $user->isRegistered() ) {
78 $this->
output(
"Invalidated sessions for user $username\n" );
80 # session invalidation might still work if there is a central identity provider
81 $this->
output(
"Could not find user $username, tried to invalidate anyway\n" );
83 }
catch ( Exception $e ) {
84 $this->
output(
"Failed to invalidate sessions for user $username | "
85 . str_replace( [
"\r",
"\n" ],
' ', $e->getMessage() ) .
"\n" );
97require_once RUN_MAINTENANCE_IF_MAIN;
Invalidate the sessions of certain users on the wiki.
__construct()
Default constructor.
execute()
Do the actual work.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getBatchSize()
Returns batch size.
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.
waitForReplication()
Wait for replica DB servers to catch up.
getOption( $name, $default=null)
Get an option, or return the default.
addDescription( $text)
Set the description text.