MediaWiki master
ExpireTemporaryAccounts Class Reference

Expire temporary accounts that are registered for longer than expiryAfterDays days (defined in $wgAutoCreateTempUser) by forcefully logging them out. More...

Inherits Maintenance.

Collaboration diagram for ExpireTemporaryAccounts:

Public Member Functions

 __construct ()
 
 execute ()
 

Protected Member Functions

 expireTemporaryAccount (UserIdentity $tempAccountUserIdentity)
 Expire a temporary account.
 
 getTempAccountsToExpireQueryBuilder (int $registeredBeforeUnix, int $frequencyDays)
 Return a SelectQueryBuilder that returns temp accounts to invalidate.
 
 initServices ()
 Construct services the script needs to use.
 
 queryBuilderToUserIdentities (SelectQueryBuilder $queryBuilder)
 Convert a SelectQueryBuilder into a list of user identities.
 
 verboseLog (string $log)
 If –verbose is passed, log to output.
 

Protected Attributes

AuthManager $authManager
 
TempUserConfig $tempUserConfig
 
UserFactory $userFactory
 
UserIdentityLookup $userIdentityLookup
 
UserIdentityUtils $userIdentityUtils
 

Detailed Description

Expire temporary accounts that are registered for longer than expiryAfterDays days (defined in $wgAutoCreateTempUser) by forcefully logging them out.

Extensions can extend this class to provide their own logic of determining a list of temporary accounts to expire.

Stability: stable
to extend
Since
1.42

Definition at line 28 of file expireTemporaryAccounts.php.

Constructor & Destructor Documentation

◆ __construct()

ExpireTemporaryAccounts::__construct ( )

Definition at line 36 of file expireTemporaryAccounts.php.

Member Function Documentation

◆ execute()

ExpireTemporaryAccounts::execute ( )

Definition at line 150 of file expireTemporaryAccounts.php.

References wfTimestamp().

◆ expireTemporaryAccount()

ExpireTemporaryAccounts::expireTemporaryAccount ( UserIdentity $tempAccountUserIdentity)
protected

Expire a temporary account.

Default implementation calls AuthManager::revokeAccessForUser and SessionManager::invalidateSessionsForUser.

Stability: stable
to override
Parameters
UserIdentity$tempAccountUserIdentity

Definition at line 140 of file expireTemporaryAccounts.php.

◆ getTempAccountsToExpireQueryBuilder()

ExpireTemporaryAccounts::getTempAccountsToExpireQueryBuilder ( int $registeredBeforeUnix,
int $frequencyDays )
protected

Return a SelectQueryBuilder that returns temp accounts to invalidate.

This method should return temporary accounts that registered before $registeredBeforeUnix. To avoid returning an ever-growing set of accounts, the method should skip users that were supposedly invalidated by a previous script run (script runs each $frequencyDays days).

If you override this method, you probably also want to override queryBuilderToUserIdentities().

Stability: stable
to override
Parameters
int$registeredBeforeUnixCutoff Unix timestamp
int$frequencyDaysScript runs each $frequencyDays days
Returns
SelectQueryBuilder

Definition at line 92 of file expireTemporaryAccounts.php.

◆ initServices()

ExpireTemporaryAccounts::initServices ( )
protected

Construct services the script needs to use.

Stability: stable
to override

Definition at line 55 of file expireTemporaryAccounts.php.

◆ queryBuilderToUserIdentities()

ExpireTemporaryAccounts::queryBuilderToUserIdentities ( SelectQueryBuilder $queryBuilder)
protected

Convert a SelectQueryBuilder into a list of user identities.

Default implementation expects $queryBuilder is an instance of UserSelectQueryBuilder. If you override getTempAccountsToExpireQueryBuilder() to work with a different query builder, this method should be overriden to properly convert the query builder into user identities.

Exceptions
LogicExceptionif $queryBuilder is not UserSelectQueryBuilder
Stability: stable
to override
Parameters
SelectQueryBuilder$queryBuilder
Returns
Iterator<UserIdentity>

Definition at line 120 of file expireTemporaryAccounts.php.

◆ verboseLog()

ExpireTemporaryAccounts::verboseLog ( string $log)
protected

If –verbose is passed, log to output.

Parameters
string$log
Returns
void

Definition at line 71 of file expireTemporaryAccounts.php.

Member Data Documentation

◆ $authManager

AuthManager ExpireTemporaryAccounts::$authManager
protected

Definition at line 32 of file expireTemporaryAccounts.php.

◆ $tempUserConfig

TempUserConfig ExpireTemporaryAccounts::$tempUserConfig
protected

Definition at line 33 of file expireTemporaryAccounts.php.

◆ $userFactory

UserFactory ExpireTemporaryAccounts::$userFactory
protected

Definition at line 31 of file expireTemporaryAccounts.php.

◆ $userIdentityLookup

UserIdentityLookup ExpireTemporaryAccounts::$userIdentityLookup
protected

Definition at line 30 of file expireTemporaryAccounts.php.

◆ $userIdentityUtils

UserIdentityUtils ExpireTemporaryAccounts::$userIdentityUtils
protected

Definition at line 34 of file expireTemporaryAccounts.php.


The documentation for this class was generated from the following file: