MediaWiki master
MediaWiki\User\ActorStore Class Reference

Inherits MediaWiki\User\UserIdentityLookup, and MediaWiki\User\ActorNormalization.

Collaboration diagram for MediaWiki\User\ActorStore:

Public Member Functions

 __construct (ILoadBalancer $loadBalancer, UserNameUtils $userNameUtils, TempUserConfig $tempUserConfig, LoggerInterface $logger, HideUserUtils $hideUserUtils, $wikiId=WikiAwareEntity::LOCAL)
 
 acquireActorId (UserIdentity $user, IDatabase $dbw)
 Attempt to assign an actor ID to the given $user.
 
 acquireSystemActorId (UserIdentity $user, IDatabase $dbw)
 Attempt to assign an ID to an actor for a system user.
 
 createNewActor (UserIdentity $user, IDatabase $dbw)
 Create a new actor for the given $user.
 
 deleteActor (UserIdentity $actor, IDatabase $dbw)
 Delete the actor from the actor table.
 
 deleteUserIdentityFromCache (UserIdentity $actor)
 
 findActorId (UserIdentity $user, IReadableDatabase $db)
 Find the actor_id of the given $user.
 
 findActorIdByName ( $name, IReadableDatabase $db)
 Find the actor_id of the given $name.
 
 getActorById (int $actorId, IReadableDatabase $db)
 Find an actor by $id.
 
 getUnknownActor ()
 In case all reasonable attempts of initializing a proper actor from the database have failed, entities can be attributed to special 'Unknown user' actor.
 
 getUserIdentityByName (string $name, int $queryFlags=IDBAccessObject::READ_NORMAL)
 Find an actor by $name.
 
 getUserIdentityByUserId (int $userId, int $queryFlags=IDBAccessObject::READ_NORMAL)
 Find an actor by $userId.
 
 newActorFromRow (stdClass $row)
 Instantiate a new UserIdentity object based on a $row from the actor table.
 
 newActorFromRowFields ( $userId, $name, $actorId)
 Instantiate a new UserIdentity object based on field values from a DB row.
 
 newSelectQueryBuilder ( $dbOrQueryFlags=IDBAccessObject::READ_NORMAL)
 Returns a specialized SelectQueryBuilder for querying the UserIdentity objects.
 
 normalizeUserName (string $name)
 Returns a canonical form of user name suitable for storage.
 
 setAllowCreateIpActors (bool $allow)
 
- Public Member Functions inherited from MediaWiki\User\ActorNormalization
 findActorIdByName (string $name, IReadableDatabase $db)
 Find the actor_id for the given name.
 

Public Attributes

const UNKNOWN_USER_NAME = 'Unknown user'
 

Detailed Description

Definition at line 44 of file ActorStore.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\ActorStore::__construct ( ILoadBalancer $loadBalancer,
UserNameUtils $userNameUtils,
TempUserConfig $tempUserConfig,
LoggerInterface $logger,
HideUserUtils $hideUserUtils,
$wikiId = WikiAwareEntity::LOCAL )
Parameters
ILoadBalancer$loadBalancer
UserNameUtils$userNameUtils
TempUserConfig$tempUserConfig
LoggerInterface$logger
HideUserUtils$hideUserUtils
string | false$wikiId

Definition at line 71 of file ActorStore.php.

Member Function Documentation

◆ acquireActorId()

MediaWiki\User\ActorStore::acquireActorId ( UserIdentity $user,
IDatabase $dbw )

Attempt to assign an actor ID to the given $user.

If it is already assigned, return the existing ID.

Note
If called within a transaction, the returned ID might become invalid if the transaction is rolled back, so it should not be passed outside of the transaction context.
Parameters
UserIdentity$user
IDatabase$dbwThe database connection to acquire the ID from. The database must correspond to ActorStore's wiki ID.
Returns
int actor ID greater then 0
Exceptions
CannotCreateActorExceptionif no actor ID has been assigned to this $user

Implements MediaWiki\User\ActorNormalization.

Definition at line 413 of file ActorStore.php.

◆ acquireSystemActorId()

MediaWiki\User\ActorStore::acquireSystemActorId ( UserIdentity $user,
IDatabase $dbw )

Attempt to assign an ID to an actor for a system user.

If an actor ID already exists, return it.

Note
For reserved user names this method will overwrite the user ID of the existing anon actor.
If called within a transaction, the returned ID might become invalid if the transaction is rolled back, so it should not be passed outside of the transaction context.
Parameters
UserIdentity$user
IDatabase$dbw
Returns
int actor ID greater then zero
Exceptions
CannotCreateActorExceptionif the existing actor is associated with registered user.
Access: internal
for use in user account creation only.

Definition at line 505 of file ActorStore.php.

◆ createNewActor()

MediaWiki\User\ActorStore::createNewActor ( UserIdentity $user,
IDatabase $dbw )

Create a new actor for the given $user.

If an actor with this name already exists, this method throws.

Note
If called within a transaction, the returned ID might become invalid if the transaction is rolled back, so it should not be passed outside of the transaction context.
Parameters
UserIdentity$user
IDatabase$dbw
Returns
int actor ID greater then 0
Exceptions
CannotCreateActorExceptionif an actor with this name already exist.
Access: internal
for use in user account creation only.

Definition at line 465 of file ActorStore.php.

◆ deleteActor()

MediaWiki\User\ActorStore::deleteActor ( UserIdentity $actor,
IDatabase $dbw )

Delete the actor from the actor table.

