MediaWiki  master
User Class Reference

The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time). More...

Inheritance diagram for User:
Collaboration diagram for User:

Public Member Functions

 __construct ()
 Lightweight constructor for an anonymous user. More...
 
__get ( $name)
 
 __set ( $name, $value)
 
 __sleep ()
 
 __toString ()
 
 addAutopromoteOnceGroups ( $event)
 Add the user to the group if he/she meets given criteria. More...
 
 addGroup ( $group, $expiry=null)
 Add the user to the given group. More...
 
 addToDatabase ()
 Add this existing user object to the database. More...
 
 addWatch (PageIdentity $title, $checkRights=self::CHECK_USER_RIGHTS, ?string $expiry=null)
 Watch an article. More...
 
 authorizeRead (string $action, PageIdentity $target, PermissionStatus $status=null)
 
 authorizeWrite (string $action, PageIdentity $target, PermissionStatus $status=null)
 
 blockedBy ()
 If user is blocked, return the name of the user who placed the block. More...
 
 blockedFor ()
 If user is blocked, return the specified reason for the block. More...
 
 canReceiveEmail ()
 Is this user allowed to receive e-mails within limits of current site configuration? More...
 
 canSendEmail ()
 Is this user allowed to send e-mails within limits of current site configuration? More...
 
 changeableGroups ()
 Returns an array of groups that this user can add and remove. More...
 
 changeAuthenticationData (array $data)
 Changes credentials of the user. More...
 
 checkAndSetTouched ()
 Bump user_touched if it didn't change since this object was loaded. More...
 
 checkPasswordValidity ( $password)
 Check if this is a valid password for this user. More...
 
 clearInstanceCache ( $reloadFrom=false)
 Clear various cached data stored in this object. More...
 
 clearSharedCache ( $mode='refresh')
 Clear user data from memcached. More...
 
 confirmEmail ()
 Mark the e-mail address confirmed. More...
 
 definitelyCan (string $action, PageIdentity $target, PermissionStatus $status=null)
 
 doLogout ()
 Clear the user's session, and reset the instance cache. More...
 
 equals (?UserIdentity $user)
 Checks if two user objects point to the same user. More...
 
 getActorId ( $dbwOrWikiId=self::LOCAL)
 Get the user's actor ID. More...
 
 getAutomaticGroups ( $recache=false)
 Get the list of implicit group memberships this user has. More...
 
 getBlock ( $freshness=self::READ_NORMAL, $disableIpBlockExemptChecking=false)
 Get the block affecting the user, or null if the user is not blocked. More...
 
 getBlockId ()
 If user is blocked, return the ID for the block. More...
 
 getBoolOption ( $oname)
 Get the user's current setting for a given option, as a boolean value. More...
 
 getDatePreference ()
 Get the user's preferred date format. More...
 
 getDBTouched ()
 Get the user_touched timestamp field (time of last DB updates) More...
 
 getEditCount ()
 Get the user's edit count. More...
 
 getEditToken ( $salt='', $request=null)
 Initialize (if necessary) and return a session token value which can be used in edit forms to show that the user's login credentials aren't being hijacked with a foreign form submission. More...
 
 getEditTokenObject ( $salt='', $request=null)
 Initialize (if necessary) and return a session token value which can be used in edit forms to show that the user's login credentials aren't being hijacked with a foreign form submission. More...
 
 getEffectiveGroups ( $recache=false)
 Get the list of implicit group memberships this user has. More...
 
 getEmail ()
 Get the user's e-mail address. More...
 
 getEmailAuthenticationTimestamp ()
 Get the timestamp of the user's e-mail authentication. More...
 
 getExperienceLevel ()
 Compute experienced level based on edit count and registration date. More...
 
 getFirstEditTimestamp ()
 Get the timestamp of the first edit. More...
 
 getFormerGroups ()
 Returns the groups the user has belonged to. More...
 
 getGlobalBlock ( $ip='')
 Check if user is blocked on all wikis. More...
 
 getGroupMemberships ()
 Get the list of explicit group memberships this user has, stored as UserGroupMembership objects. More...
 
 getGroups ()
 Get the list of explicit group memberships this user has. More...
 
 getId ( $wikiId=self::LOCAL)
 Get the user's ID. More...
 
 getInstanceForUpdate ()
 Get a new instance of this user that was loaded from the master via a locking read. More...
 
 getIntOption ( $oname, $defaultOverride=0)
 Get the user's current setting for a given option, as an integer value. More...
 
 getLatestEditTimestamp ()
 Get the timestamp of the latest edit. More...
 
 getMutableCacheKeys (WANObjectCache $cache)
 
 getName ()
 Get the user name, or the IP of an anonymous user. More...
 
 getOption ( $oname, $defaultOverride=null, $ignoreHidden=false)
 Get the user's current setting for a given option. More...
 
 getOptionKinds (IContextSource $context, $options=null)
 Return an associative array mapping preferences keys to the kind of a preference they're used for. More...
 
 getOptions ( $flags=0)
 Get all user's options. More...
 
 getRealName ()
 Get the user's real name. More...
 
 getRegistration ()
 Get the timestamp of account creation. More...
 
 getRequest ()
 Get the WebRequest object to use with this object. More...
 
 getRights ()
 Get the permissions this user has. More...
 
 getStubThreshold ()
 Get the user preferred stub threshold. More...
 
 getTalkPage ()
 Get this user's talk page title. More...
 
 getTitleKey ()
 Get the user's name escaped by underscores. More...
 
 getToken ( $forceCreation=true)
 Get the user's current token. More...
 
 getTokenFromOption ( $oname)
 Get a token stored in the preferences (like the watchlist one), resetting it if it's empty (and saving changes). More...
 
 getTouched ()
 Get the user touched timestamp. More...
 
 getUser ()
 
 getUserPage ()
 Get this user's personal page title. More...
 
 getWikiId ()
 Returns self::LOCAL to indicate the user is associated with the local wiki. More...
 
 idForName ( $flags=self::READ_NORMAL)
 If only this user's username is known, and it exists, return the user ID. More...
 
 incEditCount ()
 Schedule a deferred update to update the user's edit count. More...
 
 invalidateCache ()
 Immediately touch the user data cache for this account. More...
 
 invalidateEmail ()
 Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already confirmed. More...
 
 isAllowed (string $permission)
 Checks whether this authority has the given permission in general. More...
 
 isAllowedAll (... $permissions)
 Checks whether this authority has any of the given permissions in general. More...
 
 isAllowedAny (... $permissions)
 Checks whether this authority has any of the given permissions in general. More...
 
 isAllowedToCreateAccount ()
 Get whether the user is allowed to create an account. More...
 
 isAllowUsertalk ()
 Checks if usertalk is allowed. More...
 
 isAnon ()
 Get whether the user is anonymous. More...
 
 isBlocked ( $fromReplica=true)
 Check if user is blocked. More...
 
 isBlockedFrom ( $title, $fromReplica=false)
 Check if user is blocked from editing a particular article. More...
 
 isBlockedFromCreateAccount ()
 Get whether the user is explicitly blocked from account creation. More...
 
 isBlockedFromEmailuser ()
 Get whether the user is blocked from using Special:Emailuser. More...
 
 isBlockedFromUpload ()
 Get whether the user is blocked from using Special:Upload. More...
 
 isBlockedGlobally ( $ip='')
 Check if user is blocked on all wikis. More...
 
 isBot ()
 
 isEmailConfirmationPending ()
 Check whether there is an outstanding request for e-mail confirmation. More...
 
 isEmailConfirmed ()
 Is this user's e-mail address valid-looking and confirmed within limits of the current site configuration? More...
 
 isHidden ()
 Check if user account is hidden. More...
 
 isIPRange ()
 Is the user an IP range? More...
 
 isItemLoaded ( $item, $all='all')
 Return whether an item has been loaded. More...
 
 isLocked ()
 Check if user account is locked. More...
 
 isLoggedIn ()
 Get whether the user is registered. More...
 
 isNewbie ()
 Determine whether the user is a newbie. More...
 
 isPingLimitable ()
 Is this user subject to rate limiting? More...
 
 isRegistered ()
 Get whether the user is registered. More...
 
 isSafeToLoad ()
 Test if it's safe to load this User object. More...
 
 isSystemUser ()
 Get whether the user is a system user. More...
 
 isTempWatched (PageIdentity $title, $checkRights=self::CHECK_USER_RIGHTS)
 Check if the article is temporarily watched. More...
 
 isValidPassword ( $password)
 Is the input a valid password for this user? More...
 
 isWatched (PageIdentity $title, $checkRights=self::CHECK_USER_RIGHTS)
 Check the watched status of an article. More...
 
 load ( $flags=self::READ_NORMAL)
 Load the user table data for this object from the source given by mFrom. More...
 
 loadDefaults ( $name=false, $actorId=null)
 Set cached properties to default. More...
 
 loadFromDatabase ( $flags=self::READ_LATEST)
 Load user data from the database. More...
 
 loadFromId ( $flags=self::READ_NORMAL)
 Load user table data, given mId has already been set. More...
 
 logout ()
 Log this user out. More...
 
 matchEditToken ( $val, $salt='', $request=null, $maxage=null)
 Check given value against the token value stored in the session. More...
 
 matchEditTokenNoSuffix ( $val, $salt='', $request=null, $maxage=null)
 Check given value against the token value stored in the session, ignoring the suffix. More...
 
 pingLimiter ( $action='edit', $incrBy=1)
 Primitive rate limits: enforce maximum actions per time period to put a brake on flooding. More...
 
 probablyCan (string $action, PageIdentity $target, PermissionStatus $status=null)
 
 removeGroup ( $group)
 Remove the user from the given group. More...
 
 removeWatch (PageIdentity $title, $checkRights=self::CHECK_USER_RIGHTS)
 Stop watching an article. More...
 
 requiresHTTPS ()
 Determine based on the wiki configuration and the user's options, whether this user must be over HTTPS no matter what. More...
 
 resetOptions ( $resetKinds=[ 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused'], IContextSource $context=null)
 Reset certain (or all) options to the site defaults. More...
 
 resetTokenFromOption ( $oname)
 Reset a token stored in the preferences (like the watchlist one). More...
 
 saveSettings ()
 Save this user's settings into the database. More...
 
 sendConfirmationMail ( $type='created')
 Generate a new e-mail confirmation token and send a confirmation/invalidation mail to the user's given address. More...
 
 sendMail ( $subject, $body, $from=null, $replyto=null)
 Send an e-mail to this user's account. More...
 
 setActorId (int $actorId)
 Sets the actor id. More...
 
 setCookies ( $request=null, $secure=null, $rememberMe=false)
 Persist this user's session (e.g. More...
 
 setEmail (string $str)
 Set the user's e-mail address. More...
 
 setEmailAuthenticationTimestamp ( $timestamp)
 Set the e-mail authentication timestamp. More...
 
 setEmailWithConfirmation (string $str)
 Set the user's e-mail address and a confirmation mail if needed. More...
 
 setId ( $v)
 Set the user and reload all fields according to a given ID. More...
 
 setItemLoaded ( $item)
 Set that an item has been loaded. More...
 
 setName ( $str)
 Set the user name. More...
 
 setOption ( $oname, $val)
 Set the given option for a user. More...
 
 setRealName (string $str)
 Set the user's real name. More...
 
 setToken ( $token=false)
 Set the random token (used for persistent authentication) Called from loadDefaults() among other places. More...
 
 spreadAnyEditBlock ()
 If this user is logged-in and blocked, block any IP address they've successfully logged in from. More...
 
 touch ()
 Update the "touched" timestamp for the user. More...
 
 useFilePatrol ()
 Check whether to enable new files patrol features for this user. More...
 
 useNPPatrol ()
 Check whether to enable new pages patrol features for this user. More...
 
 useRCPatrol ()
 Check whether to enable recent changes patrol features for this user. More...
 
 validateCache ( $timestamp)
 Validate the cache for this account. More...
 
- Public Member Functions inherited from MediaWiki\Permissions\Authority
 getBlock (int $freshness=self::READ_NORMAL)
 Returns any user block affecting the Authority. More...
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId(). More...
 

Static Public Member Functions

static changeableByGroup ( $group)
 Returns an array of the groups that a particular group can add/remove. More...
 
static createNew ( $name, $params=[])
 Add a user to the database, return the user object. More...
 
static findUsersByGroup ( $groups, $limit=5000, $after=null)
 Return the users who are members of the given group(s). More...
 
static getAllGroups ()
 Return the set of defined explicit groups. More...
 
static getCanonicalName ( $name, $validate='valid')
 Given unvalidated user input, return a canonical username, or false if the username is invalid. More...
 
static getDefaultOption ( $opt)
 Get a given default option value. More...
 
static getDefaultOptions ()
 Combine the language default options with any site-specific options and add the default language variants. More...
 
static getGroupPermissions ( $groups)
 Get the permissions associated with a given list of groups. More...
 
static getGroupsWithPermission ( $role)
 Get all the groups who have a given permission. More...
 
static getImplicitGroups ()
 
static getQueryInfo ()
 Return the tables, fields, and join conditions to be selected to create a new user object. More...
 
static getRightDescription ( $right)
 Get the description of a given right. More...
 
static groupHasPermission ( $group, $role)
 Check, if the given group has the given permission. More...
 
static idFromName ( $name, $flags=self::READ_NORMAL)
 Get database id given a user name. More...
 
static isCreatableName ( $name)
 Usernames which fail to pass this function will be blocked from new account registrations, but may be used internally either by batch processes or by user accounts which have already been created. More...
 
static isIP ( $name)
 Does the string match an anonymous IP address? More...
 
static isUsableName ( $name)
 Usernames which fail to pass this function will be blocked from user login and new account registrations, but may be used internally by batch processes. More...
 
static isValidUserName ( $name)
 Is the input a valid username? More...
 
static listOptionKinds ()
 Return a list of the types of user options currently returned by User::getOptionKinds(). More...
 
static newFatalPermissionDeniedStatus ( $permission)
 Factory function for fatal permission-denied errors. More...
 
static purge ( $dbDomain, $userId)
 
static resetIdByNameCache ()
 Reset the cache used in idFromName(). More...
 
static whoIs ( $id)
 Get the username corresponding to a given user ID. More...
 
static whoIsReal ( $id)
 Get the real name of a user given their user ID. More...
 
newFrom*() static factory methods
static newFromName ( $name, $validate='valid')
 
static newFromId ( $id)
 Static factory method for creation from a given user ID. More...
 
static newFromActorId ( $id)
 Static factory method for creation from a given actor ID. More...
 
static newFromIdentity (UserIdentity $identity)
 Returns a User object corresponding to the given UserIdentity. More...
 
static newFromAnyId ( $userId, $userName, $actorId, $dbDomain=false)
 Static factory method for creation from an ID, name, and/or actor ID. More...
 
static newFromConfirmationCode ( $code, $flags=self::READ_NORMAL)
 Factory method to fetch whichever user has a given email confirmation code. More...
 
static newFromSession (WebRequest $request=null)
 Create a new user object using data from session. More...
 
static newFromRow ( $row, $data=null)
 Create a new user object from a user row. More...
 
static newSystemUser ( $name, $options=[])
 Static factory method for creation of a "system" user from username. More...
 

Public Attributes

int null $mActorId
 Switched from protected to public for use in UserFactory. More...
 
AbstractBlock null $mBlock
 
string int $mBlockedby
 
string $mEmail
 
string $mEmailAuthenticated
 
string $mFrom
 Initialization data source if mLoadedItems!==true. More...
 
bool $mHideName
 
int $mId
 Cache variables. More...
 
string $mName
 
string $mRealName
 
string $mTouched
 TS_MW timestamp from the DB. More...
 
const CHECK_USER_RIGHTS = true
 
const GETOPTIONS_EXCLUDE_DEFAULTS = UserOptionsLookup::EXCLUDE_DEFAULTS
 Exclude user options that are set to their default value. More...
 
const IGNORE_USER_RIGHTS = false
 
const INVALID_TOKEN = '*** INVALID ***'
 An invalid string value for the user_token field. More...
 
const MAINTENANCE_SCRIPT_USER = 'Maintenance script'
 Username used for various maintenance scripts. More...
 
const TOKEN_LENGTH = 32
 Number of characters required for the user_token field. More...
 

Protected Member Functions

 confirmationToken (&$expiration)
 Generate, store, and return a new e-mail confirmation code. More...
 
 confirmationTokenUrl ( $token)
 Return a URL the user can use to confirm their email address. More...
 
 getCacheKey (WANObjectCache $cache)
 
 getTokenUrl ( $page, $token)
 Internal function to format the e-mail validation/invalidation URLs. More...
 
 invalidationTokenUrl ( $token)
 Return a URL the user can use to invalidate their email address. More...
 
 loadFromCache ()
 Load user data from shared cache, given mId has already been set. More...
 
 loadFromRow ( $row, $data=null)
 Initialize this object from a row from the user table. More...
 
 loadFromUserObject ( $user)
 Load the data for this user object from another user object. More...
 
 makeUpdateConditions (IDatabase $db, array $conditions)
 Builds update conditions. More...
 
 spreadBlock ()
 If this (non-anonymous) user is blocked, block the IP address they've successfully logged in from. More...
 

Protected Attributes

bool $mAllowUsertalk
 
string $mBlockreason
 TODO: This should be removed when User::BlockedFor and AbstractBlock::getReason are hard deprecated. More...
 
string $mDatePreference
 Lazy-initialized variables, invalidated with clearInstanceCache. More...
 
string $mEmailToken
 
string $mEmailTokenExpires
 
AbstractBlock $mGlobalBlock
 
string $mHash
 
array bool $mLoadedItems = []
 Array with already loaded items or true if all items have been loaded. More...
 
bool $mLocked
 
string $mQuickTouched
 TS_MW timestamp from cache. More...
 
string $mRegistration
 
string $mToken
 
int $queryFlagsUsed = self::READ_NORMAL
 User::READ_* constant bitfield used to load data. More...
 

Static Protected Attributes

static string[] $mCacheVars
 List of member variables which are saved to the shared cache (memcached). More...
 

Private Member Functions

 getBlockedStatus ( $fromReplica=true, $disableIpBlockExemptChecking=false)
 Get blocking information. More...
 
 getThisAsAuthority ()
 Returns the Authority of this User if it's the main request context user. More...
 
 isGlobalSessionUser ()
 Check whether this is the global session user. More...
 
 loadFromSession ()
 Load user data from the session. More...
 
 newTouchedTimestamp ()
 Generate a current or new-future timestamp to be stored in the user_touched field when we update things. More...
 

Static Private Member Functions

static insertNewUser (callable $insertActor, $name, $params=[])
 See ::createNew. More...
 

Private Attributes

AbstractBlock bool $mBlockedFromCreateAccount = false
 
WebRequest $mRequest
 
Authority null $mThisAsAuthority
 lazy-initialized Authority of this user More...
 
const VERSION = 17
 Version number to tag cached versions of serialized User objects. More...
 

Detailed Description

The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).

Client classes use the getXXX() functions to access these fields. These functions do all the work of determining whether the user is logged in, whether the requested option can be satisfied from cookies or whether a database query is needed. Most of the settings needed for rendering normal pages are set in the cookie to minimize use of the database.

Note
User implements Authority to ease transition. Always prefer using existing Authority or obtaining a proper Authority implementation.

@newable in 1.35 only, the constructor is

Access: internal
since 1.36

Definition at line 68 of file User.php.

Constructor & Destructor Documentation

◆ __construct()

User::__construct ( )

Lightweight constructor for an anonymous user.

Stability: stable
to call since 1.35
Access: internal
since 1.36, use the UserFactory service instead
See also
MediaWiki\User\UserFactory
newFromName()
newFromId()
newFromActorId()
newFromConfirmationCode()
newFromSession()
newFromRow()

Definition at line 269 of file User.php.

References clearInstanceCache().

Member Function Documentation

◆ __get()

& User::__get (   $name)

Definition at line 290 of file User.php.

References wfDeprecated(), and wfLogWarning().

◆ __set()

User::__set (   $name,
  $value 
)

Definition at line 313 of file User.php.

References setOption(), wfDeprecated(), and wfLogWarning().

◆ __sleep()

User::__sleep ( )

Definition at line 334 of file User.php.

◆ __toString()

User::__toString ( )
Returns
string

Definition at line 286 of file User.php.

References getName().

◆ addAutopromoteOnceGroups()

User::addAutopromoteOnceGroups (   $event)

Add the user to the group if he/she meets given criteria.

Contrary to autopromotion by \ref $wgAutopromote, the group will be possible to remove manually via Special:UserRights. In such case it will not be re-added automatically. The user will also not lose the group if they no longer meet the criteria.

Parameters
string$eventKey in $wgAutopromoteOnce (each one has groups/criteria)
Returns
string[] Array of groups the user has been promoted to.
Deprecated:
since 1.35 Use UserGroupManager::addUserToAutopromoteOnceGroups. Hard deprecated since 1.37.
See also
$wgAutopromoteOnce

Definition at line 1468 of file User.php.

References wfDeprecated().

◆ addGroup()

User::addGroup (   $group,
  $expiry = null 
)

Add the user to the given group.

This takes immediate effect. If the user is already in the group, the expiry time will be updated to the new expiry time. (If $expiry is omitted or null, the membership will be altered to never expire.)

Deprecated:
since 1.35 Use UserGroupManager::addUserToGroup instead
Parameters
string$groupName of the group to add
string | null$expiryOptional expiry timestamp in any format acceptable to wfTimestamp(), or null if the group assignment should not expire
Returns
bool

Definition at line 2929 of file User.php.

◆ addToDatabase()

User::addToDatabase ( )

Add this existing user object to the database.

If the user already exists, a fatal status object is returned, and the user object is initialised with the data from the database.

Previously, this function generated a DB error due to a key conflict if the user already existed. Many extension callers use this function in code along the lines of:

$user = User::newFromName( $name ); if ( !$user->isRegistered() ) { $user->addToDatabase(); } // do something with $user...

However, this was vulnerable to a race condition (T18020). By initialising the user object if the user exists, we aim to support this calling sequence as far as possible.

Note that if the user exists, this function will acquire a write lock, so it is still advisable to make the call conditional on isRegistered(), and to commit the transaction after calling.

Exceptions
MWException
Returns
Status

Definition at line 3487 of file User.php.

References Wikimedia\Rdbms\IDatabase\affectedRows(), clearInstanceCache(), DB_PRIMARY, Wikimedia\Rdbms\IDatabase\insert(), Wikimedia\Rdbms\IDatabase\insertId(), load(), loadFromDatabase(), StatusValue\newFatal(), StatusValue\newGood(), PasswordFactory\newInvalidPassword(), newTouchedTimestamp(), Wikimedia\Rdbms\IDatabase\selectField(), setToken(), Wikimedia\Rdbms\IDatabase\timestamp(), Wikimedia\Rdbms\IDatabase\timestampOrNull(), and wfGetDB().

Referenced by MediaWiki\Auth\AuthManager\autoCreateUser().

◆ addWatch()

User::addWatch ( PageIdentity  $title,
  $checkRights = self::CHECK_USER_RIGHTS,
?string  $expiry = null 
)

Watch an article.

Since
1.22 $checkRights parameter added
Parameters
PageIdentity$titlethe article to look at
bool$checkRightsWhether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass User::CHECK_USER_RIGHTS or User::IGNORE_USER_RIGHTS.
string | null$expiryOptional expiry timestamp in any format acceptable to wfTimestamp(), null will not create expiries, or leave them unchanged should they already exist.
Deprecated:
since 1.37, use WatchlistManager::addWatch() or WatchlistManager::addWatchIgnoringRights()

Definition at line 3124 of file User.php.

References $title, $watchlistManager, and wfDeprecated().

◆ authorizeRead()

User::authorizeRead ( string  $action,
PageIdentity  $target,
PermissionStatus  $status = null 
)
Since
1.36
Parameters
string$action
PageIdentity$target
PermissionStatus | null$status
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 4307 of file User.php.

References getThisAsAuthority().

◆ authorizeWrite()

User::authorizeWrite ( string  $action,
PageIdentity  $target,
PermissionStatus  $status = null 
)
Since
1.36
Parameters
string$action
PageIdentity$target
PermissionStatus | null$status
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 4319 of file User.php.

References getThisAsAuthority().

◆ blockedBy()

User::blockedBy ( )

If user is blocked, return the name of the user who placed the block.

Returns
string Name of blocker

Definition at line 1972 of file User.php.

References $mBlockedby, and getBlockedStatus().

◆ blockedFor()

User::blockedFor ( )

If user is blocked, return the specified reason for the block.

Deprecated:
since 1.35 Use AbstractBlock::getReasonComment instead
Returns
string Blocking reason

Definition at line 1983 of file User.php.

References $mBlockreason, and getBlockedStatus().

◆ canReceiveEmail()

User::canReceiveEmail ( )

Is this user allowed to receive e-mails within limits of current site configuration?

Returns
bool

Definition at line 3949 of file User.php.

References getOption(), and isEmailConfirmed().

◆ canSendEmail()

User::canSendEmail ( )

Is this user allowed to send e-mails within limits of current site configuration?

Returns
bool

Definition at line 3934 of file User.php.

References $wgEnableEmail, $wgEnableUserEmail, isAllowed(), and isEmailConfirmed().

Referenced by ApiQueryInfo\getEmailToken().

◆ changeableByGroup()

static User::changeableByGroup (   $group)
static

Returns an array of the groups that a particular group can add/remove.

Parameters
string$groupThe group to check for whether it can add/remove
Returns
array [ 'add' => [ addablegroups ], 'remove' => [ removablegroups ], 'add-self' => [ addablegroups to self ], 'remove-self' => [ removable groups from self ] ]
Deprecated:
since 1.37 Use UserGroupManager::getGroupsChangeableByGroup instead.

Definition at line 4122 of file User.php.

References wfDeprecated().

◆ changeableGroups()

User::changeableGroups ( )

Returns an array of groups that this user can add and remove.

Returns
array [ 'add' => [ addablegroups ], 'remove' => [ removablegroups ], 'add-self' => [ addablegroups to self ], 'remove-self' => [ removable groups from self ] ]
Deprecated:
since 1.37 Use UserGroupManager::getGroupsChangeableBy instead.

Definition at line 4137 of file User.php.

References wfDeprecated().

◆ changeAuthenticationData()

User::changeAuthenticationData ( array  $data)

Changes credentials of the user.

This is a convenience wrapper around AuthManager::changeAuthenticationData. Note that this can return a status that isOK() but not isGood() on certain types of failures, e.g. when no provider handled the change.

Parameters
array$dataA set of authentication data in fieldname => value format. This is the same data you would pass the changeauthenticationdata API - 'username', 'password' etc.
Returns
Status
Since
1.27

Definition at line 2342 of file User.php.

References StatusValue\newGood().

◆ checkAndSetTouched()

User::checkAndSetTouched ( )

Bump user_touched if it didn't change since this object was loaded.

On success, the mTouched field is updated. The user serialization cache is always cleared.

Access: internal
Returns
bool Whether user_touched was actually updated
Since
1.26

Definition at line 1503 of file User.php.

References $success, clearSharedCache(), DB_PRIMARY, load(), newTouchedTimestamp(), and wfGetDB().

◆ checkPasswordValidity()

User::checkPasswordValidity (   $password)

Check if this is a valid password for this user.

Returns a Status object with a set of messages describing problems with the password. If the return status is fatal, the action should be refused and the password should not be checked at all (this is mainly meant for DoS mitigation). If the return value is OK but not good, the password can be checked, but the user should not be able to set their password to this. The value of the returned Status object will be an array which can have the following fields:

  • forceChange (bool): if set to true, the user should not be allowed to log with this password unless they change it during the login process (see ResetPasswordSecondaryAuthenticationProvider).
  • suggestChangeOnLogin (bool): if set to true, the user should be prompted for a password change on login.
Parameters
string$passwordDesired password
Returns
Status
Since
1.23

Definition at line 1122 of file User.php.

References $wgPasswordPolicy, and StatusValue\newGood().

Referenced by isValidPassword().

◆ clearInstanceCache()

User::clearInstanceCache (   $reloadFrom = false)

Clear various cached data stored in this object.

The cache of the user table data (i.e. self::$mCacheVars) is not cleared unless $reloadFrom is given.

Parameters
bool | string$reloadFromReload user and user_groups table data from a given source. May be "name", "id", "actor", "defaults", "session", or false for no reload.

Definition at line 1541 of file User.php.

References $wgFullyInitialised.

Referenced by __construct(), addToDatabase(), doLogout(), UserrightsPage\execute(), and setId().

◆ clearSharedCache()

User::clearSharedCache (   $mode = 'refresh')

Clear user data from memcached.

Use after applying updates to the database; caller's responsibility to update user_touched if appropriate.

Called implicitly from invalidateCache() and saveSettings().

Parameters
string$modeUse 'refresh' to clear now or 'changed' to clear before DB commit

Definition at line 2232 of file User.php.

References $cache, DB_PRIMARY, getCacheKey(), and getId().

Referenced by checkAndSetTouched(), invalidateCache(), and saveSettings().

◆ confirmationToken()

User::confirmationToken ( $expiration)
protected

Generate, store, and return a new e-mail confirmation code.

A hash (unsalted, since it's used as a key) is stored.

Note
Call saveSettings() after calling this function to commit this change to the database.
Parameters
string&$expirationAccepts the expiration time
Returns
string New token

Definition at line 3833 of file User.php.

References $wgUserEmailConfirmationTokenExpiry, MWCryptRand\generateHex(), load(), and wfTimestamp().

Referenced by sendConfirmationMail().

◆ confirmationTokenUrl()

User::confirmationTokenUrl (   $token)
protected

Return a URL the user can use to confirm their email address.

Parameters
string$tokenAccepts the email confirmation token
Returns
string New token URL

Definition at line 3851 of file User.php.

References getTokenUrl().

Referenced by sendConfirmationMail().

◆ confirmEmail()

User::confirmEmail ( )

Mark the e-mail address confirmed.

Note
Call saveSettings() after calling this function to commit the change.
Returns
bool

Definition at line 3891 of file User.php.

References isEmailConfirmed(), setEmailAuthenticationTimestamp(), and wfTimestampNow().

◆ createNew()

static User::createNew (   $name,
  $params = [] 
)
static

Add a user to the database, return the user object.

Parameters
string$nameUsername to add
array$paramsArray of Strings Non-default parameters to save to the database as user_* fields:
  • email: The user's email address.
  • email_authenticated: The email authentication timestamp.
  • real_name: The user's real name.
  • options: An associative array of non-default options.
  • token: Random authentication token. Do not set.
  • registration: Registration timestamp. Do not set.
Returns
User|null User object, or null if the username already exists.

Definition at line 3394 of file User.php.

References insertNewUser().

◆ definitelyCan()

User::definitelyCan ( string  $action,
PageIdentity  $target,
PermissionStatus  $status = null 
)
Since
1.36
Parameters
string$action
PageIdentity$target
PermissionStatus | null$status
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 4296 of file User.php.

References getThisAsAuthority().

◆ doLogout()

User::doLogout ( )

Clear the user's session, and reset the instance cache.

See also
logout()

Definition at line 3253 of file User.php.

References clearInstanceCache(), and getRequest().

Referenced by logout().

◆ equals()

User::equals ( ?UserIdentity  $user)

Checks if two user objects point to the same user.

Since
1.25 ; takes a UserIdentity instead of a User since 1.32
Parameters
UserIdentity | null$user
Returns
bool

Implements MediaWiki\User\UserIdentity.

Definition at line 4252 of file User.php.

References getName(), and MediaWiki\User\UserIdentity\getName().

◆ findUsersByGroup()

static User::findUsersByGroup (   $groups,
  $limit = 5000,
  $after = null 
)
static

Return the users who are members of the given group(s).

In case of multiple groups, users who are members of at least one of them are returned.

Parameters
string | array$groupsA single group name or an array of group names
int$limitMax number of users to return. The actual limit will never exceed 5000 records; larger values are ignored.
int | null$afterID the user to start after
Returns
UserArrayFromResult|ArrayIterator

Definition at line 1042 of file User.php.

References $dbr, DB_REPLICA, UserArray\newFromIDs(), and wfGetDB().

Referenced by EmptyUserGroup\execute().

◆ getActorId()

User::getActorId (   $dbwOrWikiId = self::LOCAL)

Get the user's actor ID.

Since
1.31
Note
This method was removed from the UserIdentity interface in 1.36, but remains supported in the User class for now. New code should use ActorNormalization::findActorId() or ActorNormalization::acquireActorId() instead.
Parameters
IDatabase | string | false$dbwOrWikiIdDeprecated since 1.36. If a database connection is passed, a new actor ID is assigned if needed. ActorNormalization::acquireActorId() should be used for that purpose instead.
Returns
int The actor's ID, or 0 if no actor ID exists and $dbw was null
Exceptions
PreconditionExceptionif $dbwOrWikiId is a string and does not match the local wiki

Definition at line 2157 of file User.php.

References $mActorId, MediaWiki\DAO\WikiAwareEntity\assertWiki(), isItemLoaded(), load(), and wfDeprecatedMsg().

◆ getAllGroups()

static User::getAllGroups ( )
static

Return the set of defined explicit groups.

The implicit groups (by default *, 'user' and 'autoconfirmed') are not included, as they are defined automatically, not in the database.

Deprecated:
since 1.35, use UserGroupManager::listAllGroups instead
Returns
string[] internal group names

Definition at line 4096 of file User.php.

◆ getAutomaticGroups()

User::getAutomaticGroups (   $recache = false)

Get the list of implicit group memberships this user has.

This includes 'user' if logged in, '*' for all accounts, and autopromoted groups

Deprecated:
since 1.35 Use UserGroupManager::getUserImplicitGroups instead. Hard deprecated since 1.37.
Parameters
bool$recacheWhether to avoid the cache
Returns
string[] internal group names

Definition at line 2880 of file User.php.

References wfDeprecated().

◆ getBlock()

User::getBlock (   $freshness = self::READ_NORMAL,
  $disableIpBlockExemptChecking = false 
)

Get the block affecting the user, or null if the user is not blocked.

Parameters
int | bool$freshnessOne of the Authority::READ_XXX constants. For backwards compatibility, a boolean is also accepted, with true meaning READ_NORMAL and false meaning READ_LATEST.
bool$disableIpBlockExemptCheckingThis is used internally to prevent a infinite recursion with autopromote. See T270145.
Returns
?AbstractBlock

Definition at line 1936 of file User.php.

References getBlockedStatus().

Referenced by Action\checkCanExecute(), MediaWiki\User\UserGroupManager\checkCondition(), FormSpecialPage\checkExecutePermissions(), MediaWiki\Permissions\PermissionManager\checkUserBlock(), isBlocked(), PasswordReset\isBlocked(), MediaWiki\Permissions\PermissionManager\isBlockedFrom(), spreadAnyEditBlock(), and MediaWiki\Block\BlockManager\trackBlockWithCookie().

◆ getBlockedStatus()

User::getBlockedStatus (   $fromReplica = true,
  $disableIpBlockExemptChecking = false 
)
private

Get blocking information.

TODO: Move this into the BlockManager, along with block-related properties.

Parameters
bool$fromReplicaWhether to check the replica DB first. To improve performance, non-critical checks are done against replica DBs. Check when actually saving should be done against master.
bool$disableIpBlockExemptCheckingThis is used internally to prevent a infinite recursion with autopromote. See T270145.

Definition at line 1603 of file User.php.

References getName(), getRequest(), isGlobalSessionUser(), load(), and wfDebug().

Referenced by blockedBy(), blockedFor(), getBlock(), getBlockId(), isBlockedFromCreateAccount(), isBlockedFromEmailuser(), isBlockedFromUpload(), and isHidden().

◆ getBlockId()

User::getBlockId ( )

If user is blocked, return the ID for the block.

Returns
int|false

Definition at line 1992 of file User.php.

References getBlockedStatus().

◆ getBoolOption()

User::getBoolOption (   $oname)

Get the user's current setting for a given option, as a boolean value.

Parameters
string$onameThe option to check
Returns
bool User's current value for the option
See also
getOption()
Deprecated:
since 1.35 Use UserOptionsLookup::getBoolOption instead

Definition at line 2585 of file User.php.

Referenced by requiresHTTPS().

◆ getCacheKey()

User::getCacheKey ( WANObjectCache  $cache)
protected
Since
1.27
Parameters
WANObjectCache$cache
Returns
string

Definition at line 503 of file User.php.

References $cache.

Referenced by clearSharedCache(), getMutableCacheKeys(), and loadFromCache().

◆ getCanonicalName()

static User::getCanonicalName (   $name,
  $validate = 'valid' 
)
static

Given unvalidated user input, return a canonical username, or false if the username is invalid.

Deprecated:
since 1.35, use the UserNameUtils service. Hard deprecated since 1.37
Parameters
string$nameUser input
string | bool$validateType of validation to use:
  • false No validation
  • 'valid' Valid for batch processes
  • 'usable' Valid for batch processes and login
  • 'creatable' Valid for batch processes, login and account creation
Exceptions
InvalidArgumentException
Returns
bool|string

Definition at line 1168 of file User.php.

References wfDeprecated().

◆ getDatePreference()

User::getDatePreference ( )

Get the user's preferred date format.

Returns
string User's preferred date format

Definition at line 2761 of file User.php.

References $mDatePreference, $wgLang, and getOption().

◆ getDBTouched()

User::getDBTouched ( )

Get the user_touched timestamp field (time of last DB updates)

Returns
string TS_MW Timestamp
Since
1.26

Definition at line 2324 of file User.php.

References $mTouched, and load().

◆ getDefaultOption()

static User::getDefaultOption (   $opt)
static

Get a given default option value.

Deprecated:
since 1.35 Use UserOptionsLookup::getDefaultOption instead.
Parameters
string$optName of option to retrieve
Returns
string|null Default option value

Definition at line 1585 of file User.php.

References wfDeprecated().

◆ getDefaultOptions()

static User::getDefaultOptions ( )
static

Combine the language default options with any site-specific options and add the default language variants.

Deprecated:
since 1.35 Use UserOptionsLookup::getDefaultOptions instead.
Returns
array Array of options; typically strings, possibly booleans

Definition at line 1571 of file User.php.

References wfDeprecated().

◆ getEditCount()

User::getEditCount ( )

Get the user's edit count.

Returns
int|null Null for anonymous users

Definition at line 2910 of file User.php.

Referenced by getExperienceLevel(), and MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().

◆ getEditToken()

User::getEditToken (   $salt = '',
  $request = null 
)

Initialize (if necessary) and return a session token value which can be used in edit forms to show that the user's login credentials aren't being hijacked with a foreign form submission.

The $salt for 'edit' and 'csrf' tokens is the default (empty string).

Since
1.19
Deprecated:
since 1.37. Use CsrfTokenSet::getToken instead
Parameters
string | string[]$saltOptional function-specific data for hashing
WebRequest | null$requestWebRequest object to use, or null to use the global request
Returns
string The new edit token

Definition at line 3707 of file User.php.

References getEditTokenObject().

◆ getEditTokenObject()

User::getEditTokenObject (   $salt = '',
  $request = null 
)

Initialize (if necessary) and return a session token value which can be used in edit forms to show that the user's login credentials aren't being hijacked with a foreign form submission.

Since
1.27
Deprecated:
since 1.37. Use CsrfTokenSet::getToken instead
Parameters
string | string[]$saltOptional function-specific data for hashing
WebRequest | null$requestWebRequest object to use, or null to use the global request
Returns
MediaWiki\Session\Token The new edit token

Definition at line 3682 of file User.php.

References getRequest(), and isAnon().

Referenced by getEditToken(), ApiQueryTokens\getToken(), and matchEditToken().

◆ getEffectiveGroups()

User::getEffectiveGroups (   $recache = false)

Get the list of implicit group memberships this user has.

This includes all explicit groups, plus 'user' if logged in, '*' for all accounts, and autopromoted groups

Deprecated:
since 1.35 Use UserGroupManager::getUserEffectiveGroups instead. Hard deprecated since 1.37.
Parameters
bool$recacheWhether to avoid the cache
Returns
string[] internal group names

Definition at line 2862 of file User.php.

References wfDeprecated().

◆ getEmail()

◆ getEmailAuthenticationTimestamp()

User::getEmailAuthenticationTimestamp ( )

Get the timestamp of the user's e-mail authentication.

Returns
string TS_MW timestamp

Definition at line 2441 of file User.php.

References $mEmailAuthenticated, and load().

Referenced by MediaWiki\User\UserGroupManager\checkCondition(), isEmailConfirmed(), and MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().

◆ getExperienceLevel()

User::getExperienceLevel ( )

Compute experienced level based on edit count and registration date.

Returns
string|false 'newcomer', 'learner', or 'experienced', false for anonymous users

Definition at line 3162 of file User.php.

References $wgExperiencedUserEdits, $wgExperiencedUserMemberSince, $wgLearnerEdits, $wgLearnerMemberSince, getEditCount(), getRegistration(), isAnon(), and wfTimestamp().

◆ getFirstEditTimestamp()

User::getFirstEditTimestamp ( )

Get the timestamp of the first edit.

Deprecated:
since 1.36, use a UserEditTracker instead
Returns
string|bool Timestamp of first edit, or false for non-existent/anonymous user accounts.

Definition at line 4020 of file User.php.

References wfDeprecated().

◆ getFormerGroups()

User::getFormerGroups ( )

Returns the groups the user has belonged to.

The user may still belong to the returned groups. Compare with getGroups().

The function will not return groups the user had belonged to before MW 1.17

Deprecated:
since 1.35 Use UserGroupManager::getUserFormerGroups instead. Hard deprecated since 1.37.
Returns
array Names of the groups the user has belonged to.

Definition at line 2899 of file User.php.

References wfDeprecated().

◆ getGlobalBlock()

User::getGlobalBlock (   $ip = '')

Check if user is blocked on all wikis.

Do not use for actual edit permission checks! This is intended for quick UI checks.

Parameters
string$ipIP address, uses current client if none given
Returns
AbstractBlock|null Block object if blocked, null otherwise
Exceptions
FatalError
MWException

Definition at line 2019 of file User.php.

References getName(), and getRequest().

Referenced by PasswordReset\isBlocked(), and isBlockedGlobally().

◆ getGroupMemberships()

User::getGroupMemberships ( )

Get the list of explicit group memberships this user has, stored as UserGroupMembership objects.

Implicit groups are not included.

Deprecated:
since 1.35 Use UserGroupManager::getUserGroupMemberships instead
Returns
UserGroupMembership[] Associative array of (group name => UserGroupMembership object)
Since
1.29

Definition at line 2845 of file User.php.

◆ getGroupPermissions()

static User::getGroupPermissions (   $groups)
static

Get the permissions associated with a given list of groups.

Deprecated:
since 1.34, use GroupPermissionsLookup::getGroupPermissions() instead in 1.36+, or PermissionManager::getGroupPermisions() in 1.34 and 1.35
Parameters
string[]$groupsinternal group names
Returns
string[] permission key names for given groups combined

Definition at line 4052 of file User.php.

◆ getGroups()

User::getGroups ( )

Get the list of explicit group memberships this user has.

The implicit * and user groups are not included.

Deprecated:
since 1.35 Use UserGroupManager::getUserGroups instead.
Returns
string[] Array of internal group names (sorted since 1.33)

Definition at line 2830 of file User.php.

◆ getGroupsWithPermission()

static User::getGroupsWithPermission (   $role)
static

Get all the groups who have a given permission.

Deprecated:
since 1.34, use GroupPermissionsLookup::getGroupsWithPermission() instead in 1.36+, or PermissionManager::getGroupsWithPermission() in 1.34 and 1.35
Parameters
string$roleRole to check
Returns
string[] internal group names with the given permission

Definition at line 4065 of file User.php.

Referenced by newFatalPermissionDeniedStatus().

◆ getId()

◆ getImplicitGroups()

static User::getImplicitGroups ( )
static
Deprecated:
since 1.35, use UserGroupManager::listAllImplicitGroups() instead
Returns
string[] internal group names

Definition at line 4106 of file User.php.

◆ getInstanceForUpdate()

User::getInstanceForUpdate ( )

Get a new instance of this user that was loaded from the master via a locking read.

Use this instead of the main context User when updating that user. This avoids races where that user was loaded from a replica DB or even the master but without proper locks.

Returns
User|null Returns null if the user was not found in the DB
Since
1.27

Definition at line 4232 of file User.php.

References getId(), and newFromId().

Referenced by SpecialChangeEmail\attemptChange().

◆ getIntOption()

User::getIntOption (   $oname,
  $defaultOverride = 0 
)

Get the user's current setting for a given option, as an integer value.

Parameters
string$onameThe option to check
int$defaultOverrideA default value returned if the option does not exist
Returns
int User's current value for the option
See also
getOption()
Deprecated:
since 1.35 Use UserOptionsLookup::getIntOption instead

Definition at line 2600 of file User.php.

Referenced by WebRequest\getLimitOffsetForUser(), and getStubThreshold().

◆ getLatestEditTimestamp()

User::getLatestEditTimestamp ( )

Get the timestamp of the latest edit.

Deprecated:
since 1.36, use a UserEditTracker instead
Since
1.33
Returns
string|bool Timestamp of first edit, or false for non-existent/anonymous user accounts.

Definition at line 4036 of file User.php.

References wfDeprecated().

◆ getMutableCacheKeys()

User::getMutableCacheKeys ( WANObjectCache  $cache)
Parameters
WANObjectCache$cache
Returns
string[]
Since
1.28

Definition at line 514 of file User.php.

References getCacheKey(), and getId().

◆ getName()

◆ getOption()

User::getOption (   $oname,
  $defaultOverride = null,
  $ignoreHidden = false 
)

Get the user's current setting for a given option.

Parameters
string$onameThe option to check
mixed | null$defaultOverrideA default value returned if the option does not exist. Default values set via $wgDefaultUserOptions / UserGetDefaultOptions take precedence.
bool$ignoreHiddenWhether to ignore the effects of $wgHiddenPrefs
Returns
mixed|null User's current value for the option
See also
getBoolOption()
getIntOption()
Deprecated:
since 1.35 Use UserOptionsLookup::getOption instead

Reimplemented in PPFuzzUser.

Definition at line 2551 of file User.php.

Referenced by canReceiveEmail(), getDatePreference(), RequestContext\getLanguage(), getTokenFromOption(), LanguageConverter\getUserVariant(), and MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\sendNewAccountEmail().

◆ getOptionKinds()

User::getOptionKinds ( IContextSource  $context,
  $options = null 
)

Return an associative array mapping preferences keys to the kind of a preference they're used for.

Different kinds are handled differently when setting or reading preferences.

See UserOptionsManager::listOptionKinds for the list of valid option types that can be provided.

See also
UserOptionsManager::listOptionKinds
Parameters
IContextSource$context
array | null$optionsAssoc. array with options keys to check as keys. Defaults to $this->mOptions.
Returns
string[] The key => kind mapping data
Deprecated:
since 1.35, hard deprecated since 1.37 Use UserOptionsManager::getOptionKinds instead

Definition at line 2720 of file User.php.

References wfDeprecated().

◆ getOptions()

User::getOptions (   $flags = 0)

Get all user's options.

Parameters
int$flagsBitwise combination of: User::GETOPTIONS_EXCLUDE_DEFAULTS Exclude user options that are set to the default value. (Since 1.25)
Returns
array
Deprecated:
since 1.35 Use UserOptionsLookup::getOptions instead. Hard deprecated since 1.37.

Definition at line 2570 of file User.php.

References wfDeprecated().

◆ getQueryInfo()

static User::getQueryInfo ( )
static

Return the tables, fields, and join conditions to be selected to create a new user object.

Since
1.31
Returns
array With three keys:
  • tables: (string[]) to include in the $table to IDatabase->select()
  • fields: (string[]) to include in the $vars to IDatabase->select()
  • joins: (array) to include in the $join_conds to IDatabase->select()

Definition at line 4174 of file User.php.

Referenced by ApiQueryUsers\execute(), PasswordReset\getUsersByEmail(), loadFromDatabase(), UserArray\newFromIDs(), UserArray\newFromNames(), and newSystemUser().

◆ getRealName()

User::getRealName ( )

Get the user's real name.

Returns
string User's real name

Implements MediaWiki\Mail\UserEmailContact.

Definition at line 2522 of file User.php.

References $mRealName, isItemLoaded(), and load().

Referenced by CreditsAction\link(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), and CreditsAction\userLink().

◆ getRegistration()

User::getRegistration ( )

Get the timestamp of account creation.

Returns
string|bool|null Timestamp of account creation, false for non-existent/anonymous user accounts, or null if existing account but information is not in database.

Definition at line 4004 of file User.php.

References $mRegistration, isAnon(), and load().

Referenced by MediaWiki\User\UserGroupManager\checkCondition(), getExperienceLevel(), and MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().

◆ getRequest()

◆ getRightDescription()

static User::getRightDescription (   $right)
static

Get the description of a given right.

Since
1.29
Parameters
string$rightRight to query
Returns
string Localized description of the right

Definition at line 4159 of file User.php.

References wfMessage().

Referenced by SpecialListGrants\execute(), SpecialListGroupRights\formatPermissions(), SpecialListGroupRights\outputNamespaceProtectionInfo(), and CreateBotPassword\showGrants().

◆ getRights()

User::getRights ( )

Get the permissions this user has.

Returns
string[] permission names
Deprecated:
since 1.34, hard deprecated since 1.37 Use MediaWikiServices::getInstance()->getPermissionManager() ->getUserPermissions(..) instead

Definition at line 2817 of file User.php.

References wfDeprecated().

◆ getStubThreshold()

User::getStubThreshold ( )

Get the user preferred stub threshold.

Returns
int

Definition at line 2797 of file User.php.

References $wgMaxArticleSize, and getIntOption().

Referenced by MediaWiki\Linker\LinkRendererFactory\createForUser().

◆ getTalkPage()

User::getTalkPage ( )

Get this user's talk page title.

Returns
Title

Definition at line 3656 of file User.php.

References $title, and getUserPage().

Referenced by MediaWiki\Permissions\PermissionManager\isBlockedFrom().

◆ getThisAsAuthority()

User::getThisAsAuthority ( )
private

Returns the Authority of this User if it's the main request context user.

This is intended to exist only for the period of transition to Authority.

Returns
Authority

Definition at line 4328 of file User.php.

References $mThisAsAuthority.

Referenced by authorizeRead(), authorizeWrite(), definitelyCan(), isAllowed(), isAllowedAll(), isAllowedAny(), and probablyCan().

◆ getTitleKey()

User::getTitleKey ( )

Get the user's name escaped by underscores.

Returns
string Username escaped by underscores.

Definition at line 2203 of file User.php.

References getName().

Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().

◆ getToken()

User::getToken (   $forceCreation = true)

Get the user's current token.

Parameters
bool$forceCreationForce the generation of a new token if the user doesn't have one (default=true for backwards compatibility).
Returns
string|null Token

Definition at line 2369 of file User.php.

References $mToken, $wgAuthenticationTokenVersion, MWCryptRand\generateHex(), MWCryptHash\hmac(), load(), and setToken().

Referenced by getTokenFromOption(), and loadFromSession().

◆ getTokenFromOption()

User::getTokenFromOption (   $oname)

Get a token stored in the preferences (like the watchlist one), resetting it if it's empty (and saving changes).

Parameters
string$onameThe option name to retrieve the token from
Returns
string|bool User's current value for the option, or false if this option is disabled.
See also
resetTokenFromOption()
getOption()
Deprecated:
since 1.26 Applications should use the OAuth extension

Definition at line 2634 of file User.php.

References $wgHiddenPrefs, getId(), getOption(), and getToken().

◆ getTokenUrl()

User::getTokenUrl (   $page,
  $token 
)
protected

Internal function to format the e-mail validation/invalidation URLs.

This uses a quickie hack to use the hardcoded English names of the Special: pages, for ASCII safety.

Note
Since these URLs get dropped directly into emails, using the short English names avoids insanely long URL-encoded links, which also sometimes can get corrupted in some browsers/mailers (T8957 with Gmail and Internet Explorer).
Parameters
string$pageSpecial page
string$token
Returns
string Formatted URL

Definition at line 3878 of file User.php.

References $title, Title\makeTitle(), and NS_MAIN.

Referenced by confirmationTokenUrl(), and invalidationTokenUrl().

◆ getTouched()

User::getTouched ( )

Get the user touched timestamp.

Use this value only to validate caches via inequalities such as in the case of HTTP If-Modified-Since response logic

Returns
string TS_MW Timestamp

Definition at line 2302 of file User.php.

References $cache, $mTouched, load(), and wfTimestamp().

Referenced by validateCache().

◆ getUser()

User::getUser ( )
Note
This is only here for compatibility with the Authority interface.
Since
1.36
Returns
UserIdentity $this

Implements MediaWiki\Mail\UserEmailContact.

Definition at line 4274 of file User.php.

Referenced by EmailNotification\actuallyNotifyOnPageChange(), Parser\getUser(), and EmailNotification\notifyOnPageChange().

◆ getUserPage()

User::getUserPage ( )

Get this user's personal page title.

Returns
Title User's personal page title

Definition at line 3647 of file User.php.

References getName(), Title\makeTitle(), and NS_USER.

Referenced by MediaWiki\Auth\AuthManager\autoCreateUser(), getTalkPage(), and saveSettings().

◆ getWikiId()

User::getWikiId ( )

Returns self::LOCAL to indicate the user is associated with the local wiki.

Since
1.36
Returns
string|false

Implements MediaWiki\DAO\WikiAwareEntity.

Definition at line 279 of file User.php.

◆ groupHasPermission()

static User::groupHasPermission (   $group,
  $role 
)
static

Check, if the given group has the given permission.

If you're wanting to check whether all users have a permission, use PermissionManager::isEveryoneAllowed() instead. That properly checks if it's revoked from anyone.

Deprecated:
since 1.34, use GroupPermissionsLookup::groupHasPermission() instead in 1.36+, or PermissionManager::groupHasPermission() in 1.34 and 1.35
Since
1.21
Parameters
string$groupGroup to check
string$roleRole to check
Returns
bool

Definition at line 4084 of file User.php.

◆ idForName()

User::idForName (   $flags = self::READ_NORMAL)

If only this user's username is known, and it exists, return the user ID.

Parameters
int$flagsBitfield of User:READ_* constants; useful for existence checks
Returns
int

Definition at line 3365 of file User.php.

References $s, DBAccessObjectUtils\getDBOptions(), getName(), and wfGetDB().

◆ idFromName()

static User::idFromName (   $name,
  $flags = self::READ_NORMAL 
)
static

Get database id given a user name.

Deprecated:
since 1.37. Use UserIdentityLookup::getUserIdentityByName instead.
Parameters
string$nameUsername
int$flagsUser::READ_* constant bitfield
Returns
int|null The corresponding user's ID, or null if user is nonexistent

Definition at line 933 of file User.php.

Referenced by ExternalUserNames\applyPrefix(), MediaWiki\Auth\AuthManager\autoCreateUser(), CleanupUsersWithNoId\cleanup(), CreateBotPassword\execute(), and UsersPager\getQueryInfo().

◆ incEditCount()

User::incEditCount ( )

Schedule a deferred update to update the user's edit count.

Deprecated:
since 1.37

Definition at line 4148 of file User.php.

◆ insertNewUser()

static User::insertNewUser ( callable  $insertActor,
  $name,
  $params = [] 
)
staticprivate

See ::createNew.

Parameters
callable$insertActor( UserIdentity $actor, IDatabase $dbw ): int actor ID,
string$name
array$params
Returns
User|null

Definition at line 3407 of file User.php.

References Wikimedia\Rdbms\IDatabase\affectedRows(), DB_PRIMARY, Wikimedia\Rdbms\IDatabase\insert(), load(), PasswordFactory\newInvalidPassword(), wfDeprecated(), and wfGetDB().

Referenced by createNew(), and newSystemUser().

◆ invalidateCache()

User::invalidateCache ( )

Immediately touch the user data cache for this account.

Calls touch() and removes account data from memcached

Definition at line 2258 of file User.php.

References clearSharedCache(), and touch().

◆ invalidateEmail()

User::invalidateEmail ( )

Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already confirmed.

Note
Call saveSettings() after calling this function to commit the change.
Returns
bool Returns true

Definition at line 3908 of file User.php.

References load(), and setEmailAuthenticationTimestamp().

Referenced by setEmail().

◆ invalidationTokenUrl()

User::invalidationTokenUrl (   $token)
protected

Return a URL the user can use to invalidate their email address.

Parameters
string$tokenAccepts the email confirmation token
Returns
string New token URL

Definition at line 3860 of file User.php.

References getTokenUrl().

Referenced by sendConfirmationMail().

◆ isAllowed()

◆ isAllowedAll()

User::isAllowedAll (   $permissions)

Checks whether this authority has any of the given permissions in general.

Implementations must ensure that this method returns false if isAllowed would return false for any of the given permissions. Calling isAllowedAll() with one parameter must be equivalent to calling isAllowed(). Calling isAllowedAny() with no parameter is not allowed.

See also
isAllowed
Parameters
string...$permissions Permissions to test. At least one must be given.
Returns
bool True if the user is allowed to perform all of the given actions

Implements MediaWiki\Permissions\Authority.

Definition at line 3021 of file User.php.

References getThisAsAuthority().

◆ isAllowedAny()

User::isAllowedAny (   $permissions)

Checks whether this authority has any of the given permissions in general.

Implementations must ensure that this method returns true if isAllowed would return true for any of the given permissions. Calling isAllowedAny() with one parameter must be equivalent to calling isAllowed(). Calling isAllowedAny() with no parameter is not allowed.

See also
isAllowed
Parameters
string...$permissions Permissions to test. At least one must be given.
Returns
bool True if user is allowed to perform any of the given actions

Implements MediaWiki\Permissions\Authority.

Definition at line 3017 of file User.php.

References getThisAsAuthority().

Referenced by ApiQueryInfo\getImportToken(), useFilePatrol(), useNPPatrol(), useRCPatrol(), and MediaWiki\Preferences\DefaultPreferencesFactory\watchlistPreferences().

◆ isAllowedToCreateAccount()

User::isAllowedToCreateAccount ( )

Get whether the user is allowed to create an account.

Returns
bool

Definition at line 3638 of file User.php.

References isAllowed(), and isBlockedFromCreateAccount().

◆ isAllowUsertalk()

User::isAllowUsertalk ( )

Checks if usertalk is allowed.

Returns
bool

Definition at line 4265 of file User.php.

References $mAllowUsertalk.

Referenced by MediaWiki\Permissions\PermissionManager\isBlockedFrom().

◆ isAnon()

◆ isBlocked()

User::isBlocked (   $fromReplica = true)

Check if user is blocked.

Deprecated:
since 1.34, use User::getBlock() or Authority:getBlock() or Authority:definitlyCan() or Authority:authorizeRead() or Authority:authorizeWrite() or PermissionManager::isBlockedFrom(), as appropriate.
Parameters
bool$fromReplicaWhether to check the replica DB instead of the master. Hacked from false due to horrible probs on site.
Returns
bool True if blocked, false otherwise

Definition at line 1920 of file User.php.

References getBlock().

◆ isBlockedFrom()

User::isBlockedFrom (   $title,
  $fromReplica = false 
)

Check if user is blocked from editing a particular article.

Parameters
PageIdentity$titleTitle to check
bool$fromReplicaWhether to check the replica DB instead of the master
Returns
bool
Deprecated:
since 1.33, use MediaWikiServices::getInstance()->getPermissionManager()->isBlockedFrom(..)

Definition at line 1961 of file User.php.

References $title, and TitleValue\castPageToLinkTarget().

Referenced by Action\checkCanExecute().

◆ isBlockedFromCreateAccount()

User::isBlockedFromCreateAccount ( )

Get whether the user is explicitly blocked from account creation.

Deprecated:
since 1.37. Instead use Authority::authorize* for createaccount permission.
Returns
bool|AbstractBlock

Definition at line 3594 of file User.php.

References $mBlock, MediaWiki\Block\AbstractBlock\appliesToRight(), getBlockedStatus(), getRequest(), and isAllowed().

Referenced by isAllowedToCreateAccount().

◆ isBlockedFromEmailuser()

User::isBlockedFromEmailuser ( )

Get whether the user is blocked from using Special:Emailuser.

Returns
bool

Definition at line 3618 of file User.php.

References getBlockedStatus().

Referenced by ApiQueryInfo\getEmailToken().

◆ isBlockedFromUpload()

User::isBlockedFromUpload ( )

Get whether the user is blocked from using Special:Upload.

Since
1.33
Returns
bool

Definition at line 3629 of file User.php.

References getBlockedStatus().

◆ isBlockedGlobally()

User::isBlockedGlobally (   $ip = '')

Check if user is blocked on all wikis.

Do not use for actual edit permission checks! This is intended for quick UI checks.

Parameters
string$ipIP address, uses current client if none given
Returns
bool True if blocked, false otherwise

Definition at line 2005 of file User.php.

References getGlobalBlock().

◆ isBot()

User::isBot ( )
Returns
bool Whether this user is flagged as being a bot role account
Since
1.28

Definition at line 2986 of file User.php.

Referenced by MediaWiki\Storage\PageEditStash\checkCache(), and getWatchlistValue().

◆ isCreatableName()

static User::isCreatableName (   $name)
static

Usernames which fail to pass this function will be blocked from new account registrations, but may be used internally either by batch processes or by user accounts which have already been created.

Additional preventions may be added here rather than in isValidUserName() to avoid disrupting existing accounts.

Deprecated:
since 1.35, use the UserNameUtils service. Hard deprecated since 1.37
Parameters
string$nameString to match
Returns
bool

Definition at line 1085 of file User.php.

References wfDeprecated().

◆ isEmailConfirmationPending()

User::isEmailConfirmationPending ( )

Check whether there is an outstanding request for e-mail confirmation.

Returns
bool

Definition at line 3989 of file User.php.

References $wgEmailAuthentication, isEmailConfirmed(), and wfTimestamp().

◆ isEmailConfirmed()

User::isEmailConfirmed ( )

Is this user's e-mail address valid-looking and confirmed within limits of the current site configuration?

Note
If $wgEmailAuthentication is on, this may require the user to have confirmed their address by returning a code or using a password sent to the address from the wiki.
Returns
bool

Implements MediaWiki\Mail\UserEmailContact.

Definition at line 3963 of file User.php.

References $wgEmailAuthentication, getEmail(), getEmailAuthenticationTimestamp(), isAnon(), load(), and Sanitizer\validateEmail().

Referenced by canReceiveEmail(), canSendEmail(), MediaWiki\Permissions\PermissionManager\checkUserBlock(), confirmEmail(), and isEmailConfirmationPending().

◆ isGlobalSessionUser()

User::isGlobalSessionUser ( )
private

Check whether this is the global session user.

Returns
bool

Definition at line 4348 of file User.php.

References RequestContext\getMain(), and getName().

Referenced by getBlockedStatus().

◆ isHidden()

User::isHidden ( )

Check if user account is hidden.

Returns
bool True if hidden, false otherwise

Definition at line 2065 of file User.php.

References $mHideName, and getBlockedStatus().

Referenced by UserrightsPage\fetchUser(), and MediaWiki\Permissions\PermissionManager\isBlockedFrom().

◆ isIP()

static User::isIP (   $name)
static

Does the string match an anonymous IP address?

This function exists for username validation, in order to reject usernames which are similar in form to IP addresses. Strings such as 300.300.300.300 will return true because it looks like an IP address, despite not being strictly valid.

We match "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.xxx" as an anonymous IP address because the usemod software would "cloak" anonymous IP addresses like this, if we allowed accounts like this to be created new users could get the old edits of these anonymous users.

Deprecated:
since 1.35, use the UserNameUtils service. Hard deprecated since 1.37. Note that UserNameUtils::isIP does not accept IPv6 ranges, while this method does
Parameters
string$nameName to match
Returns
bool

Definition at line 974 of file User.php.

References wfDeprecated().

Referenced by MediaWiki\User\UserFactory\newAnonymous().

◆ isIPRange()

User::isIPRange ( )

Is the user an IP range?

Deprecated:
since 1.35, hard deprecated since 1.36 Use the UserNameUtils service or IPUtils directly
Since
1.30
Returns
bool

Definition at line 989 of file User.php.

References wfDeprecated().

◆ isItemLoaded()

User::isItemLoaded (   $item,
  $all = 'all' 
)

Return whether an item has been loaded.

Parameters
string$itemItem to check. Current possibilities:
  • id
  • name
  • realname
string$all'all' to check if the whole object has been loaded or any other string to check if only the item is available (e.g. for optimisation)
Returns
bool

Definition at line 1237 of file User.php.

References true.

Referenced by getActorId(), getId(), getName(), and getRealName().

◆ isLocked()

User::isLocked ( )

Check if user account is locked.

Returns
bool True if locked, false otherwise

Definition at line 2050 of file User.php.

References $mLocked.

◆ isLoggedIn()

User::isLoggedIn ( )

Get whether the user is registered.

Deprecated:
since 1.36; use isRegistered() directly
Returns
bool

Definition at line 2968 of file User.php.

References isRegistered(), and wfDeprecated().

◆ isNewbie()

User::isNewbie ( )

Determine whether the user is a newbie.

Newbies are either anonymous IPs, or the most recently created accounts.

Returns
bool

Definition at line 3666 of file User.php.

References isAllowed().

Referenced by pingLimiter(), and SpecialEmailUser\validateTarget().

◆ isPingLimitable()

User::isPingLimitable ( )

Is this user subject to rate limiting?

Returns
bool True if rate limited

Definition at line 1657 of file User.php.

References $wgRateLimitsExcludedIPs, getRequest(), and isAllowed().

Referenced by pingLimiter().

◆ isRegistered()

User::isRegistered ( )

Get whether the user is registered.

Returns
bool True if user is registered on this wiki, i.e., has a user ID. False if user is anonymous or has no local account (which can happen when importing). This is equivalent to getId() != 0 and is provided for code readability.
Since
1.34

Implements MediaWiki\User\UserIdentity.

Definition at line 2958 of file User.php.

References getId().

Referenced by MediaWiki\User\UserGroupManager\checkCondition(), UppercaseTitlesForUnicodeTransition\execute(), ApiQueryInfo\getOptionsToken(), LanguageConverter\getUserVariant(), ApiQueryInfo\getWatchToken(), isAnon(), isLoggedIn(), and spreadAnyEditBlock().

◆ isSafeToLoad()

User::isSafeToLoad ( )

Test if it's safe to load this User object.

You should typically check this before using $wgUser or RequestContext::getUser in a method that might be called before the system has been fully initialized. If the object is unsafe, you should use an anonymous user: \code $user = $wgUser->isSafeToLoad() ? $wgUser : new User; \endcode

Since
1.27
Returns
bool

Definition at line 357 of file User.php.

References $wgFullyInitialised.

Referenced by LanguageConverter\getUserVariant(), and MediaWiki\Block\BlockManager\trackBlockWithCookie().

◆ isSystemUser()

User::isSystemUser ( )

Get whether the user is a system user.

A user is considered to exist as a non-system user if it can authenticate, or has an email set, or has a non-invalid token.

Returns
bool Whether this user is a system user
Since
1.35

Definition at line 3007 of file User.php.

References getEmail(), and load().

◆ isTempWatched()

User::isTempWatched ( PageIdentity  $title,
  $checkRights = self::CHECK_USER_RIGHTS 
)

Check if the article is temporarily watched.

Since
1.35
Access: internal
This, isWatched() and related User methods may be deprecated soon (T208766). If possible, implement permissions checks and call WatchedItemStore::isTempWatched()
Parameters
PageIdentity$titlethe article to look at
bool$checkRightsWhether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass User::CHECK_USER_RIGHTS or User::IGNORE_USER_RIGHTS.
Returns
bool
Deprecated:
since 1.37, use WatchlistManager::isTempWatched() or WatchlistManager::isTempWatchedIgnoringRights()

Definition at line 3105 of file User.php.

References $title, $watchlistManager, and wfDeprecated().

◆ isUsableName()

static User::isUsableName (   $name)
static

Usernames which fail to pass this function will be blocked from user login and new account registrations, but may be used internally by batch processes.

If an account already exists in this form, login will be blocked by a failure to pass this function.

Deprecated:
since 1.35, use the UserNameUtils service. Hard deprecated since 1.37
Parameters
string$nameName to match
Returns
bool

Definition at line 1027 of file User.php.

References wfDeprecated().

◆ isValidPassword()

User::isValidPassword (   $password)

Is the input a valid password for this user?

Parameters
string$passwordDesired password
Returns
bool

Definition at line 1096 of file User.php.

References checkPasswordValidity().

◆ isValidUserName()

static User::isValidUserName (   $name)
static

Is the input a valid username?

Checks if the input is a valid username, we don't want an empty string, an IP address, anything that contains slashes (would mess up subpages), is longer than the maximum allowed username size or doesn't begin with a capital letter.

Deprecated:
since 1.35, hard deprecated in 1.36 Use the UserNameUtils service
Parameters
string$nameName to match
Returns
bool

Definition at line 1008 of file User.php.

References wfDeprecated().

◆ isWatched()

User::isWatched ( PageIdentity  $title,
  $checkRights = self::CHECK_USER_RIGHTS 
)

Check the watched status of an article.

Since
1.22 $checkRights parameter added
Parameters
PageIdentity$titlethe article to look at
bool$checkRightsWhether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass User::CHECK_USER_RIGHTS or User::IGNORE_USER_RIGHTS.
Returns
bool
Deprecated:
since 1.37, use WatchlistManager::isWatched() or WatchlistManager::isWatchedIgnoringRights()

Definition at line 3084 of file User.php.

References $title, $watchlistManager, and wfDeprecated().

◆ listOptionKinds()

static User::listOptionKinds ( )
static

Return a list of the types of user options currently returned by User::getOptionKinds().

Currently, the option kinds are:

  • 'registered' - preferences which are registered in core MediaWiki or by extensions using the UserGetDefaultOptions hook.
  • 'registered-multiselect' - as above, using the 'multiselect' type.
  • 'registered-checkmatrix' - as above, using the 'checkmatrix' type.
  • 'userjs' - preferences with names starting with 'userjs-', intended to be used by user scripts.
  • 'special' - "preferences" that are not accessible via User::getOptions or User::setOptions.
  • 'unused' - preferences about which MediaWiki doesn't know anything. These are usually legacy options, removed in newer versions.

The API (and possibly others) use this function to determine the possible option types for validation purposes, so make sure to update this when a new option kind is added.

See also
User::getOptionKinds
Returns
array Option kinds
Deprecated:
since 1.35, hard deprecated since 1.37 Use UserOptionsManager::listOptionKinds instead

Definition at line 2698 of file User.php.

References wfDeprecated().

◆ load()

◆ loadDefaults()

User::loadDefaults (   $name = false,
  $actorId = null 
)

Set cached properties to default.

Note
This no longer clears uncached lazy-initialised properties; the constructor does that instead.
Parameters
string | bool$name
int | null$actorId

Definition at line 1201 of file User.php.

References wfTimestamp().

Referenced by PPFuzzUser\load(), load(), loadFromDatabase(), and loadFromId().

◆ loadFromCache()

User::loadFromCache ( )
protected

Load user data from shared cache, given mId has already been set.

Returns
bool True
Since
1.25

Definition at line 526 of file User.php.

References $cache, $wgFullyInitialised, DB_REPLICA, getCacheKey(), loadFromDatabase(), VERSION, wfDebug(), wfGetDB(), and wfTimestamp().

Referenced by loadFromId().

◆ loadFromDatabase()

User::loadFromDatabase (   $flags = self::READ_LATEST)

Load user data from the database.

$this->mId must be set, this is how the user is identified.

Parameters
int$flagsUser::READ_* constant bitfield
Returns
bool True if the user exists, false if the user is anonymous

Definition at line 1286 of file User.php.

References $s, DBAccessObjectUtils\getDBOptions(), getQueryInfo(), loadDefaults(), loadFromRow(), and wfGetDB().

Referenced by addToDatabase(), loadFromCache(), and loadFromId().

◆ loadFromId()

User::loadFromId (   $flags = self::READ_NORMAL)

Load user table data, given mId has already been set.

Parameters
int$flagsUser::READ_* constant bitfield
Returns
bool False if the ID does not exist, true otherwise

Definition at line 462 of file User.php.

References DBAccessObjectUtils\hasFlags(), loadDefaults(), loadFromCache(), and loadFromDatabase().

Referenced by MediaWiki\Auth\AuthManager\autoCreateUser(), and load().

◆ loadFromRow()

User::loadFromRow (   $row,
  $data = null 
)
protected

Initialize this object from a row from the user table.

Parameters
stdClass$rowRow from the user table to load.
array | null$dataFurther user data to load into the object

user_groups Array of arrays or stdClass result rows out of the user_groups table. Previously you were supposed to pass an array of strings here, but we also need expiry info nowadays, so an array of strings is ignored.

Definition at line 1338 of file User.php.

References if, setItemLoaded(), wfTimestamp(), and wfTimestampOrNull().

Referenced by loadFromDatabase(), and newFromRow().

◆ loadFromSession()

User::loadFromSession ( )
private

Load user data from the session.

Returns
bool True if the user is logged in, false otherwise.

Definition at line 1260 of file User.php.

References getId(), getName(), getRequest(), getToken(), and loadFromUserObject().

Referenced by load().

◆ loadFromUserObject()

User::loadFromUserObject (   $user)
protected

Load the data for this user object from another user object.

Parameters
User$user

Definition at line 1445 of file User.php.

Referenced by loadFromSession().

◆ logout()

User::logout ( )

Log this user out.

Definition at line 3241 of file User.php.

References doLogout().

◆ makeUpdateConditions()

User::makeUpdateConditions ( IDatabase  $db,
array  $conditions 
)
protected

Builds update conditions.

Additional conditions may be added to $conditions to protected against race conditions using a compare-and-set (CAS) mechanism based on comparing $this->mTouched with the user_touched field.

Parameters
IDatabase$db
array$conditionsWHERE conditions for use with Database::update
Returns
array WHERE conditions for use with Database::update

Definition at line 1484 of file User.php.

References Wikimedia\Rdbms\IDatabase\timestamp().

◆ matchEditToken()

User::matchEditToken (   $val,
  $salt = '',
  $request = null,
  $maxage = null 
)

Check given value against the token value stored in the session.

A match should confirm that the form was submitted from the user's own login session, not a form submission from a third-party site.

Deprecated:
since 1.37. Use CsrfTokenSet::matchToken instead
Parameters
string$valInput value to compare
string | array$saltOptional function-specific data for hashing
WebRequest | null$requestObject to use, or null to use the global request
int | null$maxageFail tokens older than this, in seconds
Returns
bool Whether the token matches

Definition at line 3724 of file User.php.

References getEditTokenObject().

Referenced by matchEditTokenNoSuffix().

◆ matchEditTokenNoSuffix()

User::matchEditTokenNoSuffix (   $val,
  $salt = '',
  $request = null,
  $maxage = null 
)

Check given value against the token value stored in the session, ignoring the suffix.

Deprecated:
since 1.37. No replacement was provided.
Parameters
string$valInput value to compare
string | array$saltOptional function-specific data for hashing
WebRequest | null$requestObject to use, or null to use the global request
int | null$maxageFail tokens older than this, in seconds
Returns
bool Whether the token matches

Definition at line 3739 of file User.php.

References matchEditToken(), and wfDeprecated().

◆ newFatalPermissionDeniedStatus()

static User::newFatalPermissionDeniedStatus (   $permission)
static

◆ newFromActorId()

static User::newFromActorId (   $id)
static

Static factory method for creation from a given actor ID.

See also
UserFactory::newFromActorId
Deprecated:
since 1.36, use a UserFactory instead
Since
1.31
Parameters
int$idValid actor ID
Returns
User

Definition at line 660 of file User.php.

◆ newFromAnyId()

static User::newFromAnyId (   $userId,
  $userName,
  $actorId,
  $dbDomain = false 
)
static

Static factory method for creation from an ID, name, and/or actor ID.

This does not check that the ID, name, and actor ID all correspond to the same user.

See also
UserFactory::newFromAnyId
Deprecated:
since 1.36, use a UserFactory instead
Since
1.31
Parameters
int | null$userIdUser ID, if known
string | null$userNameUser name, if known
int | null$actorIdActor ID, if known
bool | string$dbDomainremote wiki to which the User/Actor ID applies, or false if none
Returns
User

Definition at line 708 of file User.php.

Referenced by LocalFileDeleteBatch\doDBInserts(), ImportableOldRevisionImporter\import(), RemoveUnusedAccounts\isInactiveAccount(), ArchivedFile\loadFromRow(), and LocalFile\loadFromRow().

◆ newFromConfirmationCode()

static User::newFromConfirmationCode (   $code,
  $flags = self::READ_NORMAL 
)
static

Factory method to fetch whichever user has a given email confirmation code.

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.

See also
UserFactory::newFromConfirmationCode
Deprecated:
since 1.36, use a UserFactory instead
Parameters
string$codeConfirmation code
int$flagsUser::READ_* bitfield
Returns
User|null

Definition at line 729 of file User.php.

◆ newFromId()

◆ newFromIdentity()

◆ newFromName()

static User::newFromName (   $name,
  $validate = 'valid' 
)
static
See also
UserFactory::newFromName
Deprecated:
since 1.36, use a UserFactory instead

This is slightly less efficient than newFromId(), so use newFromId() if you have both an ID and a name handy.

Parameters
string$nameUsername, validated by Title::newFromText()
string | bool$validateValidate username. Takes the same parameters as User::getCanonicalName(), except that true is accepted as an alias for 'valid', for BC.
Returns
User|bool User object, or false if the username is invalid (e.g. if it contains illegal characters or is an IP address). If the username is not present in the database, the result will be a user object with a name, zero user ID and default settings.

Definition at line 602 of file User.php.

Referenced by CliInstaller\__construct(), ImageListPager\__construct(), EmailNotification\actuallyNotifyOnPageChange(), MediaWiki\Auth\AuthManager\beginAccountCreation(), MediaWiki\Auth\AuthManager\beginAuthentication(), Parser\braceSubstitution(), MediaWiki\Auth\AuthManager\canCreateAccount(), EmailNotification\canSendUserTalkEmail(), MediaWiki\Auth\AuthManager\continueAccountCreation(), MediaWiki\Auth\AuthManager\continueAccountLink(), MediaWiki\Auth\AuthManager\continueAuthentication(), Installer\createSysop(), MediaWiki\Storage\DerivedPageDataUpdater\doUpdates(), SpecialContributions\execute(), SpecialDeletedContributions\execute(), LoginSignupSpecialPage\execute(), BlockUsers\execute(), DeleteBatch\execute(), EditCLI\execute(), ImportImages\execute(), ImportSiteScripts\execute(), ImportTextFiles\execute(), InvalidateUserSesssions\execute(), MakeTestEdits\execute(), MoveBatch\execute(), Protect\execute(), ResetUserEmail\execute(), Undelete\execute(), UppercaseTitlesForUnicodeTransition\execute(), UserrightsPage\fetchUser(), LogFormatter\formatParameterValue(), LogFormatter\formatParameterValueForApi(), BlockListPager\formatValue(), CoreParserFunctions\gender(), CreditsAction\getAuthor(), WikiPage\getContributors(), RefreshLinksJob\getDataUpdateOptions(), WANCacheReapUpdate\getEventAffectedKeys(), BlockLogFormatter\getMessageParameters(), NewUsersLogFormatter\getMessageParameters(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProvider\getNewPasswordExpiry(), ContribsPager\getQueryInfo(), RollbackEdits\getRollbackTitles(), SpecialEmailUser\getTarget(), ContribsPager\getTargetTable(), File\getUser(), CategoryMembershipChange\getUser(), DoubleRedirectJob\getUser(), DerivativeResourceLoaderContext\getUserObj(), ResourceLoaderContext\getUserObj(), ImportableOldRevisionImporter\import(), ImportableUploadRevisionImporter\import(), WikiRevision\importLogItem(), RequestContext\importScopedSession(), ReassignEdits\initialiseUser(), BotPassword\login(), RequestContext\newExtraneousContext(), WikiPage\onArticleDelete(), RawAction\onView(), InfoAction\pageInfo(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\providerAllowsAuthenticationDataChange(), EnotifNotifyJob\run(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\sendPasswordResetEmail(), SpecialLog\show(), EditPage\showIntro(), Article\showMissingArticle(), WebInstallerName\submit(), HTMLUserTextField\validate(), and Maintenance\validateUserOption().

◆ newFromRow()

static User::newFromRow (   $row,
  $data = null 
)
static

Create a new user object from a user row.

The row should have the following fields from the user table in it:

  • either user_name or user_id to load further data if needed (or both)
  • user_real_name
  • all other fields (email, etc.) It is useless to provide the remaining fields if either user_id, user_name and user_real_name are not provided because the whole row will be loaded once more from the database when accessing them.
Parameters
stdClass$rowA row from the user table
array | null$dataFurther data to load into the object (see User::loadFromRow for valid keys)
Returns
User

Definition at line 764 of file User.php.

References loadFromRow().

Referenced by MediaWiki\User\UserFactory\newFromRow(), newSystemUser(), and UserArrayFromResult\setCurrent().

◆ newFromSession()

static User::newFromSession ( WebRequest  $request = null)
static

Create a new user object using data from session.

If the login credentials are invalid, the result is an anonymous user.

Parameters
WebRequest | null$requestObject to use; the global request will be used if omitted.
Returns
User

Definition at line 742 of file User.php.

Referenced by RequestContext\getUser().

◆ newSystemUser()

static User::newSystemUser (   $name,
  $options = [] 
)
static

Static factory method for creation of a "system" user from username.

A "system" user is an account that's used to attribute logged actions taken by MediaWiki itself, as opposed to a bot or human user. Examples might include the 'Maintenance script' or 'Conversion script' accounts used by various scripts in the maintenance/ directory or accounts such as 'MediaWiki message delivery' used by the MassMessage extension.

This can optionally create the user if it doesn't exist, and "steal" the account if it does exist.

"Stealing" an existing user is intended to make it impossible for normal authentication processes to use the account, effectively disabling the account for normal use:

  • Email is invalidated, to prevent account recovery by emailing a temporary password and to disassociate the account from the existing human.
  • The token is set to a magic invalid value, to kill existing sessions and to prevent $this->setToken() calls from resetting the token to a valid value.
  • SessionManager is instructed to prevent new sessions for the user, to do things like deauthorizing OAuth consumers.
  • AuthManager is instructed to revoke access, to invalidate or remove passwords and other credentials.
Parameters
string$nameUsername
array$optionsOptions are:
  • validate: As for User::getCanonicalName(), default 'valid'. Deprecated since 1.36.
  • create: Whether to create the user if it doesn't already exist, default true
  • steal: Whether to "disable" the account for normal use if it already exists, default false
Returns
User|null
Since
1.27

Definition at line 805 of file User.php.

References $dbr, DB_PRIMARY, DB_REPLICA, getQueryInfo(), insertNewUser(), INVALID_TOKEN, newFromRow(), and wfDeprecatedMsg().

Referenced by ImageBuilder\addMissingImage(), Installer\createMainpage(), AddChangeTag\execute(), BlockUsers\execute(), CleanupCaps\execute(), CleanupSpam\execute(), DeleteBatch\execute(), DeleteDefaultMessages\execute(), DeleteEqualMessages\execute(), EditCLI\execute(), ImportImages\execute(), ImportSiteScripts\execute(), ImportTextFiles\execute(), MoveBatch\execute(), Protect\execute(), RollbackEdits\execute(), Undelete\execute(), UppercaseTitlesForUnicodeTransition\execute(), and PopulateArchiveRevId\makeDummyRevisionRow().

◆ newTouchedTimestamp()

User::newTouchedTimestamp ( )
private

Generate a current or new-future timestamp to be stored in the user_touched field when we update things.

Returns
string Timestamp in TS_MW format

Definition at line 2213 of file User.php.

References wfTimestamp().

Referenced by addToDatabase(), checkAndSetTouched(), and saveSettings().

◆ pingLimiter()

User::pingLimiter (   $action = 'edit',
  $incrBy = 1 
)

Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.

The method generates both a generic profiling point and a per action one (suffix being "-$action").

Note
When using a shared cache like memcached, IP-address last-hit counters will be shared across wikis.
Parameters
string$actionAction to enforce; 'edit' if unspecified
int$incrByPositive amount to increment counter by [defaults to 1]
Returns
bool True if a rate limiter was tripped
Exceptions
MWException

Definition at line 1684 of file User.php.

References $cache, $keys, $wgRateLimits, CentralIdLookup\AUDIENCE_RAW, getId(), ObjectCache\getLocalClusterInstance(), getName(), getRequest(), isNewbie(), and isPingLimitable().

Referenced by SpecialChangeEmail\attemptChange(), and PasswordReset\execute().

◆ probablyCan()

User::probablyCan ( string  $action,
PageIdentity  $target,
PermissionStatus  $status = null 
)
Since
1.36
Parameters
string$action
PageIdentity$target
PermissionStatus | null$status
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 4285 of file User.php.

References getThisAsAuthority().

◆ purge()

static User::purge (   $dbDomain,
  $userId 
)
static
Since
1.27
Parameters
string$dbDomain
int$userId

Definition at line 492 of file User.php.

References $cache.

Referenced by UserRightsProxy\invalidateCache().

◆ removeGroup()

User::removeGroup (   $group)

Remove the user from the given group.

This takes immediate effect.

Deprecated:
since 1.35 Use UserGroupManager::removeUserFromGroup instead.
Parameters
string$groupName of the group to remove
Returns
bool

Definition at line 2944 of file User.php.

◆ removeWatch()

User::removeWatch ( PageIdentity  $title,
  $checkRights = self::CHECK_USER_RIGHTS 
)

Stop watching an article.

Since
1.22 $checkRights parameter added
Parameters
PageIdentity$titlethe article to look at
bool$checkRightsWhether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass User::CHECK_USER_RIGHTS or User::IGNORE_USER_RIGHTS.
Deprecated:
since 1.37, use WatchlistManager::removeWatch() or WatchlistManager::removeWatchIgnoringRights

Definition at line 3147 of file User.php.

References $title, $watchlistManager, and wfDeprecated().

◆ requiresHTTPS()

User::requiresHTTPS ( )

Determine based on the wiki configuration and the user's options, whether this user must be over HTTPS no matter what.

Returns
bool

Definition at line 2781 of file User.php.

References $wgForceHTTPS, $wgSecureLogin, and getBoolOption().

◆ resetIdByNameCache()

static User::resetIdByNameCache ( )
static

Reset the cache used in idFromName().

In tests, reset the service container. There is no use-case for this in production code.

Deprecated:
since 1.37.

Definition at line 949 of file User.php.

References wfDeprecated().

◆ resetOptions()

User::resetOptions (   $resetKinds = [ 'registered',
'registered-multiselect'  ,
'registered-checkmatrix'  ,
'unused']  ,
IContextSource  $context = null 
)

Reset certain (or all) options to the site defaults.

The optional parameter determines which kinds of preferences will be reset. Supported values are everything that can be reported by getOptionKinds() and 'all', which forces a reset of all preferences and overrides everything else.

Parameters
array | string$resetKindsWhich kinds of preferences to reset. Defaults to [ 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' ] for backwards-compatibility.
IContextSource | null$contextContext source used when $resetKinds does not contain 'all', passed to getOptionKinds(). Defaults to RequestContext::getMain() when null.
Deprecated:
since 1.35, hard deprecated since 1.37 Use UserOptionsManager::resetOptions instead (Warning: Different argument order).

Definition at line 2743 of file User.php.

References RequestContext\getMain(), and wfDeprecated().

◆ resetTokenFromOption()

User::resetTokenFromOption (   $oname)

Reset a token stored in the preferences (like the watchlist one).

Does not save user's preferences (similarly to setOption()).

Parameters
string$onameThe option name to reset the token in
Returns
string|bool New token value, or false if this option is disabled.
See also
getTokenFromOption()
setOption()

Definition at line 2662 of file User.php.

References $wgHiddenPrefs, MWCryptRand\generateHex(), and setOption().

◆ saveSettings()

◆ sendConfirmationMail()

User::sendConfirmationMail (   $type = 'created')

Generate a new e-mail confirmation token and send a confirmation/invalidation mail to the user's given address.

Parameters
string$typeMessage to send, either "created", "changed" or "set"
Returns
Status

Definition at line 3752 of file User.php.

References $type, $wgLang, confirmationToken(), confirmationTokenUrl(), getName(), getRequest(), invalidationTokenUrl(), saveSettings(), sendMail(), and wfMessage().

Referenced by setEmailWithConfirmation().

◆ sendMail()

User::sendMail (   $subject,
  $body,
  $from = null,
  $replyto = null 
)

Send an e-mail to this user's account.

Does not check for confirmed status or validity.

Parameters
string$subjectMessage subject
string$bodyMessage body
User | null$fromOptional sending user; if unspecified, default $wgPasswordSender will be used.
MailAddress | null$replytoReply-To address
Returns
Status

Definition at line 3807 of file User.php.

References $wgPasswordSender, MailAddress\newFromUser(), UserMailer\send(), and wfMessage().

Referenced by sendConfirmationMail(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\sendNewAccountEmail(), and setEmailWithConfirmation().

◆ setActorId()

User::setActorId ( int  $actorId)

Sets the actor id.

For use by ActorStore only. Should be removed once callers of getActorId() have been migrated to using ActorNormalization.

Access: internal
Deprecated:
since 1.36
Parameters
int$actorId

Definition at line 2194 of file User.php.

References setItemLoaded().

◆ setCookies()

User::setCookies (   $request = null,
  $secure = null,
  $rememberMe = false 
)

Persist this user's session (e.g.

set cookies)

Parameters
WebRequest | null$requestWebRequest object to use; the global request will be used if null is passed.
bool | null$secureWhether to force secure/insecure cookies or use default
bool$rememberMeWhether to add a Token cookie for elongated sessions

Definition at line 3205 of file User.php.

References getRequest(), and load().

◆ setEmail()

User::setEmail ( string  $str)

Set the user's e-mail address.

Parameters
string$strNew e-mail address

Definition at line 2452 of file User.php.

References getEmail(), invalidateEmail(), and load().

Referenced by setEmailWithConfirmation().

◆ setEmailAuthenticationTimestamp()

User::setEmailAuthenticationTimestamp (   $timestamp)

Set the e-mail authentication timestamp.

Parameters
string | null$timestampTS_MW timestamp

Definition at line 3922 of file User.php.

References load().

Referenced by confirmEmail(), and invalidateEmail().

◆ setEmailWithConfirmation()

User::setEmailWithConfirmation ( string  $str)

Set the user's e-mail address and a confirmation mail if needed.

Since
1.20
Parameters
string$strNew e-mail address
Returns
Status

Definition at line 2469 of file User.php.

References $type, $wgEmailAuthentication, $wgEnableEmail, getEmail(), getName(), getRequest(), StatusValue\newFatal(), StatusValue\newGood(), sendConfirmationMail(), sendMail(), setEmail(), and wfMessage().

◆ setId()

User::setId (   $v)

Set the user and reload all fields according to a given ID.

Parameters
int$vUser ID to reload

Definition at line 2102 of file User.php.

References clearInstanceCache().

Referenced by MediaWiki\Auth\AuthManager\autoCreateUser().

◆ setItemLoaded()

User::setItemLoaded (   $item)

Set that an item has been loaded.

Access: internal
Only public for use in UserFactory
Parameters
string$item

Definition at line 1249 of file User.php.

Referenced by loadFromRow(), MediaWiki\User\UserFactory\newFromAnyId(), and setActorId().

◆ setName()

User::setName (   $str)

Set the user name.

This does not reload fields from the database according to the given name. Rather, it is used to create a temporary "nonexistent user" for later addition to the database. It can also be used to set the IP address for an anonymous user to something other than the current remote IP.

Note
User::newFromName() has roughly the same function, when the named user does not exist.
Parameters
string$strNew user name to set

Definition at line 2139 of file User.php.

References load().

Referenced by MediaWiki\Auth\AuthManager\continueAccountCreation().

◆ setOption()

User::setOption (   $oname,
  $val 
)

Set the given option for a user.

You need to call saveSettings() to actually write to the database.

Parameters
string$onameThe option to set
mixed$valNew value to set
Deprecated:
since 1.35 Use UserOptionsManager::setOption instead

Definition at line 2618 of file User.php.

Referenced by __set(), resetTokenFromOption(), and MediaWiki\Auth\AuthManager\setDefaultUserOptions().

◆ setRealName()

User::setRealName ( string  $str)

Set the user's real name.

Parameters
string$strNew real name

Definition at line 2534 of file User.php.

References load().

◆ setToken()

User::setToken (   $token = false)

Set the random token (used for persistent authentication) Called from loadDefaults() among other places.

Parameters
string | bool$tokenIf specified, set the token to this value

Definition at line 2412 of file User.php.

References MWCryptRand\generateHex(), and load().

Referenced by addToDatabase(), getToken(), MediaWiki\Session\SessionManager\invalidateSessionsForUser(), and MediaWiki\Auth\AuthManager\setDefaultUserOptions().

◆ spreadAnyEditBlock()

User::spreadAnyEditBlock ( )

If this user is logged-in and blocked, block any IP address they've successfully logged in from.

Returns
bool A block was spread

Definition at line 3561 of file User.php.

References getBlock(), isRegistered(), and spreadBlock().

◆ spreadBlock()

User::spreadBlock ( )
protected

If this (non-anonymous) user is blocked, block the IP address they've successfully logged in from.

Returns
bool A block was spread

Definition at line 3574 of file User.php.

References getName(), getRequest(), load(), and wfDebug().

Referenced by spreadAnyEditBlock().

◆ touch()

User::touch ( )

Update the "touched" timestamp for the user.

This is useful on various login/logout events when making sure that a browser or proxy that has multiple tenants does not suffer cache pollution where the new user sees the old users content. The value of getTouched() is checked when determining 304 vs 200 responses. Unlike invalidateCache(), this preserves the User object cache and avoids database writes.

Since
1.25

Definition at line 2275 of file User.php.

References $cache, and getId().

Referenced by invalidateCache().

◆ useFilePatrol()

User::useFilePatrol ( )

Check whether to enable new files patrol features for this user.

Returns
bool True or false

Definition at line 3054 of file User.php.

References $wgUseFilePatrol, $wgUseRCPatrol, and isAllowedAny().

Referenced by ChangesList\isUnpatrolled().

◆ useNPPatrol()

User::useNPPatrol ( )

Check whether to enable new pages patrol features for this user.

Returns
bool True or false

Definition at line 3042 of file User.php.

References $wgUseNPPatrol, $wgUseRCPatrol, and isAllowedAny().

Referenced by ApiQueryRecentChanges\getPatrolToken(), WatchedItemQueryService\getWatchedItemsWithRCInfoQueryFilterConds(), ChangesList\isUnpatrolled(), and MediaWiki\Preferences\DefaultPreferencesFactory\rcPreferences().

◆ useRCPatrol()

◆ validateCache()

User::validateCache (   $timestamp)

Validate the cache for this account.

Parameters
string$timestampA timestamp in TS_MW format
Returns
bool

Definition at line 2290 of file User.php.

References getTouched().

◆ whoIs()

static User::whoIs (   $id)
static

Get the username corresponding to a given user ID.

Parameters
int$idUser ID
Returns
string|false The corresponding username

Definition at line 912 of file User.php.

References UserCache\singleton().

Referenced by UserrightsPage\fetchUser().

◆ whoIsReal()

static User::whoIsReal (   $id)
static

Get the real name of a user given their user ID.

Parameters
int$idUser ID
Returns
string|false The corresponding user's real name

Definition at line 922 of file User.php.

References UserCache\singleton().

Member Data Documentation

◆ $mActorId

int null User::$mActorId

Switched from protected to public for use in UserFactory.

Definition at line 159 of file User.php.

Referenced by getActorId().

◆ $mAllowUsertalk

bool User::$mAllowUsertalk
protected

Definition at line 243 of file User.php.

Referenced by isAllowUsertalk().

◆ $mBlock

AbstractBlock null User::$mBlock
Deprecated:
since 1.35. Instead, use User::getBlock to get the block; or the GetUserBlock hook to set or unset a block.

Definition at line 240 of file User.php.

Referenced by isBlockedFromCreateAccount().

◆ $mBlockedby

string int User::$mBlockedby
Deprecated:
since 1.35. Instead, use User::getBlock to get the block, then AbstractBlock::getByName to get the blocker's name; or use the GetUserBlock hook to set or unset a block. -1 when the block is unset

Definition at line 211 of file User.php.

Referenced by blockedBy().

◆ $mBlockedFromCreateAccount

AbstractBlock bool User::$mBlockedFromCreateAccount = false
private

Definition at line 246 of file User.php.

◆ $mBlockreason

string User::$mBlockreason
protected

TODO: This should be removed when User::BlockedFor and AbstractBlock::getReason are hard deprecated.

Definition at line 219 of file User.php.

Referenced by blockedFor().

◆ $mCacheVars

string [] User::$mCacheVars
staticprotected
Initial value:
= [
'mId',
'mName',
'mRealName',
'mEmail',
'mTouched',
'mToken',
'mEmailAuthenticated',
'mEmailToken',
'mEmailTokenExpires',
'mRegistration',
'mActorId',
]

List of member variables which are saved to the shared cache (memcached).

Any operation which changes the corresponding database fields must call a cache-clearing function.

Definition at line 130 of file User.php.

◆ $mDatePreference

string User::$mDatePreference
protected

Lazy-initialized variables, invalidated with clearInstanceCache.

Definition at line 204 of file User.php.

Referenced by getDatePreference().

◆ $mEmail

string User::$mEmail

Definition at line 164 of file User.php.

Referenced by getEmail().

◆ $mEmailAuthenticated

string User::$mEmailAuthenticated

Definition at line 172 of file User.php.

Referenced by getEmailAuthenticationTimestamp().

◆ $mEmailToken

string User::$mEmailToken
protected

Definition at line 174 of file User.php.

◆ $mEmailTokenExpires

string User::$mEmailTokenExpires
protected

Definition at line 176 of file User.php.

◆ $mFrom

string User::$mFrom

Initialization data source if mLoadedItems!==true.

May be one of:

  • 'defaults' anonymous user initialised from class defaults
  • 'name' initialise from mName
  • 'id' initialise from mId
  • 'actor' initialise from mActorId
  • 'session' log in from session if possible

Use the User::newFrom*() family of functions to set this.

Definition at line 198 of file User.php.

◆ $mGlobalBlock

AbstractBlock User::$mGlobalBlock
protected

Definition at line 221 of file User.php.

◆ $mHash

string User::$mHash
protected

Definition at line 213 of file User.php.

◆ $mHideName

bool User::$mHideName
Deprecated:
since 1.35. Instead, use User::getBlock to get the block, then AbstractBlock::getHideName to determine whether the block hides the user; or use the GetUserBlock hook to hide or unhide a user.

Definition at line 230 of file User.php.

Referenced by isHidden().

◆ $mId

int User::$mId

Cache variables.

Definition at line 151 of file User.php.

Referenced by getId().

◆ $mLoadedItems

array bool User::$mLoadedItems = []
protected

Array with already loaded items or true if all items have been loaded.

Definition at line 185 of file User.php.

Referenced by load().

◆ $mLocked

bool User::$mLocked
protected

Definition at line 223 of file User.php.

Referenced by isLocked().

◆ $mName

string User::$mName

Definition at line 153 of file User.php.

Referenced by getName().

◆ $mQuickTouched

string User::$mQuickTouched
protected

TS_MW timestamp from cache.

Definition at line 168 of file User.php.

◆ $mRealName

string User::$mRealName

Definition at line 161 of file User.php.

Referenced by getRealName().

◆ $mRegistration

string User::$mRegistration
protected

Definition at line 178 of file User.php.

Referenced by getRegistration().

◆ $mRequest

WebRequest User::$mRequest
private

Definition at line 233 of file User.php.

Referenced by getRequest().

◆ $mThisAsAuthority

Authority null User::$mThisAsAuthority
private

lazy-initialized Authority of this user

Definition at line 252 of file User.php.

Referenced by getThisAsAuthority().

◆ $mToken

string User::$mToken
protected

Definition at line 170 of file User.php.

Referenced by getToken().

◆ $mTouched

string User::$mTouched

TS_MW timestamp from the DB.

Definition at line 166 of file User.php.

Referenced by getDBTouched(), and getTouched().

◆ $queryFlagsUsed

int User::$queryFlagsUsed = self::READ_NORMAL
protected

User::READ_* constant bitfield used to load data.

Definition at line 249 of file User.php.

◆ CHECK_USER_RIGHTS

const User::CHECK_USER_RIGHTS = true
Since
1.27

Definition at line 110 of file User.php.

◆ GETOPTIONS_EXCLUDE_DEFAULTS

const User::GETOPTIONS_EXCLUDE_DEFAULTS = UserOptionsLookup::EXCLUDE_DEFAULTS

Exclude user options that are set to their default value.

Deprecated:
since 1.35 Use UserOptionsLookup::EXCLUDE_DEFAULTS
Since
1.25

Definition at line 105 of file User.php.

◆ IGNORE_USER_RIGHTS

const User::IGNORE_USER_RIGHTS = false
Since
1.27

Definition at line 115 of file User.php.

◆ INVALID_TOKEN

const User::INVALID_TOKEN = '*** INVALID ***'

An invalid string value for the user_token field.

Definition at line 92 of file User.php.

Referenced by newSystemUser().

◆ MAINTENANCE_SCRIPT_USER

◆ TOKEN_LENGTH

const User::TOKEN_LENGTH = 32

Number of characters required for the user_token field.

Definition at line 87 of file User.php.

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

◆ VERSION

const User::VERSION = 17
private

Version number to tag cached versions of serialized User objects.

Should be increased when $mCacheVars or one of it's members changes.

Definition at line 98 of file User.php.

Referenced by loadFromCache().


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