MediaWiki  1.23.15
User Class Reference

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

Inheritance diagram for User:
Collaboration diagram for User:

Public Attributes

const EDIT_TOKEN_SUFFIX = EDIT_TOKEN_SUFFIX
 
const MAX_WATCHED_ITEMS_CACHE = 100
 Maximum items in $mWatchedItems. More...
 
const MW_USER_VERSION = MW_USER_VERSION
 
const USER_TOKEN_LENGTH = USER_TOKEN_LENGTH
 Global constants made accessible as class constants so that autoloader magic can be used. More...
 

Static Public Attributes

static $mAllRights = false
 String Cached results of getAllRights() More...
 
static $mCacheVars
 Array of Strings List of member variables which are saved to the shared cache (memcached). More...
 
static $mCoreRights
 Array of Strings Core rights. More...
 

Cache variables

 $mId
 Bool Whether the cache variables have been loaded. More...
 
 $mName
 Bool Whether the cache variables have been loaded. More...
 
 $mRealName
 Bool Whether the cache variables have been loaded. More...
 
 $mPassword
 Bool Whether the cache variables have been loaded. More...
 
 $mNewpassword
 Bool Whether the cache variables have been loaded. More...
 
 $mNewpassTime
 Bool Whether the cache variables have been loaded. More...
 
 $mEmail
 Bool Whether the cache variables have been loaded. More...
 
 $mTouched
 Bool Whether the cache variables have been loaded. More...
 
 $mToken
 Bool Whether the cache variables have been loaded. More...
 
 $mEmailAuthenticated
 Bool Whether the cache variables have been loaded. More...
 
 $mEmailToken
 Bool Whether the cache variables have been loaded. More...
 
 $mEmailTokenExpires
 Bool Whether the cache variables have been loaded. More...
 
 $mRegistration
 Bool Whether the cache variables have been loaded. More...
 
 $mEditCount
 Bool Whether the cache variables have been loaded. More...
 
 $mGroups
 Bool Whether the cache variables have been loaded. More...
 
 $mOptionOverrides
 Bool Whether the cache variables have been loaded. More...
 
 $mOptionsLoaded
 Bool Whether the cache variables have been loaded. More...
 
 $mFrom
 String Initialization data source if mLoadedItems!==true. More...
 
 $mNewtalk
 Lazy-initialized variables, invalidated with clearInstanceCache. More...
 
 $mDatePreference
 Bool Whether the cache variables have been loaded. More...
 
 $mBlockedby
 Bool Whether the cache variables have been loaded. More...
 
 $mHash
 Bool Whether the cache variables have been loaded. More...
 
 $mRights
 Bool Whether the cache variables have been loaded. More...
 
 $mBlockreason
 Bool Whether the cache variables have been loaded. More...
 
 $mEffectiveGroups
 Bool Whether the cache variables have been loaded. More...
 
 $mImplicitGroups
 Bool Whether the cache variables have been loaded. More...
 
 $mFormerGroups
 Bool Whether the cache variables have been loaded. More...
 
 $mBlockedGlobally
 Bool Whether the cache variables have been loaded. More...
 
 $mLocked
 Bool Whether the cache variables have been loaded. More...
 
 $mHideName
 Bool Whether the cache variables have been loaded. More...
 
 $mOptions
 Bool Whether the cache variables have been loaded. More...
 
Block $mBlock
 Bool Whether the cache variables have been loaded. More...
 
bool $mAllowUsertalk
 Bool Whether the cache variables have been loaded. More...
 
static $idCacheByName = array()
 Bool Whether the cache variables have been loaded. More...
 
 $mPasswordExpires
 Bool Whether the cache variables have been loaded. More...
 
 $mLoadedItems = array()
 Array with already loaded items or true if all items have been loaded. More...
 
WebRequest $mRequest
 Bool Whether the cache variables have been loaded. More...
 
Block $mBlockedFromCreateAccount = false
 Bool Whether the cache variables have been loaded. More...
 
Array $mWatchedItems = array()
 Bool Whether the cache variables have been loaded. More...
 
 __construct ()
 Lightweight constructor for an anonymous user. More...
 
 __toString ()
 
 load ()
 Load the user table data for this object from the source given by mFrom. More...
 
 loadFromId ()
 Load user table data, given mId has already been set. More...
 
 saveToCache ()
 Save user data to the shared cache. More...
 