Warning
this method does very limited validation and is extremely dangerous since it can break referential integrity of the database if used incorrectly. Use at your own risk!
Since
1.37
Parameters
UserIdentity$actor
IDatabase$dbw
Returns
bool true on success, false if nothing was deleted.

Definition at line 563 of file ActorStore.php.

◆ deleteUserIdentityFromCache()

MediaWiki\User\ActorStore::deleteUserIdentityFromCache ( UserIdentity $actor)
Parameters
UserIdentity$actor
Access: internal
for use in User object only

Definition at line 194 of file ActorStore.php.

◆ findActorId()

MediaWiki\User\ActorStore::findActorId ( UserIdentity $user,
IReadableDatabase $db )

Find the actor_id of the given $user.

Parameters
UserIdentity$user
IReadableDatabase$dbThe database connection to operate on. The database must correspond to ActorStore's wiki ID.
Returns
int|null

Implements MediaWiki\User\ActorNormalization.

Definition at line 311 of file ActorStore.php.

◆ findActorIdByName()

MediaWiki\User\ActorStore::findActorIdByName ( $name,
IReadableDatabase $db )

Find the actor_id of the given $name.

Parameters
string$name
IReadableDatabase$dbThe database connection to operate on. The database must correspond to ActorStore's wiki ID.
Returns
int|null

Definition at line 347 of file ActorStore.php.

◆ getActorById()

MediaWiki\User\ActorStore::getActorById ( int $actorId,
IReadableDatabase $db )

Find an actor by $id.

Parameters
int$actorId
IReadableDatabase$dbThe database connection to operate on. The database must correspond to ActorStore's wiki ID.
Returns
UserIdentity|null Returns null if no actor with this $actorId exists in the database.

Implements MediaWiki\User\ActorNormalization.

Definition at line 206 of file ActorStore.php.

◆ getUnknownActor()

MediaWiki\User\ActorStore::getUnknownActor ( )

In case all reasonable attempts of initializing a proper actor from the database have failed, entities can be attributed to special 'Unknown user' actor.

Returns
UserIdentity

Implements MediaWiki\User\ActorNormalization.

Definition at line 694 of file ActorStore.php.

◆ getUserIdentityByName()

MediaWiki\User\ActorStore::getUserIdentityByName ( string $name,
int $queryFlags = IDBAccessObject::READ_NORMAL )

Find an actor by $name.

Parameters
string$name
int$queryFlagsone of IDBAccessObject constants
Returns
UserIdentity|null

Implements MediaWiki\User\UserIdentityLookup.

Definition at line 234 of file ActorStore.php.

◆ getUserIdentityByUserId()

MediaWiki\User\ActorStore::getUserIdentityByUserId ( int $userId,
int $queryFlags = IDBAccessObject::READ_NORMAL )

Find an actor by $userId.

Parameters
int$userId
int$queryFlagsone of IDBAccessObject constants
Returns
UserIdentity|null

Implements MediaWiki\User\UserIdentityLookup.

Definition at line 257 of file ActorStore.php.

◆ newActorFromRow()

MediaWiki\User\ActorStore::newActorFromRow ( stdClass $row)

Instantiate a new UserIdentity object based on a $row from the actor table.

Use this method when an actor row was already fetched from the DB via a join. This method just constructs a new instance and does not try fetching missing values from the DB again, use UserIdentityLookup for that.

Parameters
stdClass$rowwith the following fields:
  • int actor_id
  • string actor_name
  • int|null actor_user
Returns
UserIdentity
Exceptions
InvalidArgumentException

Implements MediaWiki\User\ActorNormalization.

Definition at line 107 of file ActorStore.php.

◆ newActorFromRowFields()

MediaWiki\User\ActorStore::newActorFromRowFields ( $userId,
$name,
$actorId )

Instantiate a new UserIdentity object based on field values from a DB row.

Until ActorMigration is completed, the actor table joins alias actor field names to legacy field names. This method is convenience to construct the UserIdentity based on legacy field names. It's more relaxed with typing then ::newFromRow to better support legacy code, so always prefer ::newFromRow in new code. Eventually, once ActorMigration is completed and all queries use explicit join with actor table, this method will be deprecated and removed.

Exceptions
InvalidArgumentException
Parameters
int | null$userId
string | null$name
int | null$actorId
Returns
UserIdentity

Implements MediaWiki\User\ActorNormalization.

Definition at line 150 of file ActorStore.php.

◆ newSelectQueryBuilder()

MediaWiki\User\ActorStore::newSelectQueryBuilder ( $dbOrQueryFlags = IDBAccessObject::READ_NORMAL)

Returns a specialized SelectQueryBuilder for querying the UserIdentity objects.

Parameters
IReadableDatabase | int$dbOrQueryFlagsThe database connection to perform the query on, or one of IDBAccessObject::READ_* constants.
Returns
UserSelectQueryBuilder

Implements MediaWiki\User\UserIdentityLookup.

Definition at line 713 of file ActorStore.php.

◆ normalizeUserName()

MediaWiki\User\ActorStore::normalizeUserName ( string $name)

Returns a canonical form of user name suitable for storage.

Access: internal
Parameters
string$name
Returns
string|null

Definition at line 592 of file ActorStore.php.

◆ setAllowCreateIpActors()

MediaWiki\User\ActorStore::setAllowCreateIpActors ( bool $allow)
Access: internal
For use immediately after construction only
Parameters
bool$allow

Definition at line 739 of file ActorStore.php.

Member Data Documentation

◆ UNKNOWN_USER_NAME

const MediaWiki\User\ActorStore::UNKNOWN_USER_NAME = 'Unknown user'

Definition at line 46 of file ActorStore.php.


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