16require_once __DIR__ .
'/Maintenance.php';
27 parent::__construct();
29 'Invalidate the sessions of certain users on the wiki.'
31 $this->
addOption(
'user',
'Username',
false,
true,
'u' );
32 $this->
addOption(
'file',
'File with one username per line',
false,
true,
'f' );
40 if ( $username ===
null && $file ===
null ) {
41 $this->
fatalError(
'Either --user or --file is required' );
42 } elseif ( $username !==
null && $file !==
null ) {
43 $this->
fatalError(
'Cannot use both --user and --file' );
46 if ( $username !==
null ) {
47 $usernames = [ $username ];
49 $usernames = is_readable( $file ) ?
50 file( $file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) :
false;
51 if ( $usernames ===
false ) {
52 $this->
fatalError(
"Could not open $file", 2 );
57 $sessionManager = SessionManager::singleton();
58 foreach ( $usernames as $username ) {
60 $user = User::newFromName( $username );
62 $sessionManager->invalidateSessionsForUser( $user );
63 if ( $user->isRegistered() ) {
64 $this->
output(
"Invalidated sessions for user $username\n" );
66 # session invalidation might still work if there is a central identity provider
67 $this->
output(
"Could not find user $username, tried to invalidate anyway\n" );
69 }
catch ( Exception $e ) {
70 $this->
output(
"Failed to invalidate sessions for user $username | "
71 . str_replace( [
"\r",
"\n" ],
' ', $e->getMessage() ) .
"\n" );
83require_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.