|
MediaWiki master
|
Create User objects. More...
Inherits MediaWiki\User\UserRigorOptions.

Public Member Functions | |
| __construct (private readonly ServiceOptions $options, private readonly ILBFactory $loadBalancerFactory, private readonly UserNameUtils $userNameUtils, private readonly TempUserConfig $tempUserConfig) | |
| invalidateCache (UserIdentity $userIdentity) | |
| Purge user-related caches, "touch" the user table to invalidate further caches. | |
| isUserTableShared () | |
| Returns if the user table is shared with other wikis. | |
| newAnonymous (?string $ip=null) | |
| Returns a new anonymous User based on ip. | |
| newFromActorId (int $actorId) | |
| Factory method for creation from a given actor ID, replacing User::newFromActorId. | |
| newFromAnyId (?int $userId, ?string $userName, ?int $actorId=null, $dbDomain=false) | |
| Factory method for creation from an ID, name, and/or actor ID, replacing User::newFromAnyId. | |
| newFromAuthority (Authority $authority) | |
| newFromConfirmationCode (string $confirmationCode, int $flags=IDBAccessObject::READ_NORMAL) | |
| Factory method to fetch the user for a given email confirmation code, replacing User::newFromConfirmationCode. | |
| newFromId (int $id) | |
| Factory method for creation from a given user ID, replacing User::newFromId. | |
| newFromName (string $name, string $validate=self::RIGOR_VALID) | |
| Factory method for creating users by name, replacing static User::newFromName. | |
| newFromNameOrIp (string $name) | |
| Returns either an anonymous or a named User based on the supplied argument. | |
| newFromRow ( $row, $data=null) | |
| newFromUserIdentity (UserIdentity $userIdentity) | |
| Factory method for creation from a given UserIdentity, replacing User::newFromIdentity. | |
| newTempPlaceholder () | |
| Create a placeholder user for an anonymous user who will be upgraded to a temporary user. | |
| newUnsavedTempUser (?string $name) | |
| Create an unsaved temporary user with a previously acquired name or a placeholder name. | |
Public Attributes | |
| const | CONSTRUCTOR_OPTIONS |
| RIGOR_* constants are inherited from UserRigorOptions. | |
Public Attributes inherited from MediaWiki\User\UserRigorOptions | |
| const | RIGOR_CREATABLE = 'creatable' |
| Check that a user name is valid for batch processes, login and account creation. | |
| const | RIGOR_NONE = 'none' |
| No validation at all. | |
| const | RIGOR_USABLE = 'usable' |
| Check that a user name is valid for batch processes and login. | |
| const | RIGOR_VALID = 'valid' |
| Check that a user name is valid for batch processes. | |
Create User objects.
This creates User objects and involves all the same global state, but wraps it in a service class to avoid static coupling, which eases mocking in unit tests.
Definition at line 32 of file UserFactory.php.
| MediaWiki\User\UserFactory::__construct | ( | private readonly ServiceOptions | $options, |
| private readonly ILBFactory | $loadBalancerFactory, | ||
| private readonly UserNameUtils | $userNameUtils, | ||
| private readonly TempUserConfig | $tempUserConfig ) |
Definition at line 48 of file UserFactory.php.
| MediaWiki\User\UserFactory::invalidateCache | ( | UserIdentity | $userIdentity | ) |
Purge user-related caches, "touch" the user table to invalidate further caches.
Definition at line 354 of file UserFactory.php.
| MediaWiki\User\UserFactory::isUserTableShared | ( | ) |
Returns if the user table is shared with other wikis.
Definition at line 409 of file UserFactory.php.
Referenced by MediaWiki\Specials\SpecialRenameUser\__construct().
| MediaWiki\User\UserFactory::newAnonymous | ( | ?string | $ip = null | ) |
Returns a new anonymous User based on ip.
| string | null | $ip | IP address |
Definition at line 102 of file UserFactory.php.
| MediaWiki\User\UserFactory::newFromActorId | ( | int | $actorId | ) |
Factory method for creation from a given actor ID, replacing User::newFromActorId.
Definition at line 156 of file UserFactory.php.
| MediaWiki\User\UserFactory::newFromAnyId | ( | ?int | $userId, |
| ?string | $userName, | ||
| ?int | $actorId = null, | ||
| $dbDomain = false ) |
Factory method for creation from an ID, name, and/or actor ID, replacing User::newFromAnyId.
| ?int | $userId | |
| ?string | $userName | |
| ?int | $actorId | |
| string | false | $dbDomain |
| InvalidArgumentException | if none of userId, userName, and actorId are specified |
Definition at line 214 of file UserFactory.php.
| MediaWiki\User\UserFactory::newFromAuthority | ( | Authority | $authority | ) |
Definition at line 317 of file UserFactory.php.
| MediaWiki\User\UserFactory::newFromConfirmationCode | ( | string | $confirmationCode, |
| int | $flags = IDBAccessObject::READ_NORMAL ) |
Factory method to fetch the user for a given email confirmation code, replacing User::newFromConfirmationCode.
This code is generated when an account is created or its e-mail address has changed. If the code is invalid or has expired, returns null.
Definition at line 276 of file UserFactory.php.
References DB_PRIMARY.
| MediaWiki\User\UserFactory::newFromId | ( | int | $id | ) |
Factory method for creation from a given user ID, replacing User::newFromId.
| int | $id | Valid user ID |
Definition at line 143 of file UserFactory.php.
| MediaWiki\User\UserFactory::newFromName | ( | string | $name, |
| string | $validate = self::RIGOR_VALID ) |
Factory method for creating users by name, replacing static User::newFromName.
This is slightly less efficient than newFromId(), so use newFromId() if you have both an ID and a name handy.
| string | $name | Username, validated by Title::newFromText |
| string | $validate | Validation strategy, one of the RIGOR_* constants. For no validation, use RIGOR_NONE. If you just want to create valid user who can be either a named user or an IP, consider using newFromNameOrIp() instead of calling this with RIGOR_NONE. |
Definition at line 77 of file UserFactory.php.
Referenced by MediaWiki\Pager\ContributionsPager\__construct().
| MediaWiki\User\UserFactory::newFromNameOrIp | ( | string | $name | ) |
Returns either an anonymous or a named User based on the supplied argument.
If IP is supplied, an anonymous user will be created, otherwise a valid named user. If you don't want to have the named user validated, use self::newFromName(). If you want to create a simple anonymous user without providing the IP, use self::newAnonymous()
| string | $name | IP address or username |
Definition at line 127 of file UserFactory.php.
| MediaWiki\User\UserFactory::newFromRow | ( | $row, | |
| $data = null ) |
| stdClass | $row | A row from the user table |
| array | null | $data | Further data to load into the object |
Definition at line 310 of file UserFactory.php.
| MediaWiki\User\UserFactory::newFromUserIdentity | ( | UserIdentity | $userIdentity | ) |
Factory method for creation from a given UserIdentity, replacing User::newFromIdentity.
Definition at line 169 of file UserFactory.php.
| MediaWiki\User\UserFactory::newTempPlaceholder | ( | ) |
Create a placeholder user for an anonymous user who will be upgraded to a temporary user.
This will throw an exception if temp user autocreation is disabled.
Definition at line 331 of file UserFactory.php.
| MediaWiki\User\UserFactory::newUnsavedTempUser | ( | ?string | $name | ) |
Create an unsaved temporary user with a previously acquired name or a placeholder name.
| ?string | $name | If null, a placeholder name is used |
Definition at line 344 of file UserFactory.php.
| const MediaWiki\User\UserFactory::CONSTRUCTOR_OPTIONS |
RIGOR_* constants are inherited from UserRigorOptions.
Definition at line 39 of file UserFactory.php.