Go to the documentation of this file.
28 require_once __DIR__ .
'/Maintenance.php';
38 parent::__construct();
40 'Invalidate the sessions of certain users on the wiki.'
42 $this->
addOption(
'user',
'Username',
false,
true,
'u' );
43 $this->
addOption(
'file',
'File with one username per line',
false,
true,
'f' );
51 if (
$username ===
null && $file ===
null ) {
52 $this->
fatalError(
'Either --user or --file is required' );
53 } elseif (
$username !==
null && $file !==
null ) {
54 $this->
fatalError(
'Cannot use both --user and --file' );
60 $usernames = is_readable( $file ) ?
61 file( $file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) :
false;
62 if ( $usernames ===
false ) {
63 $this->
fatalError(
"Could not open $file", 2 );
68 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
69 $sessionManager = SessionManager::singleton();
74 $sessionManager->invalidateSessionsForUser(
$user );
75 if (
$user->getId() ) {
76 $this->
output(
"Invalidated sessions for user $username\n" );
78 # session invalidation might still work if there is a central identity provider
79 $this->
output(
"Could not find user $username, tried to invalidate anyway\n" );
81 }
catch ( Exception
$e ) {
82 $this->
output(
"Failed to invalidate sessions for user $username | "
83 . str_replace( [
"\r",
"\n" ],
' ',
$e->getMessage() ) .
"\n" );
87 $lbFactory->waitForReplication();
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
Invalidate the sessions of certain users on the wiki.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addDescription( $text)
Set the description text.
__construct()
Default constructor.
require_once RUN_MAINTENANCE_IF_MAIN
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
execute()
Do the actual work.
getOption( $name, $default=null)
Get an option, or return the default.
getBatchSize()
Returns batch size.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
output( $out, $channel=null)
Throw some output to the user.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
this hook is for auditing only or null if authentication failed before getting that far $username
setBatchSize( $s=0)
Set the batch size.