MediaWiki  master
MediaWiki\User\BotPasswordStore Class Reference
Inheritance diagram for MediaWiki\User\BotPasswordStore:
Collaboration diagram for MediaWiki\User\BotPasswordStore:

Public Member Functions

 __construct (ServiceOptions $options, CentralIdLookup $centralIdLookup, LBFactory $lbFactory)
 
 deleteBotPassword (BotPassword $botPassword)
 Delete an existing BotPassword in the database. More...
 
 getByCentralId (int $centralId, string $appId, int $flags=self::READ_NORMAL)
 Load a BotPassword from the database. More...
 
 getByUser (UserIdentity $userIdentity, string $appId, int $flags=self::READ_NORMAL)
 Load a BotPassword from the database based on a UserIdentity object. More...
 
 getDatabase (int $db)
 Get a database connection for the bot passwords database. More...
 
 insertBotPassword (BotPassword $botPassword, Password $password=null)
 Save the new BotPassword to the database. More...
 
 invalidateUserPasswords (string $username)
 Invalidate all passwords for a user, by name. More...
 
 newUnsavedBotPassword (array $data, int $flags=self::READ_NORMAL)
 Create an unsaved BotPassword. More...
 
 removeUserPasswords (string $username)
 Remove all passwords for a user, by name. More...
 
 updateBotPassword (BotPassword $botPassword, Password $password=null)
 Update an existing BotPassword in the database. More...
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 
- Public Attributes inherited from IDBAccessObject
const READ_NONE = -1
 Constants for object loading bitfield flags (higher => higher QoS) More...
 

Private Member Functions

 validateBotPassword (BotPassword $botPassword)
 Check if a BotPassword is valid to save in the database (either inserting a new one or updating an existing one) based on the size of the restrictions and grants. More...
 

Private Attributes

CentralIdLookup $centralIdLookup
 
LBFactory $lbFactory
 
ServiceOptions $options
 

Detailed Description

Author
DannyS712
Since
1.37

Definition at line 44 of file BotPasswordStore.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\BotPasswordStore::__construct ( ServiceOptions  $options,
CentralIdLookup  $centralIdLookup,
LBFactory  $lbFactory 
)

Member Function Documentation

◆ deleteBotPassword()

MediaWiki\User\BotPasswordStore::deleteBotPassword ( BotPassword  $botPassword)

Delete an existing BotPassword in the database.

Parameters
BotPassword$botPassword
Returns
bool

Definition at line 353 of file BotPasswordStore.php.

References DB_PRIMARY, BotPassword\getAppId(), MediaWiki\User\BotPasswordStore\getDatabase(), and BotPassword\getUserCentralId().

◆ getByCentralId()

MediaWiki\User\BotPasswordStore::getByCentralId ( int  $centralId,
string  $appId,
int  $flags = self::READ_NORMAL 
)

Load a BotPassword from the database.

Parameters
int$centralIdfrom CentralIdLookup
string$appId
int$flagsIDBAccessObject read flags
Returns
BotPassword|null

Definition at line 134 of file BotPasswordStore.php.

References MediaWiki\User\BotPasswordStore\$options, MediaWiki\User\BotPasswordStore\getDatabase(), and DBAccessObjectUtils\getDBOptions().

Referenced by MediaWiki\User\BotPasswordStore\getByUser().

◆ getByUser()

MediaWiki\User\BotPasswordStore::getByUser ( UserIdentity  $userIdentity,
string  $appId,
int  $flags = self::READ_NORMAL 
)

Load a BotPassword from the database based on a UserIdentity object.

Parameters
UserIdentity$userIdentity
string$appId
int$flagsIDBAccessObject read flags
Returns
BotPassword|null

Definition at line 110 of file BotPasswordStore.php.

References CentralIdLookup\AUDIENCE_RAW, and MediaWiki\User\BotPasswordStore\getByCentralId().

◆ getDatabase()

MediaWiki\User\BotPasswordStore::getDatabase ( int  $db)

Get a database connection for the bot passwords database.

Parameters
int$dbIndex of the connection to get, e.g. DB_PRIMARY or DB_REPLICA.
Returns
IDatabase
Access: internal

Definition at line 86 of file BotPasswordStore.php.

Referenced by MediaWiki\User\BotPasswordStore\deleteBotPassword(), MediaWiki\User\BotPasswordStore\getByCentralId(), MediaWiki\User\BotPasswordStore\insertBotPassword(), MediaWiki\User\BotPasswordStore\invalidateUserPasswords(), MediaWiki\User\BotPasswordStore\removeUserPasswords(), and MediaWiki\User\BotPasswordStore\updateBotPassword().