newFrom*() static factory methods

 isValidPassword ( $password)
 Is the input a valid password for this user? More...
 
 getPasswordValidity ( $password)
 Given unvalidated password input, return error message on failure. More...
 
 checkPasswordValidity ( $password)
 Check if this is a valid password for this user. More...
 
 expirePassword ( $ts=0)
 Expire a user's password. More...
 
 resetPasswordExpiration ( $load=true)
 Clear the password expiration for a user. More...
 
 getPasswordExpired ()
 Check if the user's password is expired. More...
 
 getPasswordExpireDate ()
 Get this user's password expiration date. More...
 
 loadDefaults ( $name=false)
 Set cached properties to default. More...
 
 isItemLoaded ( $item, $all='all')
 Return whether an item has been loaded. More...
 
 loadFromDatabase ()
 Load user and user_group data from the database. More...
 
 loadFromRow ( $row, $data=null)
 Initialize this object from a row from the user table. More...
 
 addAutopromoteOnceGroups ( $event)
 Add the user to the group if he/she meets given criteria. More...
 
 clearInstanceCache ( $reloadFrom=false)
 Clear various cached data stored in this object. More...
 
 isDnsBlacklisted ( $ip, $checkWhitelist=false)
 Whether the given IP is in a DNS blacklist. More...
 
 inDnsBlacklist ( $ip, $bases)
 Whether the given IP is in a given DNS blacklist. More...
 
 isPingLimitable ()
 Is this user subject to rate limiting? More...
 
 pingLimiter ( $action='edit', $incrBy=1)
 Primitive rate limits: enforce maximum actions per time period to put a brake on flooding. More...
 
 isBlocked ( $bFromSlave=true)
 Check if user is blocked. More...
 
 getBlock ( $bFromSlave=true)
 Get the block affecting the user, or null if the user is not blocked. More...
 
 isBlockedFrom ( $title, $bFromSlave=false)
 Check if user is blocked from editing a particular article. More...
 
 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...
 
 getBlockId ()
 If user is blocked, return the ID for the block. More...
 
 isBlockedGlobally ( $ip='')
 Check if user is blocked on all wikis. More...
 
 isLocked ()
 Check if user account is locked. More...
 
 isHidden ()
 Check if user account is hidden. More...
 
 getId ()
 Get the user's ID. More...
 
 setId ( $v)
 Set the user and reload all fields according to a given ID. More...
 
 getName ()
 Get the user name, or the IP of an anonymous user. More...
 
 setName ( $str)
 Set the user name. More...
 
 getTitleKey ()
 Get the user's name escaped by underscores. More...
 
 getNewtalk ()
 Check if the user has new messages. More...
 
 getNewMessageLinks ()
 Return the data needed to construct links for new talk page message alerts. More...
 
 getNewMessageRevisionId ()
 Get the revision ID for the last talk page revision viewed by the talk page owner. More...
 
 setNewtalk ( $val, $curRev=null)
 Update the 'You have new messages!' status. More...
 
 invalidateCache ()
 Immediately touch the user data cache for this account. More...
 
 validateCache ( $timestamp)
 Validate the cache for this account. More...
 
 getTouched ()
 Get the user touched timestamp. More...
 
 setPassword ( $str)
 Set the password and reset the random token. More...
 
 setInternalPassword ( $str)
 Set the password and reset the random token unconditionally. More...
 
 getToken ( $forceCreation=true)
 Get the user's current token. More...
 
 setToken ( $token=false)
 Set the random token (used for persistent authentication) Called from loadDefaults() among other places. More...
 
 setNewpassword ( $str, $throttle=true)
 Set the password for a password reminder or new account email. More...
 
 isPasswordReminderThrottled ()
 Has password reminder email been sent within the last $wgPasswordReminderResendTime hours? More...
 
 getEmail ()
 Get the user's e-mail address. More...
 
 getEmailAuthenticationTimestamp ()
 Get the timestamp of the user's e-mail authentication. More...
 
 setEmail ( $str)
 Set the user's e-mail address. More...
 
 setEmailWithConfirmation ( $str)
 Set the user's e-mail address and a confirmation mail if needed. More...
 
 getRealName ()
 Get the user's real name. More...
 
 setRealName ( $str)
 Set the user's real name. More...
 
 getOption ( $oname, $defaultOverride=null, $ignoreHidden=false)
 Get the user's current setting for a given option. More...
 
 getOptions ()
 Get all user's options. More...
 
 getBoolOption ( $oname)
 Get the user's current setting for a given option, as a boolean value. More...
 
 getIntOption ( $oname, $defaultOverride=0)
 Get the user's current setting for a given option, as an integer value. More...
 
 setOption ( $oname, $val)
 Set the given option for a user. More...
 
 getTokenFromOption ( $oname)
 Get a token stored in the preferences (like the watchlist one), resetting it if it's empty (and saving changes). More...
 
 resetTokenFromOption ( $oname)
 Reset a token stored in the preferences (like the watchlist one). More...
 
 getOptionKinds (IContextSource $context, $options=null)
 Return an associative array mapping preferences keys to the kind of a preference they're used for. More...
 
 resetOptions ( $resetKinds=array( 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused'), IContextSource $context=null)
 Reset certain (or all) options to the site defaults. More...
 
 getDatePreference ()
 Get the user's preferred date format. More...
 
 requiresHTTPS ()
 Determine based on the wiki configuration and the user's options, whether this user must be over HTTPS no matter what. More...
 
 getStubThreshold ()
 Get the user preferred stub threshold. More...
 
 getRights ()
 Get the permissions this user has. More...
 
 getGroups ()
 Get the list of explicit group memberships this user has. More...
 
 getEffectiveGroups ( $recache=false)
 Get the list of implicit group memberships this user has. More...
 
 getAutomaticGroups ( $recache=false)
 Get the list of implicit group memberships this user has. More...
 
 getFormerGroups ()
 Returns the groups the user has belonged to. More...
 
 getEditCount ()
 Get the user's edit count. More...
 
 addGroup ( $group)
 Add the user to the given group. More...
 
 removeGroup ( $group)
 Remove the user from the given group. More...
 
 isLoggedIn ()
 Get whether the user is logged in. More...
 
 isAnon ()
 Get whether the user is anonymous. More...
 
 isAllowedAny ()
 Check if user is allowed to access a feature / make an action. More...
 
 isAllowedAll ()
 Is the input a valid password for this user? More...
 
 isAllowed ( $action='')
 Internal mechanics of testing a permission. More...
 
 useRCPatrol ()
 Check whether to enable recent changes patrol features for this user. More...
 
 useNPPatrol ()
 Check whether to enable new pages patrol features for this user. More...
 
 getRequest ()
 Get the WebRequest object to use with this object. More...
 
 getSkin ()
 Get the current skin, loading it if required. More...
 
 getWatchedItem ( $title, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
 Get a WatchedItem for this user and $title. More...
 
 isWatched ( $title, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
 Check the watched status of an article. More...
 
 addWatch ( $title, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
 Watch an article. More...
 
 removeWatch ( $title, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
 Stop watching an article. More...
 
 clearNotification (&$title, $oldid=0)
 Clear the user's notification timestamp for the given title. More...
 
 clearAllNotifications ()
 Resets all of the given user's page-change notification timestamps. More...
 
 setCookies ( $request=null, $secure=null, $rememberMe=false)
 Set the default cookies for this session on the user's client. More...
 
 logout ()
 Log this user out. More...
 
 doLogout ()
 Clear the user's cookies and session, and reset the instance cache. More...
 
 saveSettings ()
 Save this user's settings into the database. More...
 
 idForName ()
 If only this user's username is known, and it exists, return the user ID. More...
 
 addToDatabase ()
 Add this existing user object to the database. More...
 
 spreadAnyEditBlock ()
 If this user is logged-in and blocked, block any IP address they've successfully logged in from. 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...
 
 isAllowedToCreateAccount ()
 Get whether the user is allowed to create an account. More...
 
 getUserPage ()
 Get this user's personal page title. More...
 
 getTalkPage ()
 Get this user's talk page title. More...
 
 isNewbie ()
 Determine whether the user is a newbie. More...
 
 checkPassword ( $password)
 Check to see if the given clear-text password is one of the accepted passwords. More...
 
 checkTemporaryPassword ( $plaintext)
 Check if the given clear-text password matches the temporary password sent by e-mail for password reset operations. More...
 
 editToken ( $salt='', $request=null)
 Alias for getEditToken. 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...
 
 matchEditToken ( $val, $salt='', $request=null)
 Check given value against the token value stored in the session. More...
 
 matchEditTokenNoSuffix ( $val, $salt='', $request=null)
 Check given value against the token value stored in the session, ignoring the suffix. 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...
 
 confirmEmail ()
 Mark the e-mail address confirmed. More...
 
 invalidateEmail ()
 Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already confirmed. More...
 
 setEmailAuthenticationTimestamp ( $timestamp)
 Set the e-mail authentication timestamp. More...
 
 canSendEmail ()
 Is this user allowed to send e-mails within limits of current site configuration? More...
 
 canReceiveEmail ()
 Is this user allowed to receive e-mails within limits of current site configuration? More...
 
 isEmailConfirmed ()
 Is this user's e-mail address valid-looking and confirmed within limits of the current site configuration? More...
 
 isEmailConfirmationPending ()
 Check whether there is an outstanding request for e-mail confirmation. More...
 
 getRegistration ()
 Get the timestamp of account creation. More...
 
 getFirstEditTimestamp ()
 Get the timestamp of the first edit. More...
 
 changeableGroups ()
 Returns an array of groups that this user can add and remove. More...
 
 incEditCount ()
 Increment the user's edit-count field. More...
 
 addNewUserLogEntry ( $action=false, $reason='')
 Add a newuser log entry for this user. More...
 
 addNewUserLogEntryAutoCreate ()
 Add an autocreate newuser log entry for this user Used by things like CentralAuth and perhaps other authplugins. More...
 
static newFromName ( $name, $validate='valid')
 Static factory method for creation from username. More...
 
static newFromId ( $id)
 Static factory method for creation from a given user ID. More...
 
static newFromConfirmationCode ( $code)
 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 or cookies. More...
 
static newFromRow ( $row, $data=null)
 Create a new user object from a user row. 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...
 
static idFromName ( $name)
 Get database id given a user name. More...
 
static resetIdByNameCache ()
 Reset the cache used in idFromName(). More...
 
static isIP ( $name)
 Does the string match an anonymous IPv4 address? More...
 
static isValidUserName ( $name)
 Is the input a valid username? 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 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 isValidEmailAddr ( $addr)
 Does a string look like an e-mail address? More...
 
static getCanonicalName ( $name, $validate='valid')
 Given unvalidated user input, return a canonical username, or false if the username is invalid. More...
 
static edits ( $uid)
 Count the number of edits of a user. More...
 
static randomPassword ()
 Return a random password. More...
 
static getDefaultOptions ()
 Combine the language default options with any site-specific options and add the default language variants. More...
 
static getDefaultOption ( $opt)
 Get a given default option value. More...
 
static isLocallyBlockedProxy ( $ip)
 Check if an IP address is in the local proxy list. More...
 
static listOptionKinds ()
 Return a list of the types of user options currently returned by User::getOptionKinds(). More...
 
static createNew ( $name, $params=array())
 Add a user to the database, return the user object. More...
 
static generateToken ()
 Generate a looking random token for various uses. 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 groupHasPermission ( $group, $role)
 Check, if the given group has the given permission. More...
 
static isEveryoneAllowed ( $right)
 Check if all users have the given permission. More...
 
static getGroupName ( $group)
 Get the localized descriptive name for a group, if it exists. More...
 
static getGroupMember ( $group, $username='#')
 Get the localized descriptive name for a member of a group, if it exists. More...
 
static getAllGroups ()
 Return the set of defined explicit groups. More...
 
static getAllRights ()
 Get a list of all available permissions. More...
 
static getImplicitGroups ()
 Get a list of implicit groups. More...
 
static getGroupPage ( $group)
 Get the title of a page describing a particular group. More...
 
static makeGroupLinkHTML ( $group, $text='')
 Create a link to the group in HTML, if available; else return the group name. More...
 
static makeGroupLinkWiki ( $group, $text='')
 Create a link to the group in Wikitext, if available; else return the group name. More...
 
static changeableByGroup ( $group)
 Returns an array of the groups that a particular group can add/remove. More...
 
static getRightDescription ( $right)
 Get the description of a given right. More...
 
static oldCrypt ( $password, $userId)
 Make an old-style password hash. More...
 
static crypt ( $password, $salt=false)
 Make a new-style password hash. More...
 
static comparePasswords ( $hash, $password, $userId=false)
 Compare a password hash with a plain-text password. More...
 
static passwordChangeInputAttribs ()
 Provide an array of HTML5 attributes to put on an input element intended for the user to enter a new password. More...
 
static selectFields ()
 Return the list of user fields that should be selected to create a new user object. More...
 
static newFatalPermissionDeniedStatus ( $permission)
 Factory function for fatal permission-denied errors. More...
 
 setItemLoaded ( $item)
 Set that an item has been loaded. More...
 
 compareSecrets ( $answer, $test)
 A comparison of two strings, not vulnerable to timing attacks. More...
 
 loadFromUserObject ( $user)
 Load the data for this user object from another user object. More...
 
 checkNewtalk ( $field, $id, $fromMaster=false)
 Internal uncached check for new messages. More...
 
 updateNewtalk ( $field, $id, $curRev=null)
 Add or update the new messages flag. More...
 
 deleteNewtalk ( $field, $id)
 Clear the new messages flag for the given user. More...
 
 setCookie ( $name, $value, $exp=0, $secure=null, $params=array())
 Set a cookie on the user's client. More...
 
 clearCookie ( $name, $secure=null, $params=array())
 Clear a cookie on the user's client. More...
 
 spreadBlock ()
 If this (non-anonymous) user is blocked, block the IP address they've successfully logged in from. More...
 
 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...
 
 invalidationTokenUrl ( $token)
 Return a URL the user can use to invalidate their email address. More...
 
 getTokenUrl ( $page, $token)
 Internal function to format the e-mail validation/invalidation URLs. More...
 
 initEditCount ( $add=0)
 Initialize user_editcount from data out of the revision table. More...
 
 loadOptions ( $data=null)
 Load the user options either from cache, the database or an array. More...
 
 saveOptions ()
 
 loadFromSession ()
 Load user data from the session or login cookie. More...
 
 loadGroups ()
 Load the groups from the database if they aren't already loaded. More...
 
 getBlockedStatus ( $bFromSlave=true)
 Get blocking information. More...
 
 clearSharedCache ()
 Clear user data from memcached. More...
 
static newTouchedTimestamp ()
 Generate a current or new-future timestamp to be stored in the user_touched field when we update things. More...
 

Detailed Description

The User object encapsulates all of the user-specific settings (user_id, name, rights, password, 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.

Definition at line 59 of file User.php.

Constructor & Destructor Documentation

◆ __construct()

User::__construct ( )

Lightweight constructor for an anonymous user.

Use the User::newFrom* factory functions for other kinds of users.

See also
newFromName()
newFromId()
newFromConfirmationCode()
newFromSession()
newFromRow()

Definition at line 256 of file User.php.

References clearInstanceCache().

Member Function Documentation

◆ __toString()

User::__toString ( )
Returns
string

Definition at line 263 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 $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
array Array of groups the user has been promoted to.
See also
$wgAutopromoteOnce

Definition at line 1284 of file User.php.

References addGroup(), array(), as, Autopromote\getAutopromoteOnceGroups(), getGroups(), getId(), getUserPage(), and global.

◆ addGroup()

User::addGroup (   $group)

Add the user to the given group.

This takes immediate effect.

Parameters
string$groupName of the group to add

Definition at line 2931 of file User.php.

References array(), DB_MASTER, getEffectiveGroups(), getId(), invalidateCache(), loadGroups(), wfGetDB(), and wfRunHooks().

Referenced by addAutopromoteOnceGroups().

◆ addNewUserLogEntry()

User::addNewUserLogEntry (   $action = false,
  $reason = '' 
)

Add a newuser log entry for this user.

Before 1.19 the return value was always true.

Parameters
string | bool$actionaccount creation type.
  • String, one of the following values:
    • 'create' for an anonymous user creating an account for himself. This will force the action's performer to be the created user itself, no matter the value of $wgUser
    • 'create2' for a logged in user creating an account for someone else
    • 'byemail' when the created user will receive its password by e-mail
    • 'autocreate' when the user is automatically created (such as by CentralAuth).
  • Boolean means whether the account was created by e-mail (deprecated):
    • true will be converted to 'byemail'
    • false will be converted to 'create' if this object is the same as $wgUser and to 'create2' otherwise
string$reasonuser supplied reason
Returns
int|bool True if not $wgNewUserLog; otherwise ID of log item or 0 on failure

Definition at line 4614 of file User.php.

References $wgUser, array(), getId(), getName(), getUserPage(), and global.

Referenced by addNewUserLogEntryAutoCreate().

◆ addNewUserLogEntryAutoCreate()

User::addNewUserLogEntryAutoCreate ( )

Add an autocreate newuser log entry for this user Used by things like CentralAuth and perhaps other authplugins.

Consider calling addNewUserLogEntry() directly instead.

Returns
bool

Definition at line 4659 of file User.php.

References addNewUserLogEntry().

◆ 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->isLoggedIn() ) { $user->addToDatabase(); } // do something with $user...

However, this was vulnerable to a race condition (bug 16020). 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 isLoggedIn(), and to commit the transaction after calling.

Exceptions
MWException
Returns
Status

Definition at line 3540 of file User.php.

References $mEmail, $mRealName, array(), clearInstanceCache(), DB_MASTER, load(), loadFromDatabase(), Status\newFatal(), Status\newGood(), newTouchedTimestamp(), saveOptions(), setToken(), and wfGetDB().

Referenced by UserTest\testEditCount(), and UserTest\testOptions().

◆ addWatch()

User::addWatch (   $title,
  $checkRights = WatchedItem::CHECK_USER_RIGHTS 
)

Watch an article.

Since
1.22 $checkRights parameter added
Parameters
$titleTitle of the article to look at
$checkRightsint Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS.

Definition at line 3151 of file User.php.

References $title, getWatchedItem(), and invalidateCache().

◆ 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 1766 of file User.php.

References $mBlockedby, and getBlockedStatus().

Referenced by SpecialBlock\checkUnblockSelf().

◆ blockedFor()

User::blockedFor ( )

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

Returns
string Blocking reason

Definition at line 1775 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 4027 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 4012 of file User.php.

References array(), global, isAllowed(), isEmailConfirmed(), and wfRunHooks().

◆ 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 array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ), 'add-self' => array( addablegroups to self), 'remove-self' => array( removable groups from self) )

Definition at line 4344 of file User.php.

References $value, array(), as, getAllGroups(), and global.

Referenced by changeableGroups().

◆ changeableGroups()

User::changeableGroups ( )

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

Returns
Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ), 'add-self' => array( addablegroups to self), 'remove-self' => array( removable groups from self) )

Definition at line 4408 of file User.php.

References array(), as, changeableByGroup(), getAllGroups(), getEffectiveGroups(), and isAllowed().

◆ checkNewtalk()

User::checkNewtalk (   $field,
  $id,
  $fromMaster = false 
)
protected

Internal uncached check for new messages.

See also
getNewtalk()
Parameters
string$field'user_ip' for anonymous users, 'user_id' otherwise
string | int$idUser's IP address for anonymous users, User ID otherwise
bool$fromMastertrue to fetch from the master, false for a slave
Returns
bool True if the user has new messages

Definition at line 2018 of file User.php.

References $ok, array(), DB_MASTER, DB_SLAVE, and wfGetDB().

Referenced by getNewtalk().

◆ checkPassword()

User::checkPassword (   $password)

Check to see if the given clear-text password is one of the accepted passwords.

Parameters
string$passworduser password.
Returns
boolean: True if the given password is correct, otherwise False.

Definition at line 3701 of file User.php.

References $password, global, and load().

◆ checkPasswordValidity()

User::checkPasswordValidity (   $password)

Check if this is a valid password for this user.

Status will be good if the password is valid, or have an array of error messages if not.

Parameters
string$passwordDesired password
Returns
Status
Since
1.23

Definition at line 730 of file User.php.

References $password, $wgContLang, array(), getName(), global, Status\newGood(), and wfRunHooks().

Referenced by getPasswordValidity(), and UserTest\testCheckPasswordValidity().

◆ checkTemporaryPassword()

User::checkTemporaryPassword (   $plaintext)

Check if the given clear-text password matches the temporary password sent by e-mail for password reset operations.

Parameters
$plaintextstring
Returns
boolean: True if matches, false otherwise

Definition at line 3741 of file User.php.

References getId(), global, load(), TS_UNIX, and wfTimestamp().

◆ clearAllNotifications()

User::clearAllNotifications ( )

Resets all of the given user's page-change notification timestamps.

If e-notif e-mails are on, they will receive notification mails on the next change of any watched page.

Note
If the user doesn't have 'editmywatchlist', this will do nothing.

Definition at line 3237 of file User.php.

References $wgUseEnotif, array(), DB_MASTER, getId(), global, isAllowed(), setNewtalk(), wfGetDB(), and wfReadOnly().

◆ clearCookie()

User::clearCookie (   $name,
  $secure = null,
  $params = array() 
)
protected

Clear a cookie on the user's client.

Parameters
string$nameName of the cookie to clear
bool$securetrue: Force setting the secure attribute when setting the cookie false: Force NOT setting the secure attribute when setting the cookie null (default): Use the default ($wgCookieSecure) to set the secure attribute
array$paramsArray of options sent passed to WebResponse::setcookie()

Definition at line 3292 of file User.php.

References $name, $params, and setCookie().

Referenced by doLogout(), and setCookies().

◆ 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", "defaults", "session", or false for no reload.

Definition at line 1325 of file User.php.

References array().

Referenced by __construct(), addToDatabase(), doLogout(), setId(), and UserTest\testEditCount().

◆ clearNotification()

User::clearNotification ( $title,
  $oldid = 0 
)

Clear the user's notification timestamp for the given title.

If e-notif e-mails are on, they will receive notification mails on the next change of the page if it's watched etc.

Note
If the user doesn't have 'editmywatchlist', this will do nothing.
Parameters
$titleTitle of the article to look at
int$oldidThe revision id being viewed. If not given or 0, latest revision is assumed.

Definition at line 3176 of file User.php.

References $title, $wgUseEnotif, array(), getName(), getNewtalk(), getWatchedItem(), global, isAllowed(), isAnon(), Revision\newFromId(), NS_USER_TALK, setNewtalk(), wfReadOnly(), and wfRunHooks().

◆ clearSharedCache()

User::clearSharedCache ( )
private

Clear user data from memcached.

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

Called implicitly from invalidateCache() and saveSettings().

Definition at line 2131 of file User.php.

References $wgMemc, global, load(), and wfMemcKey().

Referenced by invalidateCache(), and saveSettings().

◆ comparePasswords()

static User::comparePasswords (   $hash,
  $password,
  $userId = false 
)
static

Compare a password hash with a plain-text password.

Requires the user ID if there's a chance that the hash is an old-style hash.

Parameters
string$hashPassword hash
string$passwordPlain-text password to compare
string | bool$userIdUser ID for old-style password salt
Returns
boolean

Definition at line 4572 of file User.php.

References $hash, $password, $type, array(), list, oldCrypt(), and wfRunHooks().

◆ compareSecrets()

User::compareSecrets (   $answer,
  $test 
)
protected

A comparison of two strings, not vulnerable to timing attacks.

Parameters
string$answerthe secret string that you are comparing against.
string$testcompare this string to the $answer.
Returns
bool True if the strings are the same, false otherwise

Definition at line 1115 of file User.php.

References $test.

Referenced by loadFromSession().

◆ 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
&$expiration\mixed Accepts the expiration time
Returns
string New token

Definition at line 3913 of file User.php.

References $hash, MWCryptRand\generateHex(), global, load(), TS_MW, 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 3931 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 3971 of file User.php.

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

◆ createNew()

static User::createNew (   $name,
  $params = array() 
)
static

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

Parameters
string$nameUsername to add
array$paramsof Strings Non-default parameters to save to the database as user_* fields:
  • password The user's password hash. Password logins will be disabled if this is omitted.
  • newpassword Hash for a temporary password that has been mailed to the user
  • 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 object, or null if the username already exists

Definition at line 3477 of file User.php.

References $name, $params, $user, $value, array(), as, DB_MASTER, newFromId(), User, and wfGetDB().

Referenced by UserWrapper\__construct(), TestUser\__construct(), TitlePermissionTest\setUp(), and RevisionStorageTest\testUserWasLastToEdit().

◆ crypt()

static User::crypt (   $password,
  $salt = false 
)
static

Make a new-style password hash.

Parameters
string$passwordPlain-text password
bool | string$saltOptional salt, may be random or the user ID. If unspecified or false, will generate one automatically
Returns
string Password hash

Definition at line 4544 of file User.php.

References $hash, $password, array(), MWCryptRand\generateHex(), global, and wfRunHooks().

Referenced by setInternalPassword(), and setNewpassword().

◆ deleteNewtalk()

User::deleteNewtalk (   $field,
  $id 
)
protected

Clear the new messages flag for the given user.

Parameters
string$field'user_ip' for anonymous users, 'user_id' otherwise
string | int$idUser's IP address for anonymous users, User ID otherwise
Returns
bool True if successful, false otherwise

Definition at line 2061 of file User.php.

References array(), DB_MASTER, wfDebug(), and wfGetDB().

Referenced by setNewtalk().

◆ doLogout()

User::doLogout ( )

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

See also
logout()

Definition at line 3380 of file User.php.

References array(), clearCookie(), clearInstanceCache(), getRequest(), setCookie(), and wfResetSessionID().

Referenced by logout().

◆ edits()

static User::edits (   $uid)
static

Count the number of edits of a user.

Parameters
int$uidUser ID to check
Returns
int The user's edit count
Deprecated:
since 1.21 in favour of User::getEditCount

Definition at line 940 of file User.php.

References $user, newFromId(), and wfDeprecated().

◆ editToken()

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

Alias for getEditToken.

Deprecated:
since 1.19, use getEditToken instead.
Parameters
string | array$saltof Strings Optional function-specific data for hashing
$requestWebRequest object to use or null to use $wgRequest
Returns
string The new edit token

Definition at line 3764 of file User.php.

References $request, getEditToken(), and wfDeprecated().

◆ expirePassword()

User::expirePassword (   $ts = 0)

Expire a user's password.

Since
1.23
Parameters
$tsMixed: optional timestamp to convert, default 0 for the current time

Definition at line 777 of file User.php.

References $timestamp, load(), saveSettings(), TS_MW, and wfTimestamp().

Referenced by UserTest\testPasswordExpire().

◆ generateToken()

static User::generateToken ( )
static

Generate a looking random token for various uses.

Returns
string The new random token
Deprecated:
since 1.20: Use MWCryptRand for secure purposes or wfRandomString for pseudo-randomness

Definition at line 3807 of file User.php.

References MWCryptRand\generateHex().

◆ 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.

Returns
Array of internal group names

Definition at line 4241 of file User.php.

References global.

Referenced by UsersPager\__construct(), changeableByGroup(), changeableGroups(), ApiQueryAllUsers\execute(), UsersPager\getAllGroups(), UserrightsPage\getAllGroups(), ApiUserrights\getAllowedParams(), ApiQueryContributors\getAllowedParams(), and ApiQueryAllUsers\getAllowedParams().

◆ getAllRights()

static User::getAllRights ( )
static

Get a list of all available permissions.

Returns
Array of permission names

Definition at line 4253 of file User.php.

References $mAllRights, $mCoreRights, array(), global, and wfRunHooks().

Referenced by ApiQueryContributors\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), and UserTest\testAllRightsWithMessage().

◆ 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

Parameters
bool$recacheWhether to avoid the cache
Returns
Array of String internal group names

Definition at line 2850 of file User.php.

References $mImplicitGroups, array(), Autopromote\getAutopromoteGroups(), getId(), wfProfileIn(), and wfProfileOut().

Referenced by getEffectiveGroups().

◆ getBlock()

User::getBlock (   $bFromSlave = true)

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

Parameters
bool$bFromSlaveWhether to check the slave database instead of the master
Returns
Block|null

Definition at line 1731 of file User.php.

References getBlockedStatus().

Referenced by isBlocked().

◆ getBlockedStatus()

User::getBlockedStatus (   $bFromSlave = true)
private

Get blocking information.

Parameters
bool$bFromSlaveWhether to check the slave database first. To improve performance, non-critical checks are done against slaves. Check when actually saving should be done against master.

Definition at line 1399 of file User.php.

References $wgUser, array(), Block\chooseBlock(), Block\getBlocksForIPList(), getRequest(), global, isAllowed(), isAnon(), isDnsBlacklisted(), load(), Block\newFromTarget(), Block\setBlocker(), text, wfDebug(), wfMessage(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

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

◆ getBlockId()

User::getBlockId ( )

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

Returns
int Block ID

Definition at line 1784 of file User.php.

References false, and 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()

Definition at line 2477 of file User.php.

References getOption().

Referenced by requiresHTTPS().

◆ getCanonicalName()

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

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

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
MWException
Returns
bool|string

Definition at line 884 of file User.php.

References $name, $t, $wgContLang, global, isCreatableName(), isUsableName(), isValidUserName(), Title\makeTitle(), Title\newFromText(), and NS_USER.

Referenced by LoginForm\clearLoginThrottle(), RollbackEdits\execute(), UserrightsPage\execute(), ApiQueryUsers\execute(), UserrightsPage\fetchUser(), ApiRollback\getRbUser(), LoginForm\incLoginThrottle(), newFromName(), ApiQueryContributions\prepareUsername(), and ApiQueryBlocks\prepareUsername().

◆ getDatePreference()

User::getDatePreference ( )

Get the user's preferred date format.

Returns
string User's preferred date format

Definition at line 2729 of file User.php.

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

Referenced by Language\getHumanTimestamp().

◆ getDefaultOption()

static User::getDefaultOption (   $opt)
static

Get a given default option value.

Parameters
string$optName of option to retrieve
Returns
string Default option value

Definition at line 1383 of file User.php.

References getDefaultOptions().

Referenced by ConvertUserOptions\convertOptionBatch(), Language\dateFormat(), CoreParserFunctions\gender(), GenderCache\getDefault(), ImagePage\getImageLimitsFromOption(), getOption(), getOptions(), Linker\makeImageLink(), saveOptions(), and setOption().

◆ getDefaultOptions()

static User::getDefaultOptions ( )
static

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

Returns
Array of String options

Definition at line 1350 of file User.php.

References $wgContLang, array(), as, global, SearchEngine\searchableNamespaces(), and wfRunHooks().

Referenced by getDefaultOption(), UserOptions\getDefaultOptionsNames(), Preferences\getPreferences(), UserOptions\LISTER(), loadOptions(), resetOptions(), and UserOptions\USAGER().

◆ getEditCount()

User::getEditCount ( )

Get the user's edit count.

Returns
int, null for anonymous users

Definition at line 2900 of file User.php.

References $count, $dbr, $mEditCount, array(), DB_SLAVE, getId(), initEditCount(), wfGetDB(), wfProfileIn(), and wfProfileOut().

Referenced by loadFromDatabase(), and UserTest\testEditCount().

◆ 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.

Since
1.19
Parameters
string | array$saltof Strings Optional function-specific data for hashing
$requestWebRequest object to use or null to use $wgRequest
Returns
string The new edit token

Definition at line 3781 of file User.php.

References $request, EDIT_TOKEN_SUFFIX, MWCryptRand\generateHex(), getRequest(), and isAnon().

Referenced by editToken(), matchEditToken(), and matchEditTokenNoSuffix().

◆ 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

Parameters
bool$recacheWhether to avoid the cache
Returns
Array of String internal group names

Definition at line 2827 of file User.php.

References $mEffectiveGroups, array(), getAutomaticGroups(), getGroups(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Referenced by addGroup(), changeableGroups(), getRights(), and removeGroup().

◆ getEmail()

User::getEmail ( )

Get the user's e-mail address.

Returns
string User's email address

Definition at line 2328 of file User.php.

References $mEmail, array(), load(), and wfRunHooks().

Referenced by SpecialPasswordReset\onSubmit(), and setEmailWithConfirmation().

◆ getEmailAuthenticationTimestamp()

User::getEmailAuthenticationTimestamp ( )

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

Returns
string TS_MW timestamp

Definition at line 2338 of file User.php.

References $mEmailAuthenticated, array(), load(), and wfRunHooks().

Referenced by isEmailConfirmed().

◆ getFirstEditTimestamp()

User::getFirstEditTimestamp ( )

Get the timestamp of the first edit.

Returns
string|bool Timestamp of first edit, or false for non-existent/anonymous user accounts.

Definition at line 4094 of file User.php.

References $dbr, $time, array(), DB_SLAVE, getId(), TS_MW, wfGetDB(), and wfTimestamp().

◆ 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

Returns
array Names of the groups the user has belonged to.

Definition at line 2881 of file User.php.

References $dbr, $mFormerGroups, $res, array(), as, DB_MASTER, and wfGetDB().

◆ getGroupMember()

static User::getGroupMember (   $group,
  $username = '#' 
)
static

Get the localized descriptive name for a member of a group, if it exists.

Parameters
string$groupInternal group name
string$usernameUsername for gender (since 1.19)
Returns
string Localized name for group member

Definition at line 4230 of file User.php.

References wfMessage().

Referenced by UsersPager\buildGroupLink(), UserrightsPage\buildGroupMemberLink(), RightsLogFormatter\getMessageParameters(), UserrightsPage\groupCheckboxes(), and Preferences\profilePreferences().

◆ getGroupName()

static User::getGroupName (   $group)
static

Get the localized descriptive name for a group, if it exists.

Parameters
string$groupInternal group name
Returns
string Localized descriptive group name

Definition at line 4218 of file User.php.

References wfMessage().

Referenced by UserrightsPage\buildGroupLink(), UsersPager\getAllGroups(), makeGroupLinkHTML(), makeGroupLinkWiki(), and Preferences\profilePreferences().

◆ getGroupPage()

static User::getGroupPage (   $group)
static

Get the title of a page describing a particular group.

Parameters
string$groupInternal group name
Returns
Title|bool Title of the page if it exists, false otherwise

Definition at line 4283 of file User.php.

References $title, Title\newFromText(), and wfMessage().

Referenced by makeGroupLinkHTML(), and makeGroupLinkWiki().

◆ getGroupPermissions()

static User::getGroupPermissions (   $groups)
static

Get the permissions associated with a given list of groups.

Parameters
array$groupsof Strings List of internal group names
Returns
Array of Strings List of permission key names for given groups combined

Definition at line 4116 of file User.php.

References array(), as, and global.

Referenced by Autopromote\checkCondition(), ApiQueryAllUsers\execute(), getRights(), UserTest\testGroupPermissions(), UserTest\testRevokePermissions(), and wfStreamThumb().

◆ getGroups()

User::getGroups ( )

Get the list of explicit group memberships this user has.

The implicit * and user groups are not included.

Returns
Array of String internal group names

Definition at line 2814 of file User.php.

References $mGroups, load(), and loadGroups().

Referenced by addAutopromoteOnceGroups(), getEffectiveGroups(), and pingLimiter().

◆ getGroupsWithPermission()

static User::getGroupsWithPermission (   $role)
static

◆ getId()

◆ getImplicitGroups()

static User::getImplicitGroups ( )
static

Get a list of implicit groups.

Returns
Array of Strings Array of internal group names

Definition at line 4270 of file User.php.

References array(), global, and wfRunHooks().

Referenced by UsersPager\getGroups().

◆ 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()

Definition at line 2489 of file User.php.

References getOption().

Referenced by getStubThreshold().

◆ getName()

◆ getNewMessageLinks()

User::getNewMessageLinks ( )

Return the data needed to construct links for new talk page message alerts.

If there are new messages, this will return an associative array with the following data: wiki: The database name of the wiki link: Root-relative link to the user's talk page rev: The last talk page revision that the user has seen or null. This is useful for building diff links. If there are no new messages, it returns an empty array.

Note
This function was designed to accomodate multiple talk pages, but currently only returns a single link and revision.
Returns
Array

Definition at line 1968 of file User.php.

References $dbr, $rev, $timestamp, array(), DB_SLAVE, getName(), getNewtalk(), getTalkPage(), isAnon(), Revision\loadFromTimestamp(), wfGetDB(), wfRunHooks(), and wfWikiID().

Referenced by getNewMessageRevisionId().

◆ getNewMessageRevisionId()

User::getNewMessageRevisionId ( )

Get the revision ID for the last talk page revision viewed by the talk page owner.

Returns
int|null Revision ID or null

Definition at line 1991 of file User.php.

References getNewMessageLinks(), and wfWikiID().

◆ getNewtalk()

User::getNewtalk ( )

Check if the user has new messages.

Returns
bool True if the user has new messages

Definition at line 1920 of file User.php.

References $mNewtalk, $wgMemc, checkNewtalk(), getName(), global, load(), page, and wfMemcKey().

Referenced by clearNotification(), and getNewMessageLinks().

◆ getOption()

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

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

Parameters
string$onameThe option to check
string$defaultOverrideA default value returned if the option does not exist
bool$ignoreHiddenWhether to ignore the effects of $wgHiddenPrefs
Returns
string User's current value for the option
See also
getBoolOption()
getIntOption()

Reimplemented in PPFuzzUser.

Definition at line 2425 of file User.php.

References getDefaultOption(), global, and loadOptions().

Referenced by canReceiveEmail(), getBoolOption(), getDatePreference(), getIntOption(), RequestContext\getLanguage(), getTokenFromOption(), SpecialPasswordReset\onSubmit(), and UserTest\testOptions().

◆ 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 User::listOptionKinds for the list of valid option types that can be provided.

See also
User::listOptionKinds
Parameters
$contextIContextSource
array$optionsassoc. array with options keys to check as keys. Defaults to $this->mOptions.
Returns
array the key => kind mapping data

Definition at line 2602 of file User.php.

References $columns, $mOptions, $name, $options, $value, array(), as, HTMLFormField\flattenOptions(), Preferences\getPreferences(), Preferences\getSaveBlacklist(), and loadOptions().

Referenced by resetOptions().

◆ getOptions()

User::getOptions ( )

Get all user's options.

Returns
array

Definition at line 2450 of file User.php.

References $mOptions, $options, as, getDefaultOption(), global, and loadOptions().

◆ getPasswordExpired()

User::getPasswordExpired ( )

Check if the user's password is expired.

TODO: Put this and password length into a PasswordPolicy object

Since
1.23
Returns
string|bool The expiration type, or false if not expired hard: A password change is required to login soft: Allow login, but encourage password change false: Password is not expired

Definition at line 815 of file User.php.

References getPasswordExpireDate(), global, TS_UNIX, and wfTimestamp().

Referenced by UserTest\testPasswordExpire().

◆ getPasswordExpireDate()

User::getPasswordExpireDate ( )

Get this user's password expiration date.

Since this may be using the cached User object, we assume that whatever mechanism is setting the expiration date is also expiring the User cache.

Since
1.23
Returns
string|false the datestamp of the expiration, or null if not set

Definition at line 834 of file User.php.

References $mPasswordExpires, and load().

Referenced by getPasswordExpired().

◆ getPasswordValidity()

User::getPasswordValidity (   $password)

Given unvalidated password input, return error message on failure.

Parameters
string$passwordDesired password
Returns
mixed: true on success, string or array of error message on failure

Definition at line 703 of file User.php.

References $error, $messages, $password, array(), as, and checkPasswordValidity().

Referenced by isValidPassword(), setPassword(), and UserTest\testCheckPasswordValidity().

◆ getRealName()

User::getRealName ( )

Get the user's real name.

Returns
string User's real name

Definition at line 2398 of file User.php.

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

◆ 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 4080 of file User.php.

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

◆ getRequest()

◆ getRightDescription()

static User::getRightDescription (   $right)
static

Get the description of a given right.

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

Definition at line 4514 of file User.php.

References $right, and wfMessage().

Referenced by SpecialListGroupRights\formatPermissions(), and SpecialListGroupRights\outputNamespaceProtectionInfo().

◆ getRights()

User::getRights ( )

Get the permissions this user has.

Returns
Array of String permission names

Definition at line 2783 of file User.php.

References $mRights, array(), getEffectiveGroups(), getGroupPermissions(), RequestContext\getMain(), isBlocked(), isLoggedIn(), User, and wfRunHooks().

Referenced by isAllowed().

◆ getSkin()

User::getSkin ( )

Get the current skin, loading it if required.

Returns
Skin The current skin
Todo:
FIXME: Need to check the old failback system [AV]
Deprecated:
since 1.18 Use ->getSkin() in the most relevant outputting context you have

Definition at line 3103 of file User.php.

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

◆ getStubThreshold()

User::getStubThreshold ( )

Get the user preferred stub threshold.

Returns
int

Definition at line 2768 of file User.php.

References article, getIntOption(), global, and in.

◆ getTalkPage()

User::getTalkPage ( )

Get this user's talk page title.

Returns
Title: User's talk page title

Definition at line 3682 of file User.php.

References $title, and getUserPage().

Referenced by getNewMessageLinks().

◆ getTitleKey()

User::getTitleKey ( )

Get the user's name escaped by underscores.

Returns
string Username escaped by underscores.

Definition at line 1912 of file User.php.

References getName().

◆ 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 Token

Definition at line 2265 of file User.php.

References $mToken, load(), and setToken().

◆ 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()

Definition at line 2523 of file User.php.

References getOption(), global, resetTokenFromOption(), and saveSettings().

◆ 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 (bug 6957 with Gmail and Internet Explorer).
Parameters
string$pageSpecial page
string$tokenToken
Returns
string Formatted URL

Definition at line 3958 of file User.php.

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

Referenced by confirmationTokenUrl(), and invalidationTokenUrl().

◆ getTouched()

User::getTouched ( )

Get the user touched timestamp.

Returns
string timestamp

Definition at line 2187 of file User.php.

References $mTouched, and load().

◆ getUserPage()

User::getUserPage ( )

Get this user's personal page title.

Returns
Title: User's personal page title

Definition at line 3673 of file User.php.

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

Referenced by addAutopromoteOnceGroups(), addNewUserLogEntry(), Block\getPermissionsError(), getTalkPage(), and saveSettings().

◆ getWatchedItem()

User::getWatchedItem (   $title,
  $checkRights = WatchedItem::CHECK_USER_RIGHTS 
)

Get a WatchedItem for this user and $title.

Since
1.22 $checkRights parameter added
Parameters
$titleTitle
$checkRightsint Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS.
Returns
WatchedItem

Definition at line 3117 of file User.php.

References $title, array(), and WatchedItem\fromUserTitle().

Referenced by addWatch(), clearNotification(), isWatched(), and removeWatch().

◆ 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 User::isEveryoneAllowed() instead. That properly checks if it's revoked from anyone.

Since
1.21
Parameters
string$groupGroup to check
string$roleRole to check
Returns
bool

Definition at line 4166 of file User.php.

References global.

Referenced by Title\checkQuickPermissions(), SpecialNewpages\filterLinks(), NewPagesPager\getQueryInfo(), SpecialPage\isRestricted(), and OutputPage\showPermissionsErrorPage().

◆ idForName()

User::idForName ( )

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

Returns
int

Definition at line 3447 of file User.php.

References $dbr, $s, array(), DB_SLAVE, getName(), and wfGetDB().

◆ idFromName()

static User::idFromName (   $name)
static

Get database id given a user name.

Parameters
string$nameUsername
Returns
int|null The corresponding user's ID, or null if user is nonexistent

Definition at line 503 of file User.php.

References $dbr, $name, $s, array(), DB_SLAVE, Title\makeTitleSafe(), NS_USER, and wfGetDB().

Referenced by ApiQueryLogEvents\execute(), UsersPager\getQueryInfo(), LogPage\getTitleLink(), ContribsPager\getUserCond(), WikiRevision\importLogItem(), LogPager\limitPerformer(), load(), and SpecialUnblock\processUnblock().

◆ incEditCount()

User::incEditCount ( )

Increment the user's edit-count field.

Will have no effect for anonymous users.

Definition at line 4448 of file User.php.

References $dbr, array(), DB_MASTER, DB_SLAVE, getId(), initEditCount(), invalidateCache(), isAnon(), and wfGetDB().

Referenced by UserTest\testEditCount().

◆ inDnsBlacklist()

User::inDnsBlacklist (   $ip,
  $bases 
)

Whether the given IP is in a given DNS blacklist.

Parameters
string$ipIP to check
string | array$basesof Strings: URL of the DNS blacklist
Returns
bool True if blacklisted.

Definition at line 1514 of file User.php.

References array(), as, IP\isIPv4(), wfDebugLog(), wfProfileIn(), and wfProfileOut().

Referenced by isDnsBlacklisted().

◆ initEditCount()

User::initEditCount (   $add = 0)
protected

Initialize user_editcount from data out of the revision table.

Parameters
$addInteger Edits to add to the count from the revision table
Returns
integer Number of edits

Definition at line 4485 of file User.php.

References $count, $dbr, array(), DB_MASTER, DB_SLAVE, getId(), and wfGetDB().

Referenced by getEditCount(), and incEditCount().

◆ invalidateCache()

User::invalidateCache ( )

Immediately touch the user data cache for this account.

Updates user_touched field, and removes account data from memcached for reload on the next hit.

Definition at line 2144 of file User.php.

References $mId, $mTouched, array(), clearSharedCache(), DB_MASTER, load(), newTouchedTimestamp(), wfGetDB(), and wfReadOnly().

Referenced by addGroup(), addWatch(), incEditCount(), removeGroup(), removeWatch(), and setNewtalk().

◆ 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 3988 of file User.php.

References array(), load(), setEmailAuthenticationTimestamp(), and wfRunHooks().

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 3940 of file User.php.

References getTokenUrl().

Referenced by sendConfirmationMail().

◆ isAllowed()

◆ isAllowedAll()

User::isAllowedAll ( )

Is the input a valid password for this user?

Parameters
string$passwordDesired password
Returns
bool

Definition at line 3031 of file User.php.

References as, and isAllowed().

◆ isAllowedAny()

User::isAllowedAny ( )

Check if user is allowed to access a feature / make an action.

Definition at line 3016 of file User.php.

References as, and isAllowed().

Referenced by WikiPage\commitRollback(), useNPPatrol(), and useRCPatrol().

◆ isAllowedToCreateAccount()

User::isAllowedToCreateAccount ( )

Get whether the user is allowed to create an account.

Returns
bool

Definition at line 3664 of file User.php.

References isAllowed(), and isBlockedFromCreateAccount().

◆ isAnon()

User::isAnon ( )

Get whether the user is anonymous.

Returns
bool

Definition at line 3004 of file User.php.

References isLoggedIn().

Referenced by clearNotification(), getBlockedStatus(), getEditToken(), getNewMessageLinks(), getRegistration(), incEditCount(), isEmailConfirmed(), saveToCache(), and setNewtalk().

◆ isBlocked()

User::isBlocked (   $bFromSlave = true)

Check if user is blocked.

Parameters
bool$bFromSlaveWhether to check the slave database instead of the master
Returns
bool True if blocked, false otherwise

Definition at line 1721 of file User.php.

References getBlock().

Referenced by Action\checkCanExecute(), FormSpecialPage\checkExecutePermissions(), SpecialBlock\checkUnblockSelf(), getRights(), isBlockedFrom(), and spreadAnyEditBlock().

◆ isBlockedFrom()

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

Check if user is blocked from editing a particular article.

Parameters
Title$titleTitle to check
bool$bFromSlavewhether to check the slave database instead of the master
Returns
bool

Definition at line 1743 of file User.php.

References $allowUsertalk, $title, array(), false, getName(), global, isBlocked(), NS_USER_TALK, wfDebug(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

◆ isBlockedFromCreateAccount()

User::isBlockedFromCreateAccount ( )

Get whether the user is explicitly blocked from account creation.

Returns
bool|Block

Definition at line 3634 of file User.php.

References $mBlock, getBlockedStatus(), getRequest(), isAllowed(), Block\newFromTarget(), and Block\prevents().

Referenced by isAllowedToCreateAccount().

◆ isBlockedFromEmailuser()

User::isBlockedFromEmailuser ( )

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

Returns
bool

Definition at line 3655 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 1797 of file User.php.

References $mBlockedGlobally, array(), getName(), getRequest(), IP\isIPAddress(), and wfRunHooks().

◆ 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 blacklisting may be added here rather than in isValidUserName() to avoid disrupting existing accounts.

Parameters
string$nameto match
Returns
bool

Definition at line 661 of file User.php.

References $name, global, isUsableName(), and wfDebugLog().

Referenced by getCanonicalName().

◆ isDnsBlacklisted()

User::isDnsBlacklisted (   $ip,
  $checkWhitelist = false 
)

Whether the given IP is in a DNS blacklist.

Parameters
string$ipIP to check
bool$checkWhitelistwhether to check the whitelist first
Returns
bool True if blacklisted.

Definition at line 1491 of file User.php.

References array(), global, and inDnsBlacklist().

Referenced by getBlockedStatus().

◆ isEmailConfirmationPending()

User::isEmailConfirmationPending ( )

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

Returns
bool

Definition at line 4065 of file User.php.

References global, 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

Definition at line 4041 of file User.php.

References array(), getEmailAuthenticationTimestamp(), global, isAnon(), load(), Sanitizer\validateEmail(), and wfRunHooks().

Referenced by canReceiveEmail(), canSendEmail(), confirmEmail(), and isEmailConfirmationPending().

◆ isEveryoneAllowed()

static User::isEveryoneAllowed (   $right)
static

Check if all users have the given permission.

Since
1.22
Parameters
string$rightRight to check
Returns
bool

Definition at line 4179 of file User.php.

References $cache, $right, array(), as, global, and wfRunHooks().

Referenced by ApiMain\checkExecutePermissions(), Title\checkReadPermissions(), RawAction\onView(), AjaxDispatcher\performAction(), and ApiMain\setCacheMode().

◆ isHidden()

User::isHidden ( )

Check if user account is hidden.

Returns
bool True if hidden, false otherwise

Definition at line 1834 of file User.php.

References $mHideName, getBlockedStatus(), global, and StubObject\unstub().

◆ isIP()

static User::isIP (   $name)
static

Does the string match an anonymous IPv4 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.

Parameters
string$nameName to match
Returns
bool

Definition at line 555 of file User.php.

References $name, and IP\isIPv6().

Referenced by SpecialContributions\contributionsSub(), WikiPage\doEditUpdates(), RollbackEdits\execute(), getId(), SearchEngine\getNearMatchInternal(), ApiRollback\getRbUser(), Skin\getRelevantUser(), ReassignEdits\initialiseUser(), isValidUserName(), ApiQueryContributions\prepareUsername(), ApiQueryBlocks\prepareUsername(), and Article\showMissingArticle().

◆ 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
boolean

Definition at line 1015 of file User.php.

References true.

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

◆ isLocallyBlockedProxy()

static User::isLocallyBlockedProxy (   $ip)
static

Check if an IP address is in the local proxy list.

Parameters
$ipstring
Returns
bool

Definition at line 1561 of file User.php.

References $ret, file, global, wfProfileIn(), and wfProfileOut().

◆ isLocked()

User::isLocked ( )

Check if user account is locked.

Returns
bool True if locked, false otherwise

Definition at line 1818 of file User.php.

References $mLocked, global, and StubObject\unstub().

◆ isLoggedIn()

User::isLoggedIn ( )

Get whether the user is logged in.

Returns
bool

Definition at line 2996 of file User.php.

Referenced by getRights(), isAnon(), and spreadAnyEditBlock().

◆ 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 3692 of file User.php.

References isAllowed().

Referenced by pingLimiter().

◆ isPasswordReminderThrottled()

User::isPasswordReminderThrottled ( )

Has password reminder email been sent within the last $wgPasswordReminderResendTime hours?

Returns
bool

Definition at line 2314 of file User.php.

References global, load(), TS_UNIX, and wfTimestamp().

◆ isPingLimitable()

User::isPingLimitable ( )

Is this user subject to rate limiting?

Returns
bool True if rate limited

Definition at line 1593 of file User.php.

References getRequest(), global, and isAllowed().

Referenced by pingLimiter().

◆ 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.

Parameters
string$nameName to match
Returns
bool

Definition at line 624 of file User.php.

References $name, array(), as, global, wfMessage(), and wfRunHooks().

Referenced by LoginForm\authenticateUserData(), ApiBlock\execute(), getCanonicalName(), and isCreatableName().

◆ isValidEmailAddr()

static User::isValidEmailAddr (   $addr)
static

Does a string look like an e-mail address?

This validates an email address using an HTML5 specification found at: http://www.whatwg.org/html/states-of-the-type-attribute.html#valid-e-mail-address Which as of 2011-01-24 says:

A valid e-mail address is a string that matches the ABNF production

1*( atext / "." ) "@" ldh-str *( "." ldh-str ) where atext is defined in RFC 5322 section 3.2.3, and ldh-str is defined in RFC 1034 section 3.5.

This function is an implementation of the specification as requested in bug 22449.

Client-side forms will use the same standard validation rules via JS or HTML 5 validation; additional restrictions can be enforced server-side by extensions via the 'isValidEmailAddr' hook.

Note that this validation doesn't 100% match RFC 2822, but is believed to be liberal enough for wide use. Some invalid addresses will still pass validation here.

Parameters
string$addrE-mail address
Returns
bool
Deprecated:
since 1.18 call Sanitizer::isValidEmail() directly

Definition at line 866 of file User.php.

References Sanitizer\validateEmail(), and wfDeprecated().

◆ isValidPassword()

User::isValidPassword (   $password)

Is the input a valid password for this user?

Parameters
string$passwordDesired password
Returns
bool

Definition at line 691 of file User.php.

References $password, and getPasswordValidity().

Referenced by setPassword(), and UserTest\testCheckPasswordValidity().

◆ 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.

Parameters
string$nameName to match
Returns
bool

Definition at line 570 of file User.php.

References $name, $wgContLang, global, isIP(), Title\newFromText(), and wfDebugLog().

Referenced by GenderCache\doQuery(), CheckUsernames\execute(), and getCanonicalName().

◆ isWatched()

User::isWatched (   $title,
  $checkRights = WatchedItem::CHECK_USER_RIGHTS 
)

Check the watched status of an article.

Since
1.22 $checkRights parameter added
Parameters
$titleTitle of the article to look at
$checkRightsint Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS.
Returns
bool

Definition at line 3140 of file User.php.

References $title, and getWatchedItem().

◆ 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

Definition at line 2580 of file User.php.

References array().

Referenced by ApiOptions\getAllowedParams().

◆ load()

◆ loadDefaults()

User::loadDefaults (   $name = false)

Set cached properties to default.

Note
This no longer clears uncached lazy-initialised properties; the constructor does that instead.
Parameters
$namestring|bool

Definition at line 970 of file User.php.

References $name, array(), getRequest(), pages, resetPasswordExpiration(), TS_MW, wfProfileIn(), wfProfileOut(), wfRunHooks(), and wfTimestamp().

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

◆ loadFromDatabase()

User::loadFromDatabase ( )

Load user and user_group data from the database.

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

Returns
bool True if the user exists, false if the user is anonymous

Definition at line 1134 of file User.php.

References $dbr, $s, array(), DB_MASTER, getEditCount(), loadDefaults(), loadFromRow(), wfGetDB(), and wfRunHooks().

Referenced by addToDatabase(), and loadFromId().

◆ loadFromId()

User::loadFromId ( )

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

Returns
bool false if the ID does not exist, true otherwise

Definition at line 313 of file User.php.

References $name, $wgMemc, as, global, loadDefaults(), loadFromDatabase(), MW_USER_VERSION, saveToCache(), wfDebug(), and wfMemcKey().

Referenced by load().

◆ loadFromRow()

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

Initialize this object from a row from the user table.

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

user_groups Array with groups out of the user_groups table user_properties Array with properties out of the user_properties table

Definition at line 1172 of file User.php.

References loadOptions(), setItemLoaded(), TS_MW, wfTimestamp(), and wfTimestampOrNull().

Referenced by loadFromDatabase().

◆ loadFromSession()

User::loadFromSession ( )
private

Load user data from the session or login cookie.

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

Definition at line 1035 of file User.php.

References $from, $request, array(), compareSecrets(), getRequest(), global, loadFromUserObject(), newFromId(), wfDebug(), wfDebugLog(), and wfRunHooks().

Referenced by load().

◆ loadFromUserObject()

User::loadFromUserObject (   $user)
protected

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

Parameters
$userUser

Definition at line 1244 of file User.php.

References $user, and as.

Referenced by loadFromSession().

◆ loadGroups()

User::loadGroups ( )
private

Load the groups from the database if they aren't already loaded.

Definition at line 1256 of file User.php.

References $dbr, $res, array(), as, DB_MASTER, and wfGetDB().

Referenced by addGroup(), getGroups(), removeGroup(), and saveToCache().

◆ loadOptions()

User::loadOptions (   $data = null)
protected

Load the user options either from cache, the database or an array.

Parameters
array$dataRows for the current user out of the user_properties table

Definition at line 4670 of file User.php.

References $dbr, $property, $res, $value, $wgContLang, array(), as, DB_SLAVE, getDefaultOptions(), getId(), global, load(), wfDebug(), wfGetDB(), and wfRunHooks().

Referenced by getOption(), getOptionKinds(), getOptions(), loadFromRow(), saveOptions(), saveToCache(), and setOption().

◆ logout()

User::logout ( )

Log this user out.

Definition at line 3370 of file User.php.

References array(), doLogout(), and wfRunHooks().

◆ makeGroupLinkHTML()

static User::makeGroupLinkHTML (   $group,
  $text = '' 
)
static

Create a link to the group in HTML, if available; else return the group name.

Parameters
string$groupInternal name of the group
string$textThe text of the link
Returns
string HTML link to the group

Definition at line 4302 of file User.php.

References $title, getGroupName(), getGroupPage(), and Linker\link().

Referenced by Preferences\profilePreferences().

◆ makeGroupLinkWiki()

static User::makeGroupLinkWiki (   $group,
  $text = '' 
)
static

Create a link to the group in Wikitext, if available; else return the group name.

Parameters
string$groupInternal name of the group
string$textThe text of the link
Returns
string Wikilink to the group

Definition at line 4322 of file User.php.

References $title, getGroupName(), and getGroupPage().

◆ matchEditToken()

User::matchEditToken (   $val,
  $salt = '',
  $request = 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.

Parameters
string$valInput value to compare
string$saltOptional function-specific data for hashing
WebRequest$requestObject to use or null to use $wgRequest
Returns
boolean: Whether the token matches

Definition at line 3822 of file User.php.

References $request, getEditToken(), and wfDebug().

◆ matchEditTokenNoSuffix()

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

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

Parameters
string$valInput value to compare
string$saltOptional function-specific data for hashing
WebRequest$requestobject to use or null to use $wgRequest
Returns
boolean: Whether the token matches

Definition at line 3840 of file User.php.

References $request, and getEditToken().

◆ newFatalPermissionDeniedStatus()

static User::newFatalPermissionDeniedStatus (   $permission)
static

Factory function for fatal permission-denied errors.

Since
1.22
Parameters
string$permissionUser right required
Returns
Status

Definition at line 4874 of file User.php.

References $wgLang, array(), getGroupsWithPermission(), global, and Status\newFatal().

Referenced by WatchAction\doUnwatch(), and WatchAction\doWatch().

◆ newFromConfirmationCode()

static User::newFromConfirmationCode (   $code)
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.

Parameters
string$codeConfirmation code
Returns
User|null

Definition at line 430 of file User.php.

References $dbr, array(), DB_SLAVE, newFromId(), and wfGetDB().

Referenced by EmailConfirmation\attemptConfirm(), and EmailInvalidation\attemptInvalidate().

◆ newFromId()

◆ newFromName()

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

Static factory method for creation from username.

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.
Examples
/src/tests/phpunit/MediaWikiTestCase.php.

Definition at line 389 of file User.php.

References $name, getCanonicalName(), and User.

Referenced by UserWrapper\__construct(), RecentChangeTest\__construct(), TestUser\__construct(), EmailNotification\actuallyNotifyOnPageChange(), MediaWikiTestCase\addCoreDBData(), GenderCacheTest\addDBData(), ApiBlockTest\addDBData(), BlockTest\addDBData(), BackupDumperLoggerTest\addDBData(), LoginForm\addNewAccountInternal(), BlockTest\addXffBlocks(), EditPageTest\assertEdit(), SpecialChangePassword\attemptReset(), LoginForm\authenticateUserData(), EmailNotification\canSendUserTalkEmail(), SpecialBlock\checkUnblockSelf(), Installer\createMainpage(), Installer\createSysop(), WikiPage\doEditUpdates(), Undelete\execute(), SpecialContributions\execute(), DeleteDefaultMessages\execute(), CleanupSpam\execute(), ApiBlock\execute(), ImportSiteScripts\execute(), ChangePassword\execute(), Protect\execute(), RollbackEdits\execute(), CapsCleanup\execute(), EditCLI\execute(), SpecialLog\execute(), CreateAndPromote\execute(), DeleteBatch\execute(), TableCleanup\execute(), MoveBatch\execute(), DeleteEqualMessages\execute(), DeletedContributionsPage\execute(), UserrightsPage\fetchUser(), LogFormatter\formatParameterValue(), CoreParserFunctions\gender(), CreditsAction\getAuthor(), WikiPage\getCreator(), LogEventsList\getExtraInputs(), NewUsersLogFormatter\getMessageParameters(), ResourceLoaderUserGroupsModule\getPages(), RecentChange\getPerformer(), DatabaseLogEntry\getPerformer(), RCDatabaseLogEntry\getPerformer(), Skin\getRelevantUser(), SpecialEmailUser\getTarget(), RCCacheEntryFactoryTest\getTestUser(), DoubleRedirectJob\getUser(), WikiRevision\importOldRevision(), RequestContext\importScopedSession(), WikiRevision\importUpload(), ReassignEdits\initialiseUser(), SearchEngineTest\insertPage(), RequestContext\newExtraneousContext(), WikiPage\onArticleDelete(), SpecialPasswordReset\onSubmit(), Block\parseTarget(), EnotifNotifyJob\run(), UploadFromUrlJob\run(), LogFormatterTest\setUp(), TitlePermissionTest\setUp(), SpecialLog\show(), Article\showMissingArticle(), BlockTest\testBlockedUserCanNotCreateAccount(), UserTest\testCheckPasswordValidity(), BlockTest\testCrappyCrossWikiBlocks(), UserTest\testEditCount(), RequestContextTest\testImportScopedSession(), ApiBlockTest\testMakeNormalBlock(), UserTest\testOptions(), UserTest\testPasswordExpire(), SpecialPageTest\testRequireLoginNotAnon(), GenderCacheTest\testUserObjects(), RevisionStorageTest\testUserWasLastToEdit(), and PageArchive\undeleteRevisions().

◆ 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, password, 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$dataFurther data to load into the object (see User::loadFromRow for valid keys)
Returns
User

Definition at line 471 of file User.php.

References $user, and User.

Referenced by ApiQueryUsers\execute(), DatabaseLogEntry\getPerformer(), SpecialPasswordReset\onSubmit(), and UserArrayFromResult\setCurrent().

◆ newFromSession()

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

Create a new user object using data from session or cookies.

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

Parameters
WebRequest$requestObject to use; $wgRequest will be used if omitted.
Returns
User object

Definition at line 450 of file User.php.

References $request, $user, and User.

Referenced by RequestContext\getUser().

◆ newTouchedTimestamp()

static User::newTouchedTimestamp ( )
staticprivate

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 2119 of file User.php.

References global, TS_MW, and wfTimestamp().

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

◆ oldCrypt()

static User::oldCrypt (   $password,
  $userId 
)
static

Make an old-style password hash.

Parameters
string$passwordPlain-text password
string$userIdUser ID
Returns
string Password hash

Definition at line 4527 of file User.php.

References $password, and global.

Referenced by comparePasswords().

◆ passwordChangeInputAttribs()

static User::passwordChangeInputAttribs ( )
static

Provide an array of HTML5 attributes to put on an input element intended for the user to enter a new password.

This may include required, title, and/or pattern, depending on $wgMinimalPasswordLength.

Do not use this when asking the user to enter his current password! Regardless of configuration, users may have invalid passwords for whatever reason (e.g., they were set before requirements were tightened up). Only use it when asking for a new password, like on account creation or ResetPass.

Obviously, you still need to do server-side checking.

NOTE: A combination of bugs in various browsers means that this function actually just returns array() unconditionally at the moment. May as well keep it around for when the browser bugs get fixed, though.

Todo:
FIXME: This does not belong here; put it in Html or Linker or somewhere
Returns
array Array of HTML attributes suitable for feeding to Html::element(), directly or indirectly. (Don't feed to Xml::*()! That will get confused by the boolean attribute syntax used.)

Definition at line 4807 of file User.php.

References $ret, array(), and global.

Referenced by UsercreateTemplate\execute().

◆ pingLimiter()

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

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

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
integer$incrByPositive amount to increment counter by [defaults to 1]
Returns
bool True if a rate limiter was tripped

Definition at line 1615 of file User.php.

References $count, $incrBy, $keys, $limit, $matches, $summary, $wgMemc, array(), as, getGroups(), getId(), getName(), getRequest(), global, IP\isIPv6(), isNewbie(), isPingLimitable(), list, IP\parseRange(), wfDebug(), wfDebugLog(), wfMemcKey(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

◆ randomPassword()

static User::randomPassword ( )
static

Return a random password.

Returns
string New random password

Definition at line 951 of file User.php.

References MWCryptRand\generateHex(), global, and wfBaseConvert().

Referenced by TestUser\__construct(), and ApiCreateAccountTest\testValid().

◆ removeGroup()

User::removeGroup (   $group)

Remove the user from the given group.

This takes immediate effect.

Parameters
string$groupName of the group to remove

Definition at line 2963 of file User.php.

References array(), DB_MASTER, getEffectiveGroups(), invalidateCache(), load(), loadGroups(), wfGetDB(), and wfRunHooks().

◆ removeWatch()

User::removeWatch (   $title,
  $checkRights = WatchedItem::CHECK_USER_RIGHTS 
)

Stop watching an article.

Since
1.22 $checkRights parameter added
Parameters
$titleTitle of the article to look at
$checkRightsint Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS.

Definition at line 3163 of file User.php.

References $title, getWatchedItem(), and invalidateCache().

◆ 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 2749 of file User.php.

References array(), getBoolOption(), getRequest(), global, wfCanIPUseHTTPS(), and wfRunHooks().

Referenced by setCookies().

◆ resetIdByNameCache()

static User::resetIdByNameCache ( )
static

Reset the cache used in idFromName().

For use in tests.

Examples
/src/tests/phpunit/MediaWikiTestCase.php.

Definition at line 535 of file User.php.

References array().

Referenced by MediaWikiTestCase\addCoreDBData().

◆ resetOptions()

User::resetOptions (   $resetKinds = array( '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 array( 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' ) for backwards-compatibility.
$contextIContextSource|null context source used when $resetKinds does not contain 'all', passed to getOptionKinds(). Defaults to RequestContext::getMain() when null.

Definition at line 2686 of file User.php.

References $defaultOptions, $value, array(), as, getDefaultOptions(), RequestContext\getMain(), getOptionKinds(), and load().

◆ resetPasswordExpiration()

User::resetPasswordExpiration (   $load = true)

Clear the password expiration for a user.

Since
1.23
Parameters
bool$loadensure user object is loaded first

Definition at line 789 of file User.php.

References array(), global, load(), TS_MW, wfRunHooks(), and wfTimestamp().

Referenced by loadDefaults().

◆ 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 2546 of file User.php.

References MWCryptRand\generateHex(), global, and setOption().

Referenced by getTokenFromOption().

◆ saveOptions()

User::saveOptions ( )
protected
Todo:
document

Definition at line 4732 of file User.php.

References $mOptions, $res, $value, array(), as, DB_MASTER, getDefaultOption(), getId(), loadOptions(), wfGetDB(), and wfRunHooks().

Referenced by addToDatabase(), and saveSettings().

◆ saveSettings()

User::saveSettings ( )

Save this user's settings into the database.

Todo:
Only rarely do all these fields need to be set!

Definition at line 3400 of file User.php.

References $mEmail, $mEmailToken, $mRealName, array(), clearSharedCache(), DB_MASTER, getUserPage(), global, load(), newTouchedTimestamp(), saveOptions(), wfGetDB(), wfReadOnly(), and wfRunHooks().

Referenced by expirePassword(), getTokenFromOption(), sendConfirmationMail(), setCookies(), and UserTest\testOptions().

◆ saveToCache()

User::saveToCache ( )

Save user data to the shared cache.

Definition at line 352 of file User.php.

References $name, $wgMemc, array(), as, global, isAnon(), load(), loadGroups(), loadOptions(), MW_USER_VERSION, and wfMemcKey().

Referenced by loadFromId().

◆ selectFields()

static User::selectFields ( )
static

Return the list of user fields that should be selected to create a new user object.

Returns
array

Definition at line 4847 of file User.php.

References array().

Referenced by ApiQueryUsers\execute(), UserArray\newFromIDs(), and SpecialPasswordReset\onSubmit().

◆ 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 object

Definition at line 3852 of file User.php.

References $type, $wgLang, confirmationToken(), confirmationTokenUrl(), getName(), getRequest(), global, invalidationTokenUrl(), saveSettings(), sendMail(), text, 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
string$fromOptional From address; if unspecified, default $wgPasswordSender will be used
string$replytoReply-To address
Returns
Status

Definition at line 3890 of file User.php.

References $from, global, UserMailer\send(), text, and wfMessage().

Referenced by SpecialPasswordReset\onSubmit(), and sendConfirmationMail().

◆ setCookie()

User::setCookie (   $name,
  $value,
  $exp = 0,
  $secure = null,
  $params = array() 
)
protected

Set a cookie on the user's client.

Wrapper for WebResponse::setCookie

Parameters
string$nameName of the cookie to set
string$valueValue to set
int$expExpiration time, as a UNIX time value; if 0 or not specified, use the default $wgCookieExpiration
bool$securetrue: Force setting the secure attribute when setting the cookie false: Force NOT setting the secure attribute when setting the cookie null (default): Use the default ($wgCookieSecure) to set the secure attribute
array$paramsArray of options sent passed to WebResponse::setcookie()

Definition at line 3278 of file User.php.

References $name, $params, $value, and getRequest().

Referenced by clearCookie(), doLogout(), and setCookies().

◆ setCookies()

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

Set the default cookies for this session on the user's client.

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

Definition at line 3304 of file User.php.

References $cookies, $mToken, $name, $request, $value, array(), as, clearCookie(), getName(), getRequest(), load(), requiresHTTPS(), saveSettings(), setCookie(), setToken(), and wfRunHooks().

◆ setEmail()

User::setEmail (   $str)

Set the user's e-mail address.

Parameters
string$strNew e-mail address

Definition at line 2348 of file User.php.

References array(), invalidateEmail(), load(), and wfRunHooks().

Referenced by setEmailWithConfirmation().

◆ setEmailAuthenticationTimestamp()

User::setEmailAuthenticationTimestamp (   $timestamp)

Set the e-mail authentication timestamp.

Parameters
string$timestampTS_MW timestamp

Definition at line 4001 of file User.php.

References $timestamp, array(), load(), and wfRunHooks().

Referenced by confirmEmail(), and invalidateEmail().

◆ setEmailWithConfirmation()

User::setEmailWithConfirmation (   $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 2365 of file User.php.

References $type, getEmail(), global, Status\newFatal(), Status\newGood(), sendConfirmationMail(), and setEmail().

◆ 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 1867 of file User.php.

References clearInstanceCache().

◆ setInternalPassword()

User::setInternalPassword (   $str)

Set the password and reset the random token unconditionally.

Parameters
string | null$strNew password to set or null to set an invalid password hash meaning that the user will not be able to log in through the web interface.

Definition at line 2246 of file User.php.

References crypt(), load(), and setToken().

Referenced by setPassword().

◆ setItemLoaded()

User::setItemLoaded (   $item)
protected

Set that an item has been loaded.

Parameters
string$item

Definition at line 1025 of file User.php.

Referenced by loadFromRow().

◆ 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 1903 of file User.php.

References load().

◆ setNewpassword()

User::setNewpassword (   $str,
  $throttle = true 
)

Set the password for a password reminder or new account email.

Parameters
$strNew password to set or null to set an invalid password hash meaning that the user will not be able to use it
bool$throttleIf true, reset the throttle timestamp to the present

Definition at line 2295 of file User.php.

References crypt(), load(), and wfTimestampNow().

◆ setNewtalk()

User::setNewtalk (   $val,
  $curRev = null 
)

Update the 'You have new messages!' status.

Parameters
bool$valWhether the user has new messages
$curRevRevision new, as yet unseen revision of the user talk page. Ignored if null or !$val.

Definition at line 2080 of file User.php.

References $changed, $wgMemc, deleteNewtalk(), getId(), getName(), global, invalidateCache(), isAnon(), load(), updateNewtalk(), wfMemcKey(), and wfReadOnly().

Referenced by clearAllNotifications(), and clearNotification().

◆ setOption()

User::setOption (   $oname,
  $val 
)

Set the given option for a user.

Parameters
string$onameThe option to set
mixed$valNew value to set

Definition at line 2503 of file User.php.

References getDefaultOption(), and loadOptions().

Referenced by resetTokenFromOption(), and UserTest\testOptions().

◆ setPassword()

User::setPassword (   $str)

Set the password and reset the random token.

Calls through to authentication plugin if necessary; will have no effect if the auth plugin refuses to pass the change through or if the legal password checks fail.

As a special case, setting the password to null wipes it, so the account cannot be logged in until a new password is set, for instance via e-mail.

Parameters
string$strNew password to set
Exceptions
PasswordErroron failure
Returns
bool

Definition at line 2208 of file User.php.

References $params, array(), getPasswordValidity(), global, isValidPassword(), setInternalPassword(), text, and wfMessage().

◆ setRealName()

User::setRealName (   $str)

Set the user's real name.

Parameters
string$strNew real name

Definition at line 2410 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 2279 of file User.php.

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

Referenced by addToDatabase(), getToken(), setCookies(), and setInternalPassword().

◆ 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 3603 of file User.php.

References isBlocked(), isLoggedIn(), 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 3615 of file User.php.

References getName(), getRequest(), load(), Block\newFromTarget(), and wfDebug().

Referenced by spreadAnyEditBlock().

◆ updateNewtalk()

User::updateNewtalk (   $field,
  $id,
  $curRev = null 
)
protected

Add or update the new messages flag.

Parameters
string$field'user_ip' for anonymous users, 'user_id' otherwise
string | int$idUser's IP address for anonymous users, User ID otherwise
$curRevRevision new, as yet unseen revision of the user talk page. Ignored if null.
Returns
bool True if successful, false otherwise

Definition at line 2036 of file User.php.

References array(), DB_MASTER, wfDebug(), and wfGetDB().

Referenced by setNewtalk().

◆ useNPPatrol()

User::useNPPatrol ( )

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

Returns
bool True or false

Definition at line 3075 of file User.php.

References global, and isAllowedAny().

◆ useRCPatrol()

User::useRCPatrol ( )

Check whether to enable recent changes patrol features for this user.

Returns
boolean: True or false

Definition at line 3066 of file User.php.

References global, and isAllowedAny().

◆ validateCache()

User::validateCache (   $timestamp)

Validate the cache for this account.

Parameters
string$timestampA timestamp in TS_MW format
Returns
bool

Definition at line 2178 of file User.php.

References $timestamp, and load().

◆ whoIs()

static User::whoIs (   $id)
static

Get the username corresponding to a given user ID.

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

Definition at line 484 of file User.php.

References UserCache\singleton().

Referenced by Title\checkActionPermissions(), UserrightsPage\fetchUser(), ImageListPager\formatValue(), and Revision\getRawUserText().

◆ whoIsReal()

static User::whoIsReal (   $id)
static

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

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

Definition at line 494 of file User.php.

References UserCache\singleton().

Member Data Documentation

◆ $idCacheByName

User::$idCacheByName = array()
static

Bool Whether the cache variables have been loaded.

Definition at line 244 of file User.php.

◆ $mAllowUsertalk

bool User::$mAllowUsertalk

Bool Whether the cache variables have been loaded.

Definition at line 234 of file User.php.

◆ $mAllRights

User::$mAllRights = false
static

String Cached results of getAllRights()

Definition at line 182 of file User.php.

Referenced by getAllRights().

◆ $mBlock

Block User::$mBlock

Bool Whether the cache variables have been loaded.

Definition at line 230 of file User.php.

Referenced by isBlockedFromCreateAccount().

◆ $mBlockedby

User::$mBlockedby

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by blockedBy().

◆ $mBlockedFromCreateAccount

Block User::$mBlockedFromCreateAccount = false
private

Bool Whether the cache variables have been loaded.

Definition at line 238 of file User.php.

◆ $mBlockedGlobally

User::$mBlockedGlobally

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by isBlockedGlobally().

◆ $mBlockreason

User::$mBlockreason

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by blockedFor().

◆ $mCacheVars

User::$mCacheVars
static
Initial value:
'mId',
'mName',
'mRealName',
'mPassword',
'mNewpassword',
'mNewpassTime',
'mEmail',
'mTouched',
'mToken',
'mEmailAuthenticated',
'mEmailToken',
'mEmailTokenExpires',
'mPasswordExpires',
'mRegistration',
'mEditCount',
'mGroups',
'mOptionOverrides',
)

Array of Strings 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 79 of file User.php.

◆ $mCoreRights

User::$mCoreRights
static
Initial value:
'apihighlimits',
'autoconfirmed',
'autopatrol',
'bigdelete',
'block',
'blockemail',
'bot',
'browsearchive',
'createaccount',
'createpage',
'createtalk',
'delete',
'deletedhistory',
'deletedtext',
'deletelogentry',
'deleterevision',
'edit',
'editcontentmodel',
'editinterface',
'editprotected',
'editmyoptions',
'editmyprivateinfo',
'editmyusercss',
'editmyuserjs',
'editmywatchlist',
'editsemiprotected',
'editusercssjs', #deprecated
'editusercss',
'edituserjs',
'hideuser',
'import',
'importupload',
'ipblock-exempt',
'markbotedits',
'mergehistory',
'minoredit',
'move',
'movefile',
'move-rootuserpages',
'move-subpages',
'nominornewtalk',
'noratelimit',
'override-export-depth',
'passwordreset',
'patrol',
'patrolmarks',
'protect',
'proxyunbannable',
'purge',
'read',
'reupload',
'reupload-own',
'reupload-shared',
'rollback',
'sendemail',
'siteadmin',
'suppressionlog',
'suppressredirect',
'suppressrevision',
'unblockself',
'undelete',
'unwatchedpages',
'upload',
'upload_by_url',
'userrights',
'userrights-interwiki',
'viewmyprivateinfo',
'viewmywatchlist',
'writeapi',
)

Array of Strings Core rights.

Each of these should have a corresponding message of the form "right-$right".

Definition at line 108 of file User.php.

Referenced by getAllRights().

◆ $mDatePreference

User::$mDatePreference

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by getDatePreference().

◆ $mEditCount

User::$mEditCount

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

Referenced by getEditCount().

◆ $mEffectiveGroups

User::$mEffectiveGroups

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by getEffectiveGroups().

◆ $mEmail

User::$mEmail

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

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

◆ $mEmailAuthenticated

User::$mEmailAuthenticated

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

Referenced by getEmailAuthenticationTimestamp().

◆ $mEmailToken

User::$mEmailToken

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

Referenced by saveSettings().

◆ $mEmailTokenExpires

User::$mEmailTokenExpires

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

◆ $mFormerGroups

User::$mFormerGroups

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by getFormerGroups().

◆ $mFrom

User::$mFrom

String 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
  • 'session' log in from cookies or session if possible

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

Definition at line 215 of file User.php.

◆ $mGroups

User::$mGroups

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

Referenced by getGroups().

◆ $mHash

User::$mHash

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

◆ $mHideName

User::$mHideName

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by isHidden().

◆ $mId

User::$mId

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

Referenced by getId(), and invalidateCache().

◆ $mImplicitGroups

User::$mImplicitGroups

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by getAutomaticGroups().

◆ $mLoadedItems

User::$mLoadedItems = array()
private

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

Definition at line 203 of file User.php.

◆ $mLocked

User::$mLocked

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by isLocked().

◆ $mName

User::$mName

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

Referenced by getName().

◆ $mNewpassTime

User::$mNewpassTime

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

◆ $mNewpassword

User::$mNewpassword

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

◆ $mNewtalk

User::$mNewtalk

Lazy-initialized variables, invalidated with clearInstanceCache.

Definition at line 220 of file User.php.

Referenced by getNewtalk().

◆ $mOptionOverrides

User::$mOptionOverrides

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

◆ $mOptions

User::$mOptions

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by getOptionKinds(), getOptions(), and saveOptions().

◆ $mOptionsLoaded

User::$mOptionsLoaded

Bool Whether the cache variables have been loaded.

Definition at line 198 of file User.php.

◆ $mPassword

User::$mPassword

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

◆ $mPasswordExpires

User::$mPasswordExpires
protected

Bool Whether the cache variables have been loaded.

Definition at line 191 of file User.php.

Referenced by getPasswordExpireDate().

◆ $mRealName

User::$mRealName

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

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

◆ $mRegistration

User::$mRegistration

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

Referenced by getRegistration().

◆ $mRequest

WebRequest User::$mRequest
private

Bool Whether the cache variables have been loaded.

Definition at line 226 of file User.php.

Referenced by getRequest().

◆ $mRights

User::$mRights

Bool Whether the cache variables have been loaded.

Definition at line 220 of file User.php.

Referenced by getRights().

◆ $mToken

User::$mToken

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

Referenced by getToken(), and setCookies().

◆ $mTouched

User::$mTouched

Bool Whether the cache variables have been loaded.

Definition at line 186 of file User.php.

Referenced by getTouched(), and invalidateCache().

◆ $mWatchedItems

Array User::$mWatchedItems = array()
private

Bool Whether the cache variables have been loaded.

Definition at line 242 of file User.php.

◆ EDIT_TOKEN_SUFFIX

const User::EDIT_TOKEN_SUFFIX = EDIT_TOKEN_SUFFIX

Definition at line 66 of file User.php.

Referenced by ApiTestCase\doApiRequestWithToken(), and getEditToken().

◆ MAX_WATCHED_ITEMS_CACHE

const User::MAX_WATCHED_ITEMS_CACHE = 100

Maximum items in $mWatchedItems.

Definition at line 71 of file User.php.

◆ MW_USER_VERSION

const User::MW_USER_VERSION = MW_USER_VERSION

Definition at line 65 of file User.php.

Referenced by loadFromId(), and saveToCache().

◆ USER_TOKEN_LENGTH

const User::USER_TOKEN_LENGTH = USER_TOKEN_LENGTH

Global constants made accessible as class constants so that autoloader magic can be used.

Definition at line 64 of file User.php.

Referenced by setToken().


The documentation for this class was generated from the following file:
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.