MediaWiki REL1_34
|
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time). More...
Public Member Functions | |
__construct () | |
Lightweight constructor for an anonymous user. | |
& | __get ( $name) |
__set ( $name, $value) | |
__toString () | |
getMutableCacheKeys (WANObjectCache $cache) | |
isSafeToLoad () | |
Test if it's safe to load this User object. | |
load ( $flags=self::READ_NORMAL) | |
Load the user table data for this object from the source given by mFrom. | |
loadFromId ( $flags=self::READ_NORMAL) | |
Load user table data, given mId has already been set. | |
Public Member Functions inherited from MediaWiki\User\UserIdentity | |
getActorId () | |
Static Public Member Functions | |
static | purge ( $dbDomain, $userId) |
Public Attributes | |
AbstractBlock | $mBlock |
string | $mBlockedby |
string | $mEmail |
string | $mEmailAuthenticated |
string | $mFrom |
Initialization data source if mLoadedItems!==true. | |
bool | $mHideName |
int | $mId |
Cache variables. | |
string | $mName |
array | $mOptions |
bool | $mOptionsLoaded |
Whether the cache variables have been loaded. | |
string | $mRealName |
string | $mTouched |
TS_MW timestamp from the DB. | |
const | CHECK_USER_RIGHTS = true |
const | GETOPTIONS_EXCLUDE_DEFAULTS = 1 |
Exclude user options that are set to their default value. | |
const | IGNORE_USER_RIGHTS = false |
const | INVALID_TOKEN = '*** INVALID ***' |
An invalid string value for the user_token field. | |
const | TOKEN_LENGTH = 32 |
Number of characters required for the user_token field. | |
const | VERSION = 14 |
Version number to tag cached versions of serialized User objects. | |
Public Attributes inherited from IDBAccessObject | |
const | READ_LOCKING = self::READ_LATEST | 2 |
Constants for object loading bitfield flags (higher => higher QoS) | |
const | READ_NONE = -1 |
Static Public Attributes | |
static int[] | $idCacheByName = [] |
Protected Member Functions | |
getCacheKey (WANObjectCache $cache) | |
loadFromCache () | |
Load user data from shared cache, given mId has already been set. | |
Protected Attributes | |
int null | $mActorId |
bool | $mAllowUsertalk |
string | $mBlockreason |
string | $mDatePreference |
int | $mEditCount |
array | $mEffectiveGroups |
string | $mEmailToken |
string | $mEmailTokenExpires |
array | $mFormerGroups |
AbstractBlock | $mGlobalBlock |
UserGroupMembership[] | $mGroupMemberships |
Associative array of (group name => UserGroupMembership object) | |
string | $mHash |
array | $mImplicitGroups |
array bool | $mLoadedItems = [] |
Array with already loaded items or true if all items have been loaded. | |
bool | $mLocked |
int bool | $mNewtalk |
Lazy-initialized variables, invalidated with clearInstanceCache. | |
array | $mOptionOverrides |
string | $mQuickTouched |
TS_MW timestamp from cache. | |
string | $mRegistration |
string | $mToken |
int | $queryFlagsUsed = self::READ_NORMAL |
User::READ_* constant bitfield used to load data. | |
Static Protected Attributes | |
static string[] | $mCacheVars |
Array of Strings List of member variables which are saved to the shared cache (memcached). | |
Private Attributes | |
AbstractBlock bool | $mBlockedFromCreateAccount = false |
WebRequest | $mRequest |
Static Private Attributes | |
static string[] false | $reservedUsernames = false |
Cache for self::isUsableName() | |
newFrom*() static factory methods | |
static array null | $defOpt = null |
Is the user an IP range? | |
static string null | $defOptLang = null |
Is the user an IP range? | |
isIPRange () | |
Is the user an IP range? | |
isValidPassword ( $password) | |
Is the input a valid password for this user? | |
checkPasswordValidity ( $password) | |
Check if this is a valid password for this user. | |
loadDefaults ( $name=false, $actorId=null) | |
Set cached properties to default. | |
isItemLoaded ( $item, $all='all') | |
Return whether an item has been loaded. | |
trackBlockWithCookie () | |
Set the 'BlockID' cookie depending on block type and user authentication status. | |
loadFromDatabase ( $flags=self::READ_LATEST) | |
Load user and user_group data from the database. | |
addAutopromoteOnceGroups ( $event) | |
Add the user to the group if he/she meets given criteria. | |
clearInstanceCache ( $reloadFrom=false) | |
Clear various cached data stored in this object. | |
isDnsBlacklisted ( $ip, $checkWhitelist=false) | |
Whether the given IP is in a DNS blacklist. | |
inDnsBlacklist ( $ip, $bases) | |
Whether the given IP is in a given DNS blacklist. | |
isPingLimitable () | |
Is this user subject to rate limiting? | |
pingLimiter ( $action='edit', $incrBy=1) | |
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding. | |
isBlocked ( $fromReplica=true) | |
Check if user is blocked. | |
getBlock ( $fromReplica=true) | |
Get the block affecting the user, or null if the user is not blocked. | |
isBlockedFrom ( $title, $fromReplica=false) | |
Check if user is blocked from editing a particular article. | |
blockedBy () | |
If user is blocked, return the name of the user who placed the block. | |
blockedFor () | |
If user is blocked, return the specified reason for the block. | |
getBlockId () | |
If user is blocked, return the ID for the block. | |
isBlockedGlobally ( $ip='') | |
Check if user is blocked on all wikis. | |
getGlobalBlock ( $ip='') | |
Check if user is blocked on all wikis. | |
isLocked () | |
Check if user account is locked. | |
isHidden () | |
Check if user account is hidden. | |
getId () | |
Get the user's ID. | |
setId ( $v) | |
Set the user and reload all fields according to a given ID. | |
getName () | |
Get the user name, or the IP of an anonymous user. | |
setName ( $str) | |
Set the user name. | |
getActorId (IDatabase $dbw=null) | |
Get the user's actor ID. | |
getTitleKey () | |
Get the user's name escaped by underscores. | |
getNewtalk () | |
Check if the user has new messages. | |
getNewMessageLinks () | |
Return the data needed to construct links for new talk page message alerts. | |
getNewMessageRevisionId () | |
Get the revision ID for the last talk page revision viewed by the talk page owner. | |
setNewtalk ( $val, $curRev=null) | |
Update the 'You have new messages!' status. | |
clearSharedCache ( $mode='refresh') | |
Clear user data from memcached. | |
invalidateCache () | |
Immediately touch the user data cache for this account. | |
touch () | |
Update the "touched" timestamp for the user. | |
validateCache ( $timestamp) | |
Validate the cache for this account. | |
getTouched () | |
Get the user touched timestamp. | |
getDBTouched () | |
Get the user_touched timestamp field (time of last DB updates) | |
setPassword ( $str) | |
Set the password and reset the random token. | |
setInternalPassword ( $str) | |
Set the password and reset the random token unconditionally. | |
changeAuthenticationData (array $data) | |
Changes credentials of the user. | |
getToken ( $forceCreation=true) | |
Get the user's current token. | |
setToken ( $token=false) | |
Set the random token (used for persistent authentication) Called from loadDefaults() among other places. | |
getEmail () | |
Get the user's e-mail address. | |
getEmailAuthenticationTimestamp () | |
Get the timestamp of the user's e-mail authentication. | |
setEmail ( $str) | |
Set the user's e-mail address. | |
setEmailWithConfirmation ( $str) | |
Set the user's e-mail address and a confirmation mail if needed. | |
getRealName () | |
Get the user's real name. | |
setRealName ( $str) | |
Set the user's real name. | |
getOption ( $oname, $defaultOverride=null, $ignoreHidden=false) | |
Get the user's current setting for a given option. | |
getOptions ( $flags=0) | |
Get all user's options. | |
getBoolOption ( $oname) | |
Get the user's current setting for a given option, as a boolean value. | |
getIntOption ( $oname, $defaultOverride=0) | |
Get the user's current setting for a given option, as an integer value. | |
setOption ( $oname, $val) | |
Set the given option for a user. | |
getTokenFromOption ( $oname) | |
Get a token stored in the preferences (like the watchlist one), resetting it if it's empty (and saving changes). | |
resetTokenFromOption ( $oname) | |
Reset a token stored in the preferences (like the watchlist one). | |
getOptionKinds (IContextSource $context, $options=null) | |
Return an associative array mapping preferences keys to the kind of a preference they're used for. | |
resetOptions ( $resetKinds=[ 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused'], IContextSource $context=null) | |
Reset certain (or all) options to the site defaults. | |
getDatePreference () | |
Get the user's preferred date format. | |
requiresHTTPS () | |
Determine based on the wiki configuration and the user's options, whether this user must be over HTTPS no matter what. | |
getStubThreshold () | |
Get the user preferred stub threshold. | |
getRights () | |
Get the permissions this user has. | |
getGroups () | |
Get the list of explicit group memberships this user has. | |
getGroupMemberships () | |
Get the list of explicit group memberships this user has, stored as UserGroupMembership objects. | |
getEffectiveGroups ( $recache=false) | |
Get the list of implicit group memberships this user has. | |
getAutomaticGroups ( $recache=false) | |
Get the list of implicit group memberships this user has. | |
getFormerGroups () | |
Returns the groups the user has belonged to. | |
getEditCount () | |
Get the user's edit count. | |
addGroup ( $group, $expiry=null) | |
Add the user to the given group. | |
removeGroup ( $group) | |
Remove the user from the given group. | |
isRegistered () | |
Alias of isLoggedIn() with a name that describes its actual functionality. | |
isLoggedIn () | |
Get whether the user is logged in. | |
isAnon () | |
Get whether the user is anonymous. | |
isBot () | |
isAllowedAny (... $permissions) | |
Check if user is allowed to access a feature / make an action. | |
isAllowedAll (... $permissions) | |
isAllowed ( $action='') | |
Internal mechanics of testing a permission. | |
useRCPatrol () | |
Check whether to enable recent changes patrol features for this user. | |
useNPPatrol () | |
Check whether to enable new pages patrol features for this user. | |
useFilePatrol () | |
Check whether to enable new files patrol features for this user. | |
getRequest () | |
Get the WebRequest object to use with this object. | |
isWatched ( $title, $checkRights=self::CHECK_USER_RIGHTS) | |
Check the watched status of an article. | |
addWatch ( $title, $checkRights=self::CHECK_USER_RIGHTS) | |
Watch an article. | |
removeWatch ( $title, $checkRights=self::CHECK_USER_RIGHTS) | |
Stop watching an article. | |
clearNotification (&$title, $oldid=0) | |
Clear the user's notification timestamp for the given title. | |
clearAllNotifications () | |
Resets all of the given user's page-change notification timestamps. | |
getExperienceLevel () | |
Compute experienced level based on edit count and registration date. | |
setCookies ( $request=null, $secure=null, $rememberMe=false) | |
Persist this user's session (e.g. | |
logout () | |
Log this user out. | |
doLogout () | |
Clear the user's session, and reset the instance cache. | |
saveSettings () | |
Save this user's settings into the database. | |
idForName ( $flags=0) | |
If only this user's username is known, and it exists, return the user ID. | |
addToDatabase () | |
Add this existing user object to the database. | |
spreadAnyEditBlock () | |
If this user is logged-in and blocked, block any IP address they've successfully logged in from. | |
isBlockedFromCreateAccount () | |
Get whether the user is explicitly blocked from account creation. | |
isBlockedFromEmailuser () | |
Get whether the user is blocked from using Special:Emailuser. | |
isBlockedFromUpload () | |
Get whether the user is blocked from using Special:Upload. | |
isAllowedToCreateAccount () | |
Get whether the user is allowed to create an account. | |
getUserPage () | |
Get this user's personal page title. | |
getTalkPage () | |
Get this user's talk page title. | |
isNewbie () | |
Determine whether the user is a newbie. | |
checkPassword ( $password) | |
Check to see if the given clear-text password is one of the accepted passwords. | |
checkTemporaryPassword ( $plaintext) | |
Check if the given clear-text password matches the temporary password sent by e-mail for password reset operations. | |
getEditTokenObject ( $salt='', $request=null) | |
Initialize (if necessary) and return a session token value which can be used in edit forms to show that the user's login credentials aren't being hijacked with a foreign form submission. | |
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. | |
matchEditToken ( $val, $salt='', $request=null, $maxage=null) | |
Check given value against the token value stored in the session. | |
matchEditTokenNoSuffix ( $val, $salt='', $request=null, $maxage=null) | |
Check given value against the token value stored in the session, ignoring the suffix. | |
sendConfirmationMail ( $type='created') | |
Generate a new e-mail confirmation token and send a confirmation/invalidation mail to the user's given address. | |
sendMail ( $subject, $body, $from=null, $replyto=null) | |
Send an e-mail to this user's account. | |
confirmEmail () | |
Mark the e-mail address confirmed. | |
invalidateEmail () | |
Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already confirmed. | |
setEmailAuthenticationTimestamp ( $timestamp) | |
Set the e-mail authentication timestamp. | |
canSendEmail () | |
Is this user allowed to send e-mails within limits of current site configuration? | |
canReceiveEmail () | |
Is this user allowed to receive e-mails within limits of current site configuration? | |
isEmailConfirmed () | |
Is this user's e-mail address valid-looking and confirmed within limits of the current site configuration? | |
isEmailConfirmationPending () | |
Check whether there is an outstanding request for e-mail confirmation. | |
getRegistration () | |
Get the timestamp of account creation. | |
getFirstEditTimestamp () | |
Get the timestamp of the first edit. | |
getLatestEditTimestamp () | |
Get the timestamp of the latest edit. | |
changeableGroups () | |
Returns an array of groups that this user can add and remove. | |
incEditCount () | |
Schedule a deferred update to update the user's edit count. | |
setEditCountInternal ( $count) | |
This method should not be called outside User/UserEditCountUpdate. | |
initEditCountInternal (IDatabase $dbr) | |
Initialize user_editcount from data out of the revision table. | |
addNewUserLogEntry ( $action=false, $reason='') | |
Add a newuser log entry for this user. | |
addNewUserLogEntryAutoCreate () | |
Add an autocreate newuser log entry for this user Used by things like CentralAuth and perhaps other authplugins. | |
getInstanceForUpdate () | |
Get a new instance of this user that was loaded from the master via a locking read. | |
equals (UserIdentity $user) | |
Checks if two user objects point to the same user. | |
isAllowUsertalk () | |
Checks if usertalk is allowed. | |
static | newFromName ( $name, $validate='valid') |
Static factory method for creation from username. | |
static | newFromId ( $id) |
Static factory method for creation from a given user ID. | |
static | newFromActorId ( $id) |
Static factory method for creation from a given actor ID. | |
static | newFromIdentity (UserIdentity $identity) |
Returns a User object corresponding to the given UserIdentity. | |
static | newFromAnyId ( $userId, $userName, $actorId, $dbDomain=false) |
Static factory method for creation from an ID, name, and/or actor ID. | |
static | newFromConfirmationCode ( $code, $flags=0) |
Factory method to fetch whichever user has a given email confirmation code. | |
static | newFromSession (WebRequest $request=null) |
Create a new user object using data from session. | |
static | newFromRow ( $row, $data=null) |
Create a new user object from a user row. | |
static | newSystemUser ( $name, $options=[]) |
Static factory method for creation of a "system" user from username. | |
static | whoIs ( $id) |
Get the username corresponding to a given user ID. | |
static | whoIsReal ( $id) |
Get the real name of a user given their user ID. | |
static | idFromName ( $name, $flags=self::READ_NORMAL) |
Get database id given a user name. | |
static | resetIdByNameCache () |
Reset the cache used in idFromName(). | |
static | isIP ( $name) |
Does the string match an anonymous IP address? | |
static | isValidUserName ( $name) |
Is the input a valid username? | |
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. | |
static | findUsersByGroup ( $groups, $limit=5000, $after=null) |
Return the users who are members of the given group(s). | |
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. | |
static | getCanonicalName ( $name, $validate='valid') |
Given unvalidated user input, return a canonical username, or false if the username is invalid. | |
static | resetGetDefaultOptionsForTestsOnly () |
Reset the process cache of default user options. | |
static | getDefaultOptions () |
Combine the language default options with any site-specific options and add the default language variants. | |
static | getDefaultOption ( $opt) |
Get a given default option value. | |
static | isLocallyBlockedProxy ( $ip) |
Check if an IP address is in the local proxy list. | |
static | listOptionKinds () |
Return a list of the types of user options currently returned by User::getOptionKinds(). | |
static | createNew ( $name, $params=[]) |
Add a user to the database, return the user object. | |
static | getGroupPermissions ( $groups) |
Get the permissions associated with a given list of groups. | |
static | getGroupsWithPermission ( $role) |
Get all the groups who have a given permission. | |
static | groupHasPermission ( $group, $role) |
Check, if the given group has the given permission. | |
static | isEveryoneAllowed ( $right) |
Check if all users may be assumed to have the given permission. | |
static | getAllGroups () |
Return the set of defined explicit groups. | |
static | getAllRights () |
Get a list of all available permissions. | |
static | getImplicitGroups () |
Get a list of implicit groups TODO: Should we deprecate this? It's trivial, but we don't want to encourage use of globals. | |
static | changeableByGroup ( $group) |
Returns an array of the groups that a particular group can add/remove. | |
static | getRightDescription ( $right) |
Get the description of a given right. | |
static | getGrantName ( $grant) |
Get the name of a given grant. | |
static | selectFields () |
Return the list of user fields that should be selected to create a new user object. | |
static | getQueryInfo () |
Return the tables, fields, and join conditions to be selected to create a new user object. | |
static | newFatalPermissionDeniedStatus ( $permission) |
Factory function for fatal permission-denied errors. | |
setItemLoaded ( $item) | |
Set that an item has been loaded. | |
loadFromRow ( $row, $data=null) | |
Initialize this object from a row from the user table. | |
loadFromUserObject ( $user) | |
Load the data for this user object from another user object. | |
makeUpdateConditions (IDatabase $db, array $conditions) | |
Builds update conditions. | |
checkAndSetTouched () | |
Bump user_touched if it didn't change since this object was loaded. | |
checkNewtalk ( $field, $id) | |
Internal uncached check for new messages. | |
updateNewtalk ( $field, $id, $curRev=null) | |
Add or update the new messages flag. | |
deleteNewtalk ( $field, $id) | |
Clear the new messages flag for the given user. | |
spreadBlock () | |
If this (non-anonymous) user is blocked, block the IP address they've successfully logged in from. | |
confirmationToken (&$expiration) | |
Generate, store, and return a new e-mail confirmation code. | |
confirmationTokenUrl ( $token) | |
Return a URL the user can use to confirm their email address. | |
invalidationTokenUrl ( $token) | |
Return a URL the user can use to invalidate their email address. | |
getTokenUrl ( $page, $token) | |
Internal function to format the e-mail validation/invalidation URLs. | |
loadOptions ( $data=null) | |
Load the user options either from cache, the database or an array. | |
saveOptions () | |
Saves the non-default options for this user, as previously set e.g. | |
loadFromSession () | |
Load user data from the session. | |
loadGroups () | |
Load the groups from the database if they aren't already loaded. | |
getBlockedStatus ( $fromReplica=true) | |
Get blocking information. | |
newTouchedTimestamp () | |
Generate a current or new-future timestamp to be stored in the user_touched field when we update things. | |
setPasswordInternal ( $str) | |
Actually set the password and such. | |
updateActorId (IDatabase $dbw) | |
Update the actor ID after an insert. | |
getEditTimestamp ( $first) | |
Get the timestamp of the first or latest edit. | |
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
Client classes use the getXXX() functions to access these fields. These functions do all the work of determining whether the user is logged in, whether the requested option can be satisfied from cookies or whether a database query is needed. Most of the settings needed for rendering normal pages are set in the cookie to minimize use of the database.
User::__construct | ( | ) |
Lightweight constructor for an anonymous user.
Use the User::newFrom* factory functions for other kinds of users.
Definition at line 232 of file User.php.
References clearInstanceCache().
& User::__get | ( | $name | ) |
Definition at line 243 of file User.php.
References getRights(), and wfLogWarning().
User::__set | ( | $name, | |
$value ) |
Definition at line 260 of file User.php.
References wfLogWarning().
User::addAutopromoteOnceGroups | ( | $event | ) |
Add the user to the group if he/she meets given criteria.
Contrary to autopromotion by \ref $wgAutopromote, the group will be possible to remove manually via Special:UserRights. In such case it will not be re-added automatically. The user will also not lose the group if they no longer meet the criteria.
string | $event | Key in $wgAutopromoteOnce (each one has groups/criteria) |
Definition at line 1535 of file User.php.
References $wgAutopromoteOnceLogInRC, addGroup(), checkAndSetTouched(), Autopromote\getAutopromoteOnceGroups(), getGroupMemberships(), getGroups(), getId(), getUserPage(), and wfReadOnly().
Referenced by MediaWiki\Storage\PageUpdater\saveRevision().
User::addGroup | ( | $group, | |
$expiry = null ) |
Add the user to the given group.
This takes immediate effect. If the user is already in the group, the expiry time will be updated to the new expiry time. (If $expiry is omitted or null, the membership will be altered to never expire.)
string | $group | Name of the group to add |
string | null | $expiry | Optional expiry timestamp in any format acceptable to wfTimestamp(), or null if the group assignment should not expire |
Definition at line 3553 of file User.php.
References getEffectiveGroups(), invalidateCache(), load(), loadGroups(), and wfTimestamp().
Referenced by addAutopromoteOnceGroups().
User::addNewUserLogEntry | ( | $action = false, | |
$reason = '' ) |
Add a newuser log entry for this user.
Before 1.19 the return value was always true.
string | bool | $action | Account creation type.
|
string | $reason | User supplied reason |
Definition at line 5165 of file User.php.
Referenced by 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.
Definition at line 5177 of file User.php.
References addNewUserLogEntry(), and wfDeprecated().
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 (T18020). By initialising the user object if the user exists, we aim to support this calling sequence as far as possible.
Note that if the user exists, this function will acquire a write lock, so it is still advisable to make the call conditional on isLoggedIn(), and to commit the transaction after calling.
MWException |
Definition at line 4212 of file User.php.
References Wikimedia\Rdbms\IDatabase\affectedRows(), clearInstanceCache(), DB_MASTER, Wikimedia\Rdbms\IDatabase\insert(), Wikimedia\Rdbms\IDatabase\insertId(), load(), loadFromDatabase(), newTouchedTimestamp(), saveOptions(), Wikimedia\Rdbms\IDatabase\selectField(), setToken(), Wikimedia\Rdbms\IDatabase\timestamp(), Wikimedia\Rdbms\IDatabase\timestampOrNull(), updateActorId(), and wfGetDB().
Referenced by MediaWiki\Auth\AuthManager\autoCreateUser().
User::addWatch | ( | $title, | |
$checkRights = self::CHECK_USER_RIGHTS ) |
Watch an article.
Title | $title | Title of the article to look at |
bool | $checkRights | Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass User::CHECK_USER_RIGHTS or User::IGNORE_USER_RIGHTS. |
Definition at line 3768 of file User.php.
References $title, invalidateCache(), and isAllowed().
Referenced by MediaWiki\Auth\AuthManager\autoCreateUser(), WatchAction\doWatch(), and LocalFile\recordUpload().
User::blockedBy | ( | ) |
If user is blocked, return the name of the user who placed the block.
Definition at line 2225 of file User.php.
References getBlockedStatus().
Referenced by SpecialBlock\checkUnblockSelf().
User::blockedFor | ( | ) |
If user is blocked, return the specified reason for the block.
Definition at line 2234 of file User.php.
References getBlockedStatus().
User::canReceiveEmail | ( | ) |
Is this user allowed to receive e-mails within limits of current site configuration?
Definition at line 4726 of file User.php.
References getOption(), and isEmailConfirmed().
User::canSendEmail | ( | ) |
Is this user allowed to send e-mails within limits of current site configuration?
Definition at line 4709 of file User.php.
References $wgEnableEmail, $wgEnableUserEmail, isAllowed(), and isEmailConfirmed().
|
static |
Returns an array of the groups that a particular group can add/remove.
string | $group | The group to check for whether it can add/remove |
Definition at line 4953 of file User.php.
References $wgAddGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf, and $wgRemoveGroups.
Referenced by changeableGroups().
User::changeableGroups | ( | ) |
Returns an array of groups that this user can add and remove.
Definition at line 5026 of file User.php.
References changeableByGroup(), getEffectiveGroups(), and isAllowed().
User::changeAuthenticationData | ( | array | $data | ) |
Changes credentials of the user.
This is a convenience wrapper around AuthManager::changeAuthenticationData. Note that this can return a status that isOK() but not isGood() on certain types of failures, e.g. when no provider handled the change.
array | $data | A set of authentication data in fieldname => value format. This is the same data you would pass the changeauthenticationdata API - 'username', 'password' etc. |
Definition at line 2819 of file User.php.
Referenced by setPasswordInternal().
|
protected |
Bump user_touched if it didn't change since this object was loaded.
On success, the mTouched field is updated. The user serialization cache is always cleared.
Definition at line 1604 of file User.php.
References $success, clearSharedCache(), DB_MASTER, load(), newTouchedTimestamp(), and wfGetDB().
Referenced by addAutopromoteOnceGroups().
|
protected |
Internal uncached check for new messages.
string | $field | 'user_ip' for anonymous users, 'user_id' otherwise |
string | int | $id | User's IP address for anonymous users, User ID otherwise |
Definition at line 2529 of file User.php.
References $dbr, DB_REPLICA, and wfGetDB().
Referenced by getNewtalk().
User::checkPassword | ( | $password | ) |
Check to see if the given clear-text password is one of the accepted passwords.
string | $password | User password |
Definition at line 4410 of file User.php.
References $res, and wfDeprecated().
Referenced by checkTemporaryPassword().
User::checkPasswordValidity | ( | $password | ) |
Check if this is a valid password for this user.
Returns a Status object with a set of messages describing problems with the password. If the return status is fatal, the action should be refused and the password should not be checked at all (this is mainly meant for DoS mitigation). If the return value is OK but not good, the password can be checked, but the user should not be able to set their password to this. The value of the returned Status object will be an array which can have the following fields:
string | $password | Desired password |
Definition at line 1138 of file User.php.
References $wgPasswordPolicy.
Referenced by isValidPassword().
User::checkTemporaryPassword | ( | $plaintext | ) |
Check if the given clear-text password matches the temporary password sent by e-mail for password reset operations.
string | $plaintext |
Definition at line 4445 of file User.php.
References checkPassword(), and wfDeprecated().
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.
Definition at line 3876 of file User.php.
References $wgShowUpdatedMarker, $wgUseEnotif, getId(), isAllowed(), setNewtalk(), and wfReadOnly().
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.
bool | string | $reloadFrom | Reload user and user_groups table data from a given source. May be "name", "id", "actor", "defaults", "session", or false for no reload. |
Definition at line 1642 of file User.php.
References $wgFullyInitialised.
Referenced by __construct(), addToDatabase(), doLogout(), and setId().
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.
Title | &$title | Title of the article to look at |
int | $oldid | The revision id being viewed. If not given or 0, latest revision is assumed. |
Definition at line 3802 of file User.php.
References $title, $wgShowUpdatedMarker, $wgUseEnotif, getName(), getNewtalk(), isAllowed(), isAnon(), NS_USER_TALK, setNewtalk(), and wfReadOnly().
Referenced by WikiPage\doViewUpdates().
User::clearSharedCache | ( | $mode = 'refresh' | ) |
Clear user data from memcached.
Use after applying updates to the database; caller's responsibility to update user_touched if appropriate.
Called implicitly from invalidateCache() and saveSettings().
string | $mode | Use 'refresh' to clear now or 'changed' to clear before DB commit |
Definition at line 2641 of file User.php.
References $cache, DB_MASTER, getCacheKey(), and getId().
Referenced by checkAndSetTouched(), invalidateCache(), and saveSettings().
|
protected |
Generate, store, and return a new e-mail confirmation code.
A hash (unsalted, since it's used as a key) is stored.
string | &$expiration | Accepts the expiration time |
Definition at line 4609 of file User.php.
References $wgUserEmailConfirmationTokenExpiry, MWCryptRand\generateHex(), load(), and wfTimestamp().
Referenced by sendConfirmationMail().
|
protected |
Return a URL the user can use to confirm their email address.
string | $token | Accepts the email confirmation token |
Definition at line 4627 of file User.php.
References getTokenUrl().
Referenced by sendConfirmationMail().
User::confirmEmail | ( | ) |
Mark the e-mail address confirmed.
Definition at line 4667 of file User.php.
References isEmailConfirmed(), setEmailAuthenticationTimestamp(), and wfTimestampNow().
|
static |
Add a user to the database, return the user object.
string | $name | Username to add |
array | $params | Array of Strings Non-default parameters to save to the database as user_* fields:
|
Definition at line 4136 of file User.php.
References Wikimedia\Rdbms\IDatabase\affectedRows(), DB_MASTER, Wikimedia\Rdbms\IDatabase\insert(), load(), wfDeprecated(), and wfGetDB().
|
protected |
Clear the new messages flag for the given user.
string | $field | 'user_ip' for anonymous users, 'user_id' otherwise |
string | int | $id | User's IP address for anonymous users, User ID otherwise |
Definition at line 2569 of file User.php.
References DB_MASTER, wfDebug(), and wfGetDB().
Referenced by setNewtalk().
User::doLogout | ( | ) |
Clear the user's session, and reset the instance cache.
Definition at line 3991 of file User.php.
References clearInstanceCache(), and getRequest().
Referenced by logout().
User::equals | ( | UserIdentity | $user | ) |
Checks if two user objects point to the same user.
UserIdentity | $user |
Implements MediaWiki\User\UserIdentity.
Definition at line 5436 of file User.php.
References getName(), and MediaWiki\User\UserIdentity\getName().
|
static |
Return the users who are members of the given group(s).
In case of multiple groups, users who are members of at least one of them are returned.
string | array | $groups | A single group name or an array of group names |
int | $limit | Max number of users to return. The actual limit will never exceed 5000 records; larger values are ignored. |
int | null | $after | ID the user to start after |
Definition at line 1042 of file User.php.
References $dbr, DB_REPLICA, UserArray\newFromIDs(), and wfGetDB().
User::getActorId | ( | IDatabase | $dbw = null | ) |
Get the user's actor ID.
IDatabase | null | $dbw | Assign a new actor ID, using this DB handle, if none exists |
Definition at line 2403 of file User.php.
References invalidateCache(), isItemLoaded(), load(), and setItemLoaded().
Referenced by LocalFile\recordUpload2().
|
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.
Definition at line 4914 of file User.php.
References $wgGroupPermissions, and $wgRevokePermissions.
|
static |
Get a list of all available permissions.
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
bool | $recache | Whether to avoid the cache |
Definition at line 3465 of file User.php.
References Autopromote\getAutopromoteGroups(), and getId().
Referenced by getEffectiveGroups().
User::getBlock | ( | $fromReplica = true | ) |
Get the block affecting the user, or null if the user is not blocked.
bool | $fromReplica | Whether to check the replica DB instead of the master |
Definition at line 2200 of file User.php.
References getBlockedStatus().
Referenced by Action\checkCanExecute(), Autopromote\checkCondition(), FormSpecialPage\checkExecutePermissions(), SpecialBlock\checkUnblockSelf(), MediaWiki\Permissions\PermissionManager\checkUserBlock(), isBlocked(), PasswordReset\isBlocked(), MediaWiki\Permissions\PermissionManager\isBlockedFrom(), spreadAnyEditBlock(), and MediaWiki\Block\BlockManager\trackBlockWithCookie().
|
private |
Get blocking information.
TODO: Move this into the BlockManager, along with block-related properties.
bool | $fromReplica | Whether to check the replica DB first. To improve performance, non-critical checks are done against replica DBs. Check when actually saving should be done against master. |
Definition at line 1748 of file User.php.
References getName(), getRequest(), load(), and wfDebug().
Referenced by blockedBy(), blockedFor(), getBlock(), getBlockId(), isBlockedFromCreateAccount(), isBlockedFromEmailuser(), isBlockedFromUpload(), and isHidden().
User::getBlockId | ( | ) |
If user is blocked, return the ID for the block.
Definition at line 2243 of file User.php.
References getBlockedStatus().
User::getBoolOption | ( | $oname | ) |
Get the user's current setting for a given option, as a boolean value.
string | $oname | The option to check |
Definition at line 3081 of file User.php.
References getOption().
Referenced by requiresHTTPS().
|
protected |
WANObjectCache | $cache |
Definition at line 432 of file User.php.
References $cache.
Referenced by clearSharedCache(), getMutableCacheKeys(), and loadFromCache().
|
static |
Given unvalidated user input, return a canonical username, or false if the username is invalid.
string | $name | User input |
string | bool | $validate | Type of validation to use:
|
InvalidArgumentException |
Definition at line 1180 of file User.php.
Referenced by MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider\beginPrimaryAuthentication(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\beginPrimaryAuthentication(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider\providerAllowsAuthenticationDataChange(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\providerAllowsAuthenticationDataChange(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider\providerChangeAuthenticationData(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\providerChangeAuthenticationData(), MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\providerNormalizeUsername(), MediaWiki\Session\CookieSessionProvider\suggestLoginUsername(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider\testUserCanAuthenticate(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\testUserCanAuthenticate(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider\testUserExists(), and MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\testUserExists().
User::getDatePreference | ( | ) |
Get the user's preferred date format.
Definition at line 3345 of file User.php.
References $wgLang, and getOption().
Referenced by Language\getHumanTimestampInternal(), and Language\internalUserTimeAndDate().
User::getDBTouched | ( | ) |
|
static |
|
static |
Combine the language default options with any site-specific options and add the default language variants.
Definition at line 1692 of file User.php.
References $wgDefaultSkin, $wgDefaultUserOptions, and $wgNamespacesToBeSearchedDefault.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\loadPreferenceValues().
User::getEditCount | ( | ) |
Get the user's edit count.
Definition at line 3518 of file User.php.
References $dbr, DB_REPLICA, getId(), initEditCountInternal(), and wfGetDB().
Referenced by MediaWiki\Storage\PageEditStash\checkCache(), Autopromote\checkCondition(), getExperienceLevel(), loadFromDatabase(), LogFormatter\makeUserLink(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), and MediaWiki\Storage\PageEditStash\storeStashValue().
|
private |
Get the timestamp of the first or latest edit.
bool | $first | True for the first edit, false for the latest one |
Definition at line 4817 of file User.php.
References $dbr, DB_REPLICA, getId(), wfGetDB(), and wfTimestamp().
Referenced by getFirstEditTimestamp(), and getLatestEditTimestamp().
User::getEditToken | ( | $salt = '', | |
$request = null ) |
Initialize (if necessary) and return a session token value which can be used in edit forms to show that the user's login credentials aren't being hijacked with a foreign form submission.
The $salt for 'edit' and 'csrf' tokens is the default (empty string).
string | array | $salt | Array of Strings Optional function-specific data for hashing |
WebRequest | null | $request | WebRequest object to use or null to use $wgRequest |
Definition at line 4486 of file User.php.
References getEditTokenObject().
Referenced by WatchAction\getWatchToken().
User::getEditTokenObject | ( | $salt = '', | |
$request = null ) |
Initialize (if necessary) and return a session token value which can be used in edit forms to show that the user's login credentials aren't being hijacked with a foreign form submission.
string | array | $salt | Array of Strings Optional function-specific data for hashing |
WebRequest | null | $request | WebRequest object to use or null to use $wgRequest |
Definition at line 4462 of file User.php.
References getRequest(), and isAnon().
Referenced by getEditToken(), ApiQueryTokens\getToken(), and matchEditToken().
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
bool | $recache | Whether to avoid the cache |
Definition at line 3442 of file User.php.
References getAutomaticGroups(), and getGroups().
Referenced by addGroup(), changeableGroups(), UserPasswordPolicy\getPoliciesForUser(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), and removeGroup().
User::getEmail | ( | ) |
Get the user's e-mail address.
Definition at line 2905 of file User.php.
References load().
Referenced by SpecialChangeEmail\attemptChange(), Autopromote\checkCondition(), EmailBlacklist\checkUser(), MailAddress\newFromUser(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), and setEmailWithConfirmation().
User::getEmailAuthenticationTimestamp | ( | ) |
Get the timestamp of the user's e-mail authentication.
Definition at line 2915 of file User.php.
References load().
Referenced by Autopromote\checkCondition(), isEmailConfirmed(), and MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().
User::getExperienceLevel | ( | ) |
Compute experienced level based on edit count and registration date.
Definition at line 3905 of file User.php.
References $wgExperiencedUserEdits, $wgExperiencedUserMemberSince, $wgLearnerEdits, $wgLearnerMemberSince, getEditCount(), getRegistration(), isAnon(), and wfTimestamp().
User::getFirstEditTimestamp | ( | ) |
Get the timestamp of the first edit.
Definition at line 4795 of file User.php.
References getEditTimestamp().
Referenced by Autopromote\checkCondition().
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
Definition at line 3494 of file User.php.
References $res, DB_MASTER, DB_REPLICA, load(), and wfGetDB().
Referenced by Autopromote\getAutopromoteOnceGroups().
User::getGlobalBlock | ( | $ip = '' | ) |
Check if user is blocked on all wikis.
Do not use for actual edit permission checks! This is intended for quick UI checks.
string | $ip | IP address, uses current client if none given |
FatalError | |
MWException |
Definition at line 2270 of file User.php.
References getName(), and getRequest().
Referenced by PasswordReset\isBlocked(), and isBlockedGlobally().
|
static |
Get the name of a given grant.
string | $grant | Grant to query |
Definition at line 5139 of file User.php.
References wfMessage().
User::getGroupMemberships | ( | ) |
Get the list of explicit group memberships this user has, stored as UserGroupMembership objects.
Implicit groups are not included.
Definition at line 3429 of file User.php.
References load(), and loadGroups().
Referenced by addAutopromoteOnceGroups(), and MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().
|
static |
Get the permissions associated with a given list of groups.
array | $groups | Array of Strings List of internal group names |
User::getGroups | ( | ) |
Get the list of explicit group memberships this user has.
The implicit * and user groups are not included.
Definition at line 3416 of file User.php.
References load(), and loadGroups().
Referenced by addAutopromoteOnceGroups(), Autopromote\checkCondition(), Autopromote\getAutopromoteOnceGroups(), getEffectiveGroups(), isBot(), and pingLimiter().
|
static |
Get all the groups who have a given permission.
string | $role | Role to check |
Definition at line 4862 of file User.php.
Referenced by newFatalPermissionDeniedStatus().
User::getId | ( | ) |
Get the user's ID.
Implements MediaWiki\User\UserIdentity.
Definition at line 2335 of file User.php.
References ExternalUserNames\isExternal(), isItemLoaded(), and load().
Referenced by UserEditCountUpdate\__construct(), UploadFromChunks\__construct(), addAutopromoteOnceGroups(), MediaWiki\Auth\AuthManager\autoCreateUser(), MediaWiki\Auth\AuthManager\beginAccountCreation(), MediaWiki\Auth\AuthManager\beginAccountLink(), EmailNotification\canSendUserTalkEmail(), SpecialBlock\checkUnblockSelf(), clearAllNotifications(), clearSharedCache(), WikiPage\doDeleteArticleBatched(), WikiPage\doUpdateRestrictions(), ApiBlock\execute(), ApiUnblock\execute(), PasswordReset\execute(), getAutomaticGroups(), MediaWiki\Block\DatabaseBlock\getDatabaseArray(), getEditCount(), getEditTimestamp(), getInstanceForUpdate(), getMutableCacheKeys(), getNewMessageLinks(), MediaWiki\Storage\PageEditStash\getStashKey(), getTokenFromOption(), UploadBase\getUploadSessionKey(), RequestContext\importScopedSession(), initEditCountInternal(), MediaWiki\Revision\RevisionStore\insertIpChangesRow(), LocalIdLookup\isAttached(), isRegistered(), loadFromSession(), loadOptions(), SpecialMute\loadTarget(), LogFormatter\makeUserLink(), MovePage\moveToInternal(), EmailNotification\notifyOnPageChange(), pingLimiter(), LocalFile\recordUpload2(), saveOptions(), setNewtalk(), touch(), and SpecialEmailUser\validateTarget().
|
static |
Get a list of implicit groups TODO: Should we deprecate this? It's trivial, but we don't want to encourage use of globals.
Definition at line 4939 of file User.php.
References $wgImplicitGroups.
User::getInstanceForUpdate | ( | ) |
Get a new instance of this user that was loaded from the master via a locking read.
Use this instead of the main context User when updating that user. This avoids races where that user was loaded from a replica DB or even the master but without proper locks.
Definition at line 5416 of file User.php.
References getId().
User::getIntOption | ( | $oname, | |
$defaultOverride = 0 ) |
Get the user's current setting for a given option, as an integer value.
string | $oname | The option to check |
int | $defaultOverride | A default value returned if the option does not exist |
Definition at line 3093 of file User.php.
References getOption().
Referenced by getStubThreshold().
User::getLatestEditTimestamp | ( | ) |
Get the timestamp of the latest edit.
Definition at line 4806 of file User.php.
References getEditTimestamp().
User::getMutableCacheKeys | ( | WANObjectCache | $cache | ) |
WANObjectCache | $cache |
Definition at line 443 of file User.php.
References $cache, getCacheKey(), and getId().
User::getName | ( | ) |
Get the user name, or the IP of an anonymous user.
Implements MediaWiki\User\UserIdentity.
Definition at line 2364 of file User.php.
References getRequest(), isItemLoaded(), and load().
Referenced by MediaWiki\Session\UserInfo\__construct(), __toString(), EmailNotification\actuallyNotifyOnPageChange(), SpecialChangeEmail\attemptChange(), MediaWiki\Auth\AuthManager\autoCreateUser(), MediaWiki\Auth\AuthManager\beginAccountCreation(), MediaWiki\Auth\AuthManager\beginAccountLink(), CentralIdLookup\centralIdFromLocalUser(), MediaWiki\Storage\PageEditStash\checkCache(), PasswordPolicyChecks\checkPasswordCannotMatchBlacklist(), PasswordPolicyChecks\checkPasswordCannotMatchUsername(), SpecialBlock\checkUnblockSelf(), clearNotification(), WikiPage\doEditUpdates(), RecentChange\doMarkPatrolled(), equals(), ApiUnblock\execute(), PasswordReset\execute(), MediaWiki\Extension\OATHAuth\OATHUserRepository\findByUser(), MediaWiki\Preferences\DefaultPreferencesFactory\generateSkinOptions(), MediaWiki\Storage\PageUpdater\getAtomicSectionUpdate(), getBlockedStatus(), ApiQueryUserInfo\getCentralUserInfo(), getGlobalBlock(), getNewMessageLinks(), getNewtalk(), MediaWiki\Storage\PageEditStash\getStashKey(), getTitleKey(), UploadBase\getUploadSessionKey(), ArchivedFile\getUser(), LocalFile\getUser(), getUserPage(), idForName(), MediaWiki\Revision\RevisionStore\insertIpChangesRow(), PasswordReset\isAllowed(), CreditsAction\link(), loadFromSession(), LogFormatter\makeUserLink(), MovePage\moveToInternal(), MailAddress\newFromUser(), EmailNotification\notifyOnPageChange(), MediaWiki\Block\AbstractBlock\parseTarget(), pingLimiter(), SpecialBlock\preText(), SpecialBlock\processForm(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), MediaWiki\Storage\PageEditStash\pruneExcessStashedEntries(), MediaWiki\Storage\PageEditStash\recentStashEntryCount(), LocalFile\recordUpload2(), sendConfirmationMail(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\sendNewAccountEmail(), setEmailWithConfirmation(), setNewtalk(), setPasswordInternal(), MediaWiki\Preferences\DefaultPreferencesFactory\skinPreferences(), spreadBlock(), MediaWiki\Auth\ResetPasswordSecondaryAuthenticationProvider\tryReset(), CreditsAction\userLink(), and SpecialBlock\validateTarget().
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.
Definition at line 2469 of file User.php.
References $dbr, DB_REPLICA, getId(), getName(), getNewtalk(), getTalkPage(), isAnon(), and wfGetDB().
Referenced by getNewMessageRevisionId().
User::getNewMessageRevisionId | ( | ) |
Get the revision ID for the last talk page revision viewed by the talk page owner.
Definition at line 2502 of file User.php.
References getNewMessageLinks().
User::getNewtalk | ( | ) |
Check if the user has new messages.
Definition at line 2431 of file User.php.
References $wgDisableAnonTalk, checkNewtalk(), getName(), and load().
Referenced by clearNotification(), and getNewMessageLinks().
User::getOption | ( | $oname, | |
$defaultOverride = null, | |||
$ignoreHidden = false ) |
Get the user's current setting for a given option.
string | $oname | The option to check |
string | array | null | $defaultOverride | A default value returned if the option does not exist |
bool | $ignoreHidden | Whether to ignore the effects of $wgHiddenPrefs |
Reimplemented in PPFuzzUser.
Definition at line 3022 of file User.php.
References $wgHiddenPrefs, and loadOptions().
Referenced by MediaWiki\EditPage\TextboxBuilder\buildTextboxAttribs(), canReceiveEmail(), MediaWiki\Preferences\DefaultPreferencesFactory\generateSkinOptions(), getBoolOption(), getDatePreference(), getIntOption(), RequestContext\getLanguage(), getTokenFromOption(), Language\internalUserTimeAndDate(), MWTimestamp\offsetForUser(), SkinMonoBook\onGetPreferences(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\sendNewAccountEmail(), and MultimediaViewerHooks\shouldHandleClicks().
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.
IContextSource | $context | |
array | null | $options | Assoc. array with options keys to check as keys. Defaults to $this->mOptions. |
Definition at line 3215 of file User.php.
References $context, and loadOptions().
Referenced by resetOptions().
User::getOptions | ( | $flags = 0 | ) |
Get all user's options.
int | $flags | Bitwise combination of: User::GETOPTIONS_EXCLUDE_DEFAULTS Exclude user options that are set to the default value. (Since 1.25) |
Definition at line 3050 of file User.php.
References $wgHiddenPrefs, and loadOptions().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\loadPreferenceValues().
|
static |
Return the tables, fields, and join conditions to be selected to create a new user object.
$table
to IDatabase->select()
$vars
to IDatabase->select()
$join_conds
to IDatabase->select()
User::getRealName | ( | ) |
Get the user's real name.
Definition at line 2995 of file User.php.
References isItemLoaded(), and load().
Referenced by CreditsAction\link(), MailAddress\newFromUser(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), and CreditsAction\userLink().
User::getRegistration | ( | ) |
Get the timestamp of account creation.
Definition at line 4781 of file User.php.
References isAnon(), and load().
Referenced by Autopromote\checkCondition(), getExperienceLevel(), and MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().
User::getRequest | ( | ) |
Get the WebRequest object to use with this object.
Definition at line 3737 of file User.php.
References $wgRequest.
Referenced by MediaWiki\Extension\OATHAuth\Hook\GetUserPermissionsErrors\CheckExclusiveRights\callback(), MediaWiki\Storage\PageEditStash\checkCache(), Autopromote\checkCondition(), doLogout(), PasswordReset\execute(), getBlockedStatus(), getEditTokenObject(), getGlobalBlock(), getName(), isBlockedFromCreateAccount(), isPingLimitable(), loadFromSession(), pingLimiter(), requiresHTTPS(), sendConfirmationMail(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\sendNewAccountEmail(), setCookies(), setEmailWithConfirmation(), spreadBlock(), and MediaWiki\Block\BlockManager\trackBlockWithCookie().
|
static |
Get the description of a given right.
string | $right | Right to query |
Definition at line 5126 of file User.php.
References wfMessage().
User::getRights | ( | ) |
Get the permissions this user has.
Definition at line 3406 of file User.php.
Referenced by __get().
User::getStubThreshold | ( | ) |
Get the user preferred stub threshold.
Definition at line 3387 of file User.php.
References $wgMaxArticleSize, and getIntOption().
Referenced by MediaWiki\Linker\LinkRendererFactory\createForUser().
User::getTalkPage | ( | ) |
Get this user's talk page title.
Definition at line 4390 of file User.php.
References $title, and getUserPage().
Referenced by getNewMessageLinks(), and MediaWiki\Permissions\PermissionManager\isBlockedFrom().
User::getTitleKey | ( | ) |
User::getToken | ( | $forceCreation = true | ) |
Get the user's current token.
bool | $forceCreation | Force the generation of a new token if the user doesn't have one (default=true for backwards compatibility). |
Definition at line 2846 of file User.php.
References $wgAuthenticationTokenVersion, MWCryptRand\generateHex(), load(), and setToken().
Referenced by getTokenFromOption(), and loadFromSession().
User::getTokenFromOption | ( | $oname | ) |
Get a token stored in the preferences (like the watchlist one), resetting it if it's empty (and saving changes).
string | $oname | The option name to retrieve the token from |
Definition at line 3130 of file User.php.
References $wgHiddenPrefs, getId(), getOption(), and getToken().
|
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.
string | $page | Special page |
string | $token |
Definition at line 4654 of file User.php.
References $title, and NS_MAIN.
Referenced by confirmationTokenUrl(), and invalidationTokenUrl().
User::getTouched | ( | ) |
Get the user touched timestamp.
Use this value only to validate caches via inequalities such as in the case of HTTP If-Modified-Since response logic
Definition at line 2711 of file User.php.
References $cache, load(), and wfTimestamp().
Referenced by validateCache().
User::getUserPage | ( | ) |
Get this user's personal page title.
Definition at line 4381 of file User.php.
References getName(), and NS_USER.
Referenced by addAutopromoteOnceGroups(), MediaWiki\Auth\AuthManager\autoCreateUser(), MediaWiki\Block\AbstractBlock\getBlockErrorParams(), getTalkPage(), SpecialBlock\getTargetUserTitle(), CreditsAction\link(), and saveSettings().
|
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.
string | $group | Group to check |
string | $role | Role to check |
User::idForName | ( | $flags = 0 | ) |
|
static |
Get database id given a user name.
string | $name | Username |
int | $flags | User::READ_* constant bitfield |
Definition at line 871 of file User.php.
References $s, NS_USER, and wfGetDB().
Referenced by MediaWiki\Auth\AuthManager\autoCreateUser().
User::incEditCount | ( | ) |
Schedule a deferred update to update the user's edit count.
Definition at line 5065 of file User.php.
References isAnon().
Referenced by MediaWiki\Storage\PageUpdater\doCreate(), MediaWiki\Storage\PageUpdater\doModify(), and MovePage\moveToInternal().
User::inDnsBlacklist | ( | $ip, | |
$bases ) |
Whether the given IP is in a given DNS blacklist.
string | $ip | IP to check |
string | array | $bases | Array of Strings: URL of the DNS blacklist |
Definition at line 1831 of file User.php.
References $base, wfDebugLog(), and wfDeprecated().
User::initEditCountInternal | ( | IDatabase | $dbr | ) |
User::invalidateCache | ( | ) |
Immediately touch the user data cache for this account.
Calls touch() and removes account data from memcached
Definition at line 2667 of file User.php.
References clearSharedCache(), and touch().
Referenced by addGroup(), addWatch(), getActorId(), removeGroup(), removeWatch(), and setNewtalk().
User::invalidateEmail | ( | ) |
Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already confirmed.
Definition at line 4684 of file User.php.
References load(), and setEmailAuthenticationTimestamp().
Referenced by setEmail().
|
protected |
Return a URL the user can use to invalidate their email address.
string | $token | Accepts the email confirmation token |
Definition at line 4636 of file User.php.
References getTokenUrl().
Referenced by sendConfirmationMail().
User::isAllowed | ( | $action = '' | ) |
Internal mechanics of testing a permission.
string | $action |
Definition at line 3694 of file User.php.
Referenced by addWatch(), canSendEmail(), changeableGroups(), clearAllNotifications(), clearNotification(), isAllowedToCreateAccount(), isBlockedFromCreateAccount(), isBot(), isNewbie(), isPingLimitable(), removeWatch(), and GadgetTest\testIsAllowed().
User::isAllowedAll | ( | $permissions | ) |
string | ...$permissions Permissions to test |
Definition at line 3678 of file User.php.
Referenced by Gadget\isAllowed().
User::isAllowedAny | ( | $permissions | ) |
Check if user is allowed to access a feature / make an action.
string | ...$permissions Permissions to test |
Definition at line 3666 of file User.php.
Referenced by useFilePatrol(), useNPPatrol(), and useRCPatrol().
User::isAllowedToCreateAccount | ( | ) |
Get whether the user is allowed to create an account.
Definition at line 4372 of file User.php.
References isAllowed(), and isBlockedFromCreateAccount().
User::isAllowUsertalk | ( | ) |
Checks if usertalk is allowed.
Definition at line 5446 of file User.php.
Referenced by MediaWiki\Permissions\PermissionManager\isBlockedFrom().
User::isAnon | ( | ) |
Get whether the user is anonymous.
Definition at line 3638 of file User.php.
References isRegistered().
Referenced by MediaWiki\Session\UserInfo\__construct(), MediaWiki\Storage\PageEditStash\checkCache(), WatchAction\checkCanExecute(), MediaWiki\Permissions\PermissionManager\checkQuickPermissions(), clearNotification(), getEditTokenObject(), getExperienceLevel(), getNewMessageLinks(), getRegistration(), incEditCount(), isEmailConfirmed(), CreditsAction\link(), MediaWiki\Session\UserInfo\newFromId(), setNewtalk(), MediaWiki\Block\BlockManager\trackBlockWithCookie(), CreditsAction\userLink(), and SpecialBlock\validateTarget().
User::isBlocked | ( | $fromReplica = true | ) |
Check if user is blocked.
bool | $fromReplica | Whether to check the replica DB instead of the master. Hacked from false due to horrible probs on site. |
Definition at line 2189 of file User.php.
References getBlock().
User::isBlockedFrom | ( | $title, | |
$fromReplica = false ) |
Check if user is blocked from editing a particular article.
Title | $title | Title to check |
bool | $fromReplica | Whether to check the replica DB instead of the master |
Definition at line 2216 of file User.php.
References $title.
Referenced by Action\checkCanExecute().
User::isBlockedFromCreateAccount | ( | ) |
Get whether the user is explicitly blocked from account creation.
Definition at line 4328 of file User.php.
References MediaWiki\Block\AbstractBlock\appliesToRight(), getBlockedStatus(), getRequest(), and isAllowed().
Referenced by MediaWiki\Auth\AuthManager\checkAccountCreatePermissions(), and isAllowedToCreateAccount().
User::isBlockedFromEmailuser | ( | ) |
Get whether the user is blocked from using Special:Emailuser.
Definition at line 4352 of file User.php.
References getBlockedStatus().
User::isBlockedFromUpload | ( | ) |
Get whether the user is blocked from using Special:Upload.
Definition at line 4363 of file User.php.
References getBlockedStatus().
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.
string | $ip | IP address, uses current client if none given |
Definition at line 2256 of file User.php.
References getGlobalBlock().
User::isBot | ( | ) |
Definition at line 3646 of file User.php.
References getGroups(), and isAllowed().
Referenced by MediaWiki\Storage\PageEditStash\checkCache().
|
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.
string | $name | String to match |
Definition at line 1082 of file User.php.
References $wgInvalidUsernameCharacters, and wfDebugLog().
Referenced by MediaWiki\Auth\AuthManager\autoCreateUser().
User::isDnsBlacklisted | ( | $ip, | |
$checkWhitelist = false ) |
Whether the given IP is in a DNS blacklist.
string | $ip | IP to check |
bool | $checkWhitelist | Whether to check the whitelist first |
User::isEmailConfirmationPending | ( | ) |
Check whether there is an outstanding request for e-mail confirmation.
Definition at line 4766 of file User.php.
References $wgEmailAuthentication, isEmailConfirmed(), and wfTimestamp().
User::isEmailConfirmed | ( | ) |
Is this user's e-mail address valid-looking and confirmed within limits of the current site configuration?
Definition at line 4740 of file User.php.
References $wgEmailAuthentication, getEmailAuthenticationTimestamp(), isAnon(), and load().
Referenced by canReceiveEmail(), canSendEmail(), MediaWiki\Permissions\PermissionManager\checkUserBlock(), confirmEmail(), and isEmailConfirmationPending().
|
static |
Check if all users may be assumed to have the given permission.
We generally assume so if the right is granted to '*' and isn't revoked on any group. It doesn't attempt to take grants or other extension limitations on rights into account in the general case, though, as that would require it to always return false and defeat the purpose. Specifically, session-based rights restrictions (such as OAuth or bot passwords) are applied based on the current session.
string | $right | Right to check |
User::isHidden | ( | ) |
Check if user account is hidden.
Definition at line 2318 of file User.php.
References getBlockedStatus().
Referenced by UserrightsPage\fetchUser(), and MediaWiki\Permissions\PermissionManager\isBlockedFrom().
|
static |
Does the string match an anonymous IP address?
This function exists for username validation, in order to reject usernames which are similar in form to IP addresses. Strings such as 300.300.300.300 will return true because it looks like an IP address, despite not being strictly valid.
We match "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.xxx" as an anonymous IP address because the usemod software would "cloak" anonymous IP addresses like this, if we allowed accounts like this to be created new users could get the old edits of these anonymous users.
string | $name | Name to match |
Definition at line 933 of file User.php.
Referenced by MediaWiki\Storage\DerivedPageDataUpdater\doUpdates().
User::isIPRange | ( | ) |
User::isItemLoaded | ( | $item, | |
$all = 'all' ) |
Return whether an item has been loaded.
string | $item | Item to check. Current possibilities:
|
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) |
Definition at line 1275 of file User.php.
References true.
Referenced by getActorId(), getId(), getName(), and getRealName().
|
static |
Check if an IP address is in the local proxy list.
string | $ip |
Definition at line 1879 of file User.php.
References $wgProxyList, and wfDeprecated().
User::isLocked | ( | ) |
User::isLoggedIn | ( | ) |
Get whether the user is logged in.
Definition at line 3630 of file User.php.
References isRegistered().
Referenced by WatchAction\doWatchOrUnwatch(), UppercaseTitlesForUnicodeTransition\execute(), MultimediaViewerHooks\shouldHandleClicks(), and spreadAnyEditBlock().
User::isNewbie | ( | ) |
Determine whether the user is a newbie.
Newbies are either anonymous IPs, or the most recently created accounts.
Definition at line 4400 of file User.php.
References isAllowed().
Referenced by pingLimiter(), and SpecialEmailUser\validateTarget().
User::isPingLimitable | ( | ) |
Is this user subject to rate limiting?
Definition at line 1927 of file User.php.
References $wgRateLimitsExcludedIPs, getRequest(), and isAllowed().
Referenced by pingLimiter().
User::isRegistered | ( | ) |
Alias of isLoggedIn() with a name that describes its actual functionality.
UserIdentity has only this new name and not the old isLoggedIn() variant.
Implements MediaWiki\User\UserIdentity.
Definition at line 3622 of file User.php.
References getId().
Referenced by MediaWiki\Block\BlockManager\getUserBlock(), isAnon(), and isLoggedIn().
User::isSafeToLoad | ( | ) |
Test if it's safe to load this User object.
You should typically check this before using $wgUser or RequestContext::getUser in a method that might be called before the system has been fully initialized. If the object is unsafe, you should use an anonymous user: \code $user = $wgUser->isSafeToLoad() ? $wgUser : new User; \endcode
Definition at line 289 of file User.php.
References $wgFullyInitialised.
|
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.
string | $name | Name to match |
Definition at line 1008 of file User.php.
References $wgReservedUsernames, and wfMessage().
Referenced by MediaWiki\Session\UserInfo\__construct(), MediaWiki\Auth\AuthManager\beginAccountLink(), and MediaWiki\Block\AbstractBlock\setBlocker().
User::isValidPassword | ( | $password | ) |
Is the input a valid password for this user?
string | $password | Desired password |
Definition at line 1112 of file User.php.
References checkPasswordValidity().
|
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.
string | $name | Name to match |
Definition at line 959 of file User.php.
References $wgMaxNameChars.
Referenced by MediaWiki\Session\SessionBackend\save().
User::isWatched | ( | $title, | |
$checkRights = self::CHECK_USER_RIGHTS ) |
Check the watched status of an article.
Title | $title | Title of the article to look at |
bool | $checkRights | Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass User::CHECK_USER_RIGHTS or User::IGNORE_USER_RIGHTS. |
Definition at line 3754 of file User.php.
References $title.
Referenced by WatchAction\doWatchOrUnwatch().
|
static |
Return a list of the types of user options currently returned by User::getOptionKinds().
Currently, the option kinds are:
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.
User::load | ( | $flags = self::READ_NORMAL | ) |
Load the user table data for this object from the source given by mFrom.
int | $flags | User::READ_* constant bitfield |
Reimplemented in PPFuzzUser.
Definition at line 306 of file User.php.
References $wgFullyInitialised, loadDefaults(), loadFromId(), loadFromSession(), and wfGetDB().
Referenced by addGroup(), addToDatabase(), checkAndSetTouched(), confirmationToken(), createNew(), getActorId(), getBlockedStatus(), getDBTouched(), getEmail(), getEmailAuthenticationTimestamp(), getFormerGroups(), getGroupMemberships(), getGroups(), getId(), getName(), getNewtalk(), getRealName(), getRegistration(), getToken(), getTouched(), RequestContext\importScopedSession(), invalidateEmail(), isEmailConfirmed(), loadOptions(), MediaWiki\Session\UserInfo\newFromId(), removeGroup(), resetOptions(), saveSettings(), setCookies(), setEmail(), setEmailAuthenticationTimestamp(), setName(), setNewtalk(), setRealName(), setToken(), and spreadBlock().
User::loadDefaults | ( | $name = false, | |
$actorId = null ) |
Set cached properties to default.
string | bool | $name | |
int | null | $actorId |
Definition at line 1236 of file User.php.
References wfTimestamp().
Referenced by PPFuzzUser\load(), load(), loadFromDatabase(), and loadFromId().
|
protected |
Load user data from shared cache, given mId has already been set.
Definition at line 455 of file User.php.
References $cache, DB_REPLICA, getCacheKey(), loadFromDatabase(), loadGroups(), loadOptions(), wfDebug(), wfGetDB(), and wfTimestamp().
Referenced by loadFromId().
User::loadFromDatabase | ( | $flags = self::READ_LATEST | ) |
Load user and user_group data from the database.
$this->mId must be set, this is how the user is identified.
int | $flags | User::READ_* constant bitfield |
Definition at line 1336 of file User.php.
References $s, getEditCount(), loadDefaults(), loadFromRow(), and wfGetDB().
Referenced by addToDatabase(), loadFromCache(), and loadFromId().
User::loadFromId | ( | $flags = self::READ_NORMAL | ) |
Load user table data, given mId has already been set.
int | $flags | User::READ_* constant bitfield |
Definition at line 391 of file User.php.
References loadDefaults(), loadFromCache(), and loadFromDatabase().
Referenced by MediaWiki\Auth\AuthManager\autoCreateUser(), and load().
|
protected |
Initialize this object from a row from the user table.
stdClass | $row | Row from the user table to load. |
array | null | $data | Further user data to load into the object |
user_groups Array of arrays or stdClass result rows out of the user_groups table. Previously you were supposed to pass an array of strings here, but we also need expiry info nowadays, so an array of strings is ignored. user_properties Array with properties out of the user_properties table
Definition at line 1389 of file User.php.
References loadOptions(), setItemLoaded(), wfTimestamp(), and wfTimestampOrNull().
Referenced by loadFromDatabase(), and newFromRow().
|
private |
Load user data from the session.
Definition at line 1296 of file User.php.
References getId(), getName(), getRequest(), getToken(), and loadFromUserObject().
Referenced by load().
|
protected |
Load the data for this user object from another user object.
User | $user |
Definition at line 1501 of file User.php.
Referenced by loadFromSession().
|
private |
Load the groups from the database if they aren't already loaded.
Definition at line 1511 of file User.php.
References DB_MASTER, DB_REPLICA, and wfGetDB().
Referenced by addGroup(), getGroupMemberships(), getGroups(), loadFromCache(), and removeGroup().
|
protected |
Load the user options either from cache, the database or an array.
array | null | $data | Rows for the current user out of the user_properties table |
Definition at line 5189 of file User.php.
References $dbr, $res, DB_MASTER, DB_REPLICA, getId(), load(), wfDebug(), and wfGetDB().
Referenced by getOption(), getOptionKinds(), getOptions(), loadFromCache(), loadFromRow(), saveOptions(), and setOption().
User::logout | ( | ) |
|
protected |
Builds update conditions.
Additional conditions may be added to $conditions to protected against race conditions using a compare-and-set (CAS) mechanism based on comparing $this->mTouched with the user_touched field.
IDatabase | $db | |
array | $conditions | WHERE conditions for use with Database::update |
Definition at line 1586 of file User.php.
References Wikimedia\Rdbms\IDatabase\timestamp().
User::matchEditToken | ( | $val, | |
$salt = '', | |||
$request = null, | |||
$maxage = null ) |
Check given value against the token value stored in the session.
A match should confirm that the form was submitted from the user's own login session, not a form submission from a third-party site.
string | $val | Input value to compare |
string | array | $salt | Optional function-specific data for hashing |
WebRequest | null | $request | Object to use or null to use $wgRequest |
int | null | $maxage | Fail tokens older than this, in seconds |
Definition at line 4502 of file User.php.
References getEditTokenObject().
Referenced by WikiPage\doRollback(), and matchEditTokenNoSuffix().
User::matchEditTokenNoSuffix | ( | $val, | |
$salt = '', | |||
$request = null, | |||
$maxage = null ) |
Check given value against the token value stored in the session, ignoring the suffix.
string | $val | Input value to compare |
string | array | $salt | Optional function-specific data for hashing |
WebRequest | null | $request | Object to use or null to use $wgRequest |
int | null | $maxage | Fail tokens older than this, in seconds |
Definition at line 4516 of file User.php.
References matchEditToken().
|
static |
Factory function for fatal permission-denied errors.
string | $permission | User right required |
Definition at line 5390 of file User.php.
References $wgLang, getGroupsWithPermission(), and getPermissionManager().
Referenced by MediaWiki\Permissions\PermissionManager\missingPermissionError().
|
static |
Static factory method for creation from a given actor ID.
int | $id | Valid actor ID |
Definition at line 557 of file User.php.
References setItemLoaded().
|
static |
Static factory method for creation from an ID, name, and/or actor ID.
This does not check that the ID, name, and actor ID all correspond to the same user.
int | null | $userId | User ID, if known |
string | null | $userName | User name, if known |
int | null | $actorId | Actor ID, if known |
bool | string | $dbDomain | remote wiki to which the User/Actor ID applies, or false if none |
Definition at line 599 of file User.php.
References setItemLoaded().
Referenced by MediaWiki\Block\DatabaseBlock\initFromRow(), MediaWiki\Revision\RevisionStore\initializeMutableRevisionFromArray(), MediaWiki\Revision\RevisionStoreCacheRecord\loadFreshRow(), MediaWiki\Revision\RevisionStore\newRevisionFromArchiveRow(), and MediaWiki\Revision\RevisionStore\newRevisionFromRowAndSlots().
|
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.
string | $code | Confirmation code |
int | $flags | User::READ_* bitfield |
Definition at line 653 of file User.php.
References DB_MASTER, DB_REPLICA, and wfGetDB().
|
static |
Static factory method for creation from a given user ID.
int | $id | Valid user ID |
Definition at line 542 of file User.php.
References setItemLoaded().
Referenced by MediaWiki\Block\AbstractBlock\__construct(), MediaWiki\Auth\AuthManager\continueAccountCreation(), and MediaWiki\Session\UserInfo\newFromId().
|
static |
Returns a User object corresponding to the given UserIdentity.
UserIdentity | $identity |
Definition at line 574 of file User.php.
References MediaWiki\User\UserIdentity\getActorId(), MediaWiki\User\UserIdentity\getId(), and MediaWiki\User\UserIdentity\getName().
Referenced by MediaWiki\Storage\DerivedPageDataUpdater\doSecondaryDataUpdates(), MediaWiki\Storage\DerivedPageDataUpdater\doUpdates(), MediaWiki\Permissions\PermissionManager\getUserPermissions(), and MediaWiki\Storage\DerivedPageDataUpdater\prepareContent().
|
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.
string | $name | Username, validated by Title::newFromText() |
string | bool | $validate | Validate username. Takes the same parameters as User::getCanonicalName(), except that true is accepted as an alias for 'valid', for BC. |
Definition at line 518 of file User.php.
References setItemLoaded().
Referenced by MediaWiki\Auth\AuthManager\beginAccountCreation(), MediaWiki\Auth\AuthManager\beginAuthentication(), MediaWiki\Auth\AuthManager\canCreateAccount(), MediaWiki\Auth\AuthManager\continueAccountCreation(), MediaWiki\Auth\AuthManager\continueAccountLink(), MediaWiki\Auth\AuthManager\continueAuthentication(), MediaWiki\Storage\DerivedPageDataUpdater\doUpdates(), MediaWiki\Extension\OATHAuth\Api\Module\ApiOATHValidate\execute(), MediaWiki\Extension\OATHAuth\Api\Module\ApiQueryOATH\execute(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProvider\getNewPasswordExpiry(), MediaWiki\Session\UserInfo\newFromName(), MediaWiki\Extension\OATHAuth\Special\DisableOATHForUser\onSubmit(), MediaWiki\Block\AbstractBlock\parseTarget(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\providerAllowsAuthenticationDataChange(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\sendPasswordResetEmail(), and MediaWiki\Block\AbstractBlock\setBlocker().
|
static |
Create a new user object from a user row.
The row should have the following fields from the user table in it:
stdClass | $row | A row from the user table |
array | null | $data | Further data to load into the object (see User::loadFromRow for valid keys) |
Definition at line 699 of file User.php.
References loadFromRow().
|
static |
Create a new user object using data from session.
If the login credentials are invalid, the result is an anonymous user.
WebRequest | null | $request | Object to use; $wgRequest will be used if omitted. |
|
static |
Static factory method for creation of a "system" user from username.
A "system" user is an account that's used to attribute logged actions taken by MediaWiki itself, as opposed to a bot or human user. Examples might include the 'Maintenance script' or 'Conversion script' accounts used by various scripts in the maintenance/ directory or accounts such as 'MediaWiki message delivery' used by the MassMessage extension.
This can optionally create the user if it doesn't exist, and "steal" the account if it does exist.
"Stealing" an existing user is intended to make it impossible for normal authentication processes to use the account, effectively disabling the account for normal use:
string | $name | Username |
array | $options | Options are:
|
Definition at line 740 of file User.php.
References $dbr, DB_MASTER, DB_REPLICA, Wikimedia\Rdbms\IDatabase\delete(), Wikimedia\Rdbms\IDatabase\selectRow(), Wikimedia\Rdbms\IDatabase\update(), and wfGetDB().
|
private |
Generate a current or new-future timestamp to be stored in the user_touched field when we update things.
Definition at line 2622 of file User.php.
References wfTimestamp().
Referenced by addToDatabase(), checkAndSetTouched(), and saveSettings().
User::pingLimiter | ( | $action = 'edit', | |
$incrBy = 1 ) |
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
The method generates both a generic profiling point and a per action one (suffix being "-$action".
string | $action | Action to enforce; 'edit' if unspecified |
int | $incrBy | Positive amount to increment counter by [defaults to 1] |
MWException |
Definition at line 1954 of file User.php.
References $cache, $keys, $wgRateLimits, getGroups(), getId(), getName(), getRequest(), isNewbie(), and isPingLimitable().
Referenced by SpecialChangeEmail\attemptChange(), WikiPage\doRollback(), PasswordReset\execute(), SimpleCaptcha\passCaptchaLimited(), and ChangeTags\updateTagsWithChecks().
|
static |
User::removeGroup | ( | $group | ) |
Remove the user from the given group.
This takes immediate effect.
string | $group | Name of the group to remove |
Definition at line 3588 of file User.php.
References getEffectiveGroups(), invalidateCache(), load(), and loadGroups().
User::removeWatch | ( | $title, | |
$checkRights = self::CHECK_USER_RIGHTS ) |
Stop watching an article.
Title | $title | Title of the article to look at |
bool | $checkRights | Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass User::CHECK_USER_RIGHTS or User::IGNORE_USER_RIGHTS. |
Definition at line 3785 of file User.php.
References $title, invalidateCache(), and isAllowed().
Referenced by WatchAction\doUnwatch().
User::requiresHTTPS | ( | ) |
Determine based on the wiki configuration and the user's options, whether this user must be over HTTPS no matter what.
Definition at line 3365 of file User.php.
References $wgForceHTTPS, $wgSecureLogin, getBoolOption(), getRequest(), and wfCanIPUseHTTPS().
|
static |
|
static |
User::resetOptions | ( | $resetKinds = [ 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' ], | |
IContextSource | $context = null ) |
Reset certain (or all) options to the site defaults.
The optional parameter determines which kinds of preferences will be reset. Supported values are everything that can be reported by getOptionKinds() and 'all', which forces a reset of all preferences and overrides everything else.
array | string | $resetKinds | Which kinds of preferences to reset. Defaults to [ 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' ] for backwards-compatibility. |
IContextSource | null | $context | Context source used when $resetKinds does not contain 'all', passed to getOptionKinds(). Defaults to RequestContext::getMain() when null. |
Definition at line 3300 of file User.php.
References $context, getOptionKinds(), and load().
User::resetTokenFromOption | ( | $oname | ) |
Reset a token stored in the preferences (like the watchlist one).
Does not save user's preferences (similarly to setOption()).
string | $oname | The option name to reset the token in |
Definition at line 3158 of file User.php.
References $wgHiddenPrefs, MWCryptRand\generateHex(), and setOption().
|
protected |
Saves the non-default options for this user, as previously set e.g.
via setOption(), in the database's "user_properties" (preferences) table. Usually used via saveSettings().
Definition at line 5266 of file User.php.
References $res, DB_MASTER, getId(), loadOptions(), and wfGetDB().
Referenced by addToDatabase(), and saveSettings().
User::saveSettings | ( | ) |
Save this user's settings into the database.
Definition at line 4027 of file User.php.
References Wikimedia\Rdbms\IDatabase\affectedRows(), clearSharedCache(), DB_MASTER, getUserPage(), load(), newTouchedTimestamp(), saveOptions(), Wikimedia\Rdbms\IDatabase\timestamp(), Wikimedia\Rdbms\IDatabase\timestampOrNull(), Wikimedia\Rdbms\IDatabase\update(), wfGetDB(), and wfReadOnly().
Referenced by SpecialChangeEmail\attemptChange(), MediaWiki\Auth\AuthManager\autoCreateUser(), MediaWiki\Session\SessionManager\invalidateSessionsForUser(), MediaWiki\Session\SessionBackend\save(), and sendConfirmationMail().
|
static |
Return the list of user fields that should be selected to create a new user object.
Definition at line 5332 of file User.php.
References wfDeprecated().
User::sendConfirmationMail | ( | $type = 'created' | ) |
Generate a new e-mail confirmation token and send a confirmation/invalidation mail to the user's given address.
string | $type | Message to send, either "created", "changed" or "set" |
Definition at line 4528 of file User.php.
References $type, $wgLang, confirmationToken(), confirmationTokenUrl(), getName(), getRequest(), invalidationTokenUrl(), saveSettings(), sendMail(), and wfMessage().
Referenced by setEmailWithConfirmation().
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.
string | $subject | Message subject |
string | $body | Message body |
User | null | $from | Optional sending user; if unspecified, default $wgPasswordSender will be used. |
MailAddress | null | $replyto | Reply-To address |
Definition at line 4583 of file User.php.
References $wgPasswordSender, MailAddress\newFromUser(), UserMailer\send(), and wfMessage().
Referenced by sendConfirmationMail(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\sendNewAccountEmail(), and setEmailWithConfirmation().
User::setCookies | ( | $request = null, | |
$secure = null, | |||
$rememberMe = false ) |
Persist this user's session (e.g.
set cookies)
WebRequest | null | $request | WebRequest object to use; $wgRequest will be used if null is passed. |
bool | null | $secure | Whether to force secure/insecure cookies or use default |
bool | $rememberMe | Whether to add a Token cookie for elongated sessions |
Definition at line 3943 of file User.php.
References getRequest(), and load().
User::setEditCountInternal | ( | $count | ) |
User::setEmail | ( | $str | ) |
Set the user's e-mail address.
string | $str | New e-mail address |
Definition at line 2925 of file User.php.
References invalidateEmail(), and load().
Referenced by setEmailWithConfirmation().
User::setEmailAuthenticationTimestamp | ( | $timestamp | ) |
Set the e-mail authentication timestamp.
string | $timestamp | TS_MW timestamp |
Definition at line 4698 of file User.php.
References load().
Referenced by confirmEmail(), and invalidateEmail().
User::setEmailWithConfirmation | ( | $str | ) |
Set the user's e-mail address and a confirmation mail if needed.
string | $str | New e-mail address |
Definition at line 2942 of file User.php.
References $type, $wgEmailAuthentication, $wgEnableEmail, getEmail(), getName(), getRequest(), sendConfirmationMail(), sendMail(), setEmail(), and wfMessage().
Referenced by SpecialChangeEmail\attemptChange().
User::setId | ( | $v | ) |
Set the user and reload all fields according to a given ID.
int | $v | User ID to reload |
Definition at line 2355 of file User.php.
References clearInstanceCache().
Referenced by MediaWiki\Auth\AuthManager\autoCreateUser().
User::setInternalPassword | ( | $str | ) |
Set the password and reset the random token unconditionally.
string | null | $str | New 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 2768 of file User.php.
References setPasswordInternal(), and wfDeprecated().
|
protected |
Set that an item has been loaded.
string | $item |
Definition at line 1285 of file User.php.
Referenced by getActorId(), loadFromRow(), newFromActorId(), newFromAnyId(), newFromId(), and newFromName().
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.
string | $str | New user name to set |
Definition at line 2392 of file User.php.
References load().
Referenced by MediaWiki\Auth\AuthManager\continueAccountCreation().
User::setNewtalk | ( | $val, | |
$curRev = null ) |
Update the 'You have new messages!' status.
bool | $val | Whether the user has new messages |
Revision | null | $curRev | New, as yet unseen revision of the user talk page. Ignored if null or !$val. |
Definition at line 2589 of file User.php.
References deleteNewtalk(), getId(), getName(), invalidateCache(), isAnon(), load(), updateNewtalk(), and wfReadOnly().
Referenced by clearAllNotifications(), and clearNotification().
User::setOption | ( | $oname, | |
$val ) |
Set the given option for a user.
You need to call saveSettings() to actually write to the database.
string | $oname | The option to set |
mixed | $val | New value to set |
Definition at line 3109 of file User.php.
References loadOptions().
Referenced by resetTokenFromOption(), MediaWiki\Auth\AuthManager\setDefaultUserOptions(), and setPasswordInternal().
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.
string | $str | New password to set |
PasswordError | On failure |
Definition at line 2755 of file User.php.
References setPasswordInternal(), and wfDeprecated().
|
private |
Actually set the password and such.
string | null | $str | New 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 2781 of file User.php.
References changeAuthenticationData(), getName(), and setOption().
Referenced by setInternalPassword(), and setPassword().
User::setRealName | ( | $str | ) |
User::setToken | ( | $token = false | ) |
Set the random token (used for persistent authentication) Called from loadDefaults() among other places.
string | bool | $token | If specified, set the token to this value |
Definition at line 2889 of file User.php.
References MWCryptRand\generateHex(), and load().
Referenced by addToDatabase(), getToken(), MediaWiki\Session\SessionManager\invalidateSessionsForUser(), and MediaWiki\Auth\AuthManager\setDefaultUserOptions().
User::spreadAnyEditBlock | ( | ) |
If this user is logged-in and blocked, block any IP address they've successfully logged in from.
Definition at line 4296 of file User.php.
References getBlock(), isLoggedIn(), and spreadBlock().
Referenced by MovePage\moveIfAllowed().
|
protected |
If this (non-anonymous) user is blocked, block the IP address they've successfully logged in from.
Definition at line 4309 of file User.php.
References getName(), getRequest(), load(), and wfDebug().
Referenced by spreadAnyEditBlock().
User::touch | ( | ) |
Update the "touched" timestamp for the user.
This is useful on various login/logout events when making sure that a browser or proxy that has multiple tenants does not suffer cache pollution where the new user sees the old users content. The value of getTouched() is checked when determining 304 vs 200 responses. Unlike invalidateCache(), this preserves the User object cache and avoids database writes.
Definition at line 2684 of file User.php.
References $cache, and getId().
Referenced by invalidateCache().
User::trackBlockWithCookie | ( | ) |
Set the 'BlockID' cookie depending on block type and user authentication status.
|
private |
Update the actor ID after an insert.
IDatabase | $dbw | Writable database handle |
Definition at line 4282 of file User.php.
References Wikimedia\Rdbms\IDatabase\insert(), and Wikimedia\Rdbms\IDatabase\insertId().
Referenced by addToDatabase().
|
protected |
Add or update the new messages flag.
string | $field | 'user_ip' for anonymous users, 'user_id' otherwise |
string | int | $id | User's IP address for anonymous users, User ID otherwise |
Revision | null | $curRev | New, as yet unseen revision of the user talk page. Ignored if null. |
Definition at line 2544 of file User.php.
References DB_MASTER, wfDebug(), and wfGetDB().
Referenced by setNewtalk().
User::useFilePatrol | ( | ) |
Check whether to enable new files patrol features for this user.
Definition at line 3724 of file User.php.
References $wgUseFilePatrol, $wgUseRCPatrol, and isAllowedAny().
Referenced by ChangesList\isUnpatrolled().
User::useNPPatrol | ( | ) |
Check whether to enable new pages patrol features for this user.
Definition at line 3712 of file User.php.
References $wgUseNPPatrol, $wgUseRCPatrol, and isAllowedAny().
Referenced by WatchedItemQueryService\getWatchedItemsWithRCInfoQueryFilterConds(), ChangesList\isUnpatrolled(), and MediaWiki\Preferences\DefaultPreferencesFactory\rcPreferences().
User::useRCPatrol | ( | ) |
Check whether to enable recent changes patrol features for this user.
Definition at line 3703 of file User.php.
References $wgUseRCPatrol, and isAllowedAny().
Referenced by WatchedItemQueryService\getWatchedItemsWithRCInfoQueryFilterConds(), ChangesList\isUnpatrolled(), MediaWiki\Preferences\DefaultPreferencesFactory\rcPreferences(), and MediaWiki\Preferences\DefaultPreferencesFactory\watchlistPreferences().
User::validateCache | ( | $timestamp | ) |
Validate the cache for this account.
string | $timestamp | A timestamp in TS_MW format |
Definition at line 2699 of file User.php.
References getTouched().
|
static |
Get the username corresponding to a given user ID.
int | $id | User ID |
Definition at line 851 of file User.php.
References UserCache\singleton().
Referenced by MediaWiki\Permissions\PermissionManager\checkActionPermissions().
|
static |
Get the real name of a user given their user ID.
int | $id | User ID |
Definition at line 861 of file User.php.
References UserCache\singleton().
|
staticprivate |
|
staticprivate |
AbstractBlock User::$mBlock |
|
private |
|
staticprotected |
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.
string User::$mFrom |
Initialization data source if mLoadedItems!==true.
May be one of:
Use the User::newFrom*() family of functions to set this.
|
protected |
|
protected |
Associative array of (group name => UserGroupMembership object)
|
protected |
|
protected |
bool User::$mOptionsLoaded |
|
protected |
|
private |
|
protected |
|
staticprivate |
const User::GETOPTIONS_EXCLUDE_DEFAULTS = 1 |
const User::IGNORE_USER_RIGHTS = false |
Definition at line 83 of file User.php.
Referenced by MediaWiki\Auth\AuthManager\autoCreateUser(), and MediaWiki\Auth\AuthManager\continueAccountCreation().
const User::INVALID_TOKEN = '*** INVALID ***' |
const User::TOKEN_LENGTH = 32 |
const User::VERSION = 14 |
Version number to tag cached versions of serialized User objects.
Should be increased when $mCacheVars
or one of it's members changes.