◆ insertBotPassword()

MediaWiki\User\BotPasswordStore::insertBotPassword ( BotPassword  $botPassword,
Password  $password = null 
)

◆ invalidateUserPasswords()

MediaWiki\User\BotPasswordStore::invalidateUserPasswords ( string  $username)

Invalidate all passwords for a user, by name.

Parameters
string$usernameUser name
Returns
bool Whether any passwords were invalidated

Definition at line 372 of file BotPasswordStore.php.

References CentralIdLookup\AUDIENCE_RAW, DB_PRIMARY, MediaWiki\User\BotPasswordStore\getDatabase(), and PasswordFactory\newInvalidPassword().

◆ newUnsavedBotPassword()

MediaWiki\User\BotPasswordStore::newUnsavedBotPassword ( array  $data,
int  $flags = self::READ_NORMAL 
)

Create an unsaved BotPassword.

Parameters
array$dataData to use to create the bot password. Keys are:
  • user: (UserIdentity) UserIdentity to create the password for. Overrides username and centralId.
  • username: (string) Username to create the password for. Overrides centralId.
  • centralId: (int) User central ID to create the password for.
  • appId: (string, required) App ID for the password.
  • restrictions: (MWRestrictions, optional) Restrictions.
  • grants: (string[], optional) Grants.
int$flagsIDBAccessObject read flags
Returns
BotPassword|null

Definition at line 167 of file BotPasswordStore.php.

References BotPassword\APPID_MAXLENGTH, CentralIdLookup\AUDIENCE_RAW, FormatJson\encode(), and MWRestrictions\newDefault().

◆ removeUserPasswords()

MediaWiki\User\BotPasswordStore::removeUserPasswords ( string  $username)

Remove all passwords for a user, by name.

Parameters
string$usernameUser name
Returns
bool Whether any passwords were removed

Definition at line 401 of file BotPasswordStore.php.

References CentralIdLookup\AUDIENCE_RAW, DB_PRIMARY, and MediaWiki\User\BotPasswordStore\getDatabase().

◆ updateBotPassword()

MediaWiki\User\BotPasswordStore::updateBotPassword ( BotPassword  $botPassword,
Password  $password = null 
)

Update an existing BotPassword in the database.

Access: internal
Parameters
BotPassword$botPassword
Password | null$passwordUse null for an invalid password
Returns
StatusValue if everything worked, the value of the StatusValue is the new token

Definition at line 281 of file BotPasswordStore.php.

References $res, DB_PRIMARY, FormatJson\encode(), MWCryptRand\generateHex(), BotPassword\getAppId(), MediaWiki\User\BotPasswordStore\getDatabase(), BotPassword\getGrants(), BotPassword\getRestrictions(), BotPassword\getUserCentralId(), StatusValue\newFatal(), StatusValue\newGood(), User\TOKEN_LENGTH, and MediaWiki\User\BotPasswordStore\validateBotPassword().

◆ validateBotPassword()

MediaWiki\User\BotPasswordStore::validateBotPassword ( BotPassword  $botPassword)
private

Check if a BotPassword is valid to save in the database (either inserting a new one or updating an existing one) based on the size of the restrictions and grants.

Parameters
BotPassword$botPassword
Returns
StatusValue

Definition at line 331 of file BotPasswordStore.php.

References $res, FormatJson\encode(), BotPassword\getGrants(), BotPassword\getRestrictions(), BotPassword\GRANTS_MAXLENGTH, StatusValue\newGood(), and BotPassword\RESTRICTIONS_MAXLENGTH.

Referenced by MediaWiki\User\BotPasswordStore\insertBotPassword(), and MediaWiki\User\BotPasswordStore\updateBotPassword().

Member Data Documentation

◆ $centralIdLookup

CentralIdLookup MediaWiki\User\BotPasswordStore::$centralIdLookup
private

Definition at line 62 of file BotPasswordStore.php.

Referenced by MediaWiki\User\BotPasswordStore\__construct().

◆ $lbFactory

LBFactory MediaWiki\User\BotPasswordStore::$lbFactory
private

Definition at line 59 of file BotPasswordStore.php.

Referenced by MediaWiki\User\BotPasswordStore\__construct().

◆ $options

ServiceOptions MediaWiki\User\BotPasswordStore::$options
private

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\User\BotPasswordStore::CONSTRUCTOR_OPTIONS
Initial value:
= [
'EnableBotPasswords',
'BotPasswordsCluster',
'BotPasswordsDatabase',
]
Access: internal
For use by ServiceWiring

Definition at line 49 of file BotPasswordStore.php.


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