* This is slightly less efficient than newFromId(), so use newFromId() if
* you have both an ID and a name handy.
*
- * @param $name String Username, validated by Title::newFromText()
- * @param $validate String|Bool Validate username. Takes the same parameters as
+ * @param string $name Username, validated by Title::newFromText()
+ * @param string|Bool $validate Validate username. Takes the same parameters as
* User::getCanonicalName(), except that true is accepted as an alias
* for 'valid', for BC.
*
/**
* Static factory method for creation from a given user ID.
*
- * @param $id Int Valid user ID
+ * @param int $id Valid user ID
* @return User The corresponding User object
*/
public static function newFromId( $id ) {
*
* If the code is invalid or has expired, returns NULL.
*
- * @param $code String Confirmation code
+ * @param string $code Confirmation code
* @return User object, or null
*/
public static function newFromConfirmationCode( $code ) {
* Create a new user object using data from session or cookies. If the
* login credentials are invalid, the result is an anonymous user.
*
- * @param $request WebRequest object to use; $wgRequest will be used if
- * ommited.
+ * @param $request WebRequest object to use; $wgRequest will be used if omitted.
* @return User object
*/
public static function newFromSession( WebRequest $request = null ) {
* user_name and user_real_name are not provided because the whole row
* will be loaded once more from the database when accessing them.
*
- * @param $row Array A row from the user table
- * @param $data Array Further data to load into the object (see User::loadFromRow for valid keys)
+ * @param array $row A row from the user table
+ * @param array $data Further data to load into the object (see User::loadFromRow for valid keys)
* @return User
*/
public static function newFromRow( $row, $data = null ) {
/**
* Get the username corresponding to a given user ID
- * @param $id Int User ID
+ * @param int $id User ID
* @return String|bool The corresponding username
*/
public static function whoIs( $id ) {
/**
* Get the real name of a user given their user ID
*
- * @param $id Int User ID
+ * @param int $id User ID
* @return String|bool The corresponding user's real name
*/
public static function whoIsReal( $id ) {
/**
* Get database id given a user name
- * @param $name String Username
+ * @param string $name Username
* @return Int|Null The corresponding user's ID, or null if user is nonexistent
*/
public static function idFromName( $name ) {
* addresses like this, if we allowed accounts like this to be created
* new users could get the old edits of these anonymous users.
*
- * @param $name String to match
+ * @param string $name to match
* @return Bool
*/
public static function isIP( $name ) {
* 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 containins slashes (would mess up subpages),
+ * 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.
*
- * @param $name String to match
+ * @param string $name to match
* @return Bool
*/
public static function isValidUserName( $name ) {
return false;
}
-
// Ensure that the name can't be misresolved as a different title,
// such as with extra namespace keys at the start.
$parsed = Title::newFromText( $name );
* If an account already exists in this form, login will be blocked
* by a failure to pass this function.
*
- * @param $name String to match
+ * @param string $name to match
* @return Bool
*/
public static function isUsableName( $name ) {
* Additional blacklisting may be added here rather than in
* isValidUserName() to avoid disrupting existing accounts.
*
- * @param $name String to match
+ * @param string $name to match
* @return Bool
*/
public static function isCreatableName( $name ) {
/**
* Is the input a valid password for this user?
*
- * @param $password String Desired password
+ * @param string $password Desired password
* @return Bool
*/
public function isValidPassword( $password ) {
/**
* Given unvalidated password input, return error message on failure.
*
- * @param $password String Desired password
+ * @param string $password Desired password
* @return mixed: true on success, string or array of error message on failure
*/
public function getPasswordValidity( $password ) {
return 'passwordtooshort';
} elseif ( $wgContLang->lc( $password ) == $wgContLang->lc( $this->mName ) ) {
return 'password-name-match';
- } elseif ( isset( $blockedLogins[ $this->getName() ] ) && $password == $blockedLogins[ $this->getName() ] ) {
+ } elseif ( isset( $blockedLogins[$this->getName()] ) && $password == $blockedLogins[$this->getName()] ) {
return 'password-login-forbidden';
} else {
//it seems weird returning true here, but this is because of the
* to be liberal enough for wide use. Some invalid addresses will still
* pass validation here.
*
- * @param $addr String E-mail address
+ * @param string $addr E-mail address
* @return Bool
* @deprecated since 1.18 call Sanitizer::isValidEmail() directly
*/
/**
* Given unvalidated user input, return a canonical username, or false if
* the username is invalid.
- * @param $name String User input
- * @param $validate String|Bool type of validation to use:
+ * @param string $name User input
+ * @param string|Bool $validate type of validation to use:
* - false No validation
* - 'valid' Valid for batch processes
* - 'usable' Valid for batch processes and login
/**
* Count the number of edits of a user
*
- * @param $uid Int User ID to check
+ * @param int $uid User ID to check
* @return Int the user's edit count
*
* @deprecated since 1.21 in favour of User::getEditCount
* @note This no longer clears uncached lazy-initialised properties;
* the constructor does that instead.
*
- * @param $name string
+ * @param $name string|bool
*/
public function loadDefaults( $name = false ) {
wfProfileIn( __METHOD__ );
/**
* Return whether an item has been loaded.
*
- * @param $item String: item to check. Current possibilities:
+ * @param string $item item to check. Current possibilities:
* - id
* - name
* - realname
- * @param $all String: 'all' to check if the whole object has been loaded
+ * @param 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)
* @return Boolean
* @return Bool True if the user is logged in, false otherwise.
*/
private function loadFromSession() {
- global $wgExternalAuthType, $wgAutocreatePolicy;
-
$result = null;
wfRunHooks( 'UserLoadFromSession', array( $this, &$result ) );
if ( $result !== null ) {
return $result;
}
- if ( $wgExternalAuthType && $wgAutocreatePolicy == 'view' ) {
- $extUser = ExternalUser::newFromCookie();
- if ( $extUser ) {
- # TODO: Automatically create the user here (or probably a bit
- # lower down, in fact)
- }
- }
-
$request = $this->getRequest();
$cookieId = $request->getCookie( 'UserID' );
/**
* Initialize this object from a row from the user table.
*
- * @param $row Array Row from the user table to load.
- * @param $data Array Further user data to load into the object
+ * @param array $row Row from the user table to load.
+ * @param array $data Further user data to load into the object
*
* user_groups Array with groups out of the user_groups table
* user_properties Array with properties out of the user_properties table
* will not be re-added automatically. The user will also not lose the
* group if they no longer meet the criteria.
*
- * @param $event String key in $wgAutopromoteOnce (each one has groups/criteria)
+ * @param string $event key in $wgAutopromoteOnce (each one has groups/criteria)
*
* @return array Array of groups the user has been promoted to.
*
* 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.
*
- * @param $reloadFrom bool|String Reload user and user_groups table data from a
+ * @param bool|String $reloadFrom Reload user and user_groups table data from a
* given source. May be "name", "id", "defaults", "session", or false for
* no reload.
*/
/**
* Get a given default option value.
*
- * @param $opt String Name of option to retrieve
+ * @param string $opt Name of option to retrieve
* @return String Default option value
*/
public static function getDefaultOption( $opt ) {
}
}
-
/**
* Get blocking information
- * @param $bFromSlave Bool Whether to check the slave database first. To
+ * @param bool $bFromSlave Whether to check the slave database first. To
* improve performance, non-critical checks are done
* against slaves. Check when actually saving should be
* done against master.
*/
private function getBlockedStatus( $bFromSlave = true ) {
- global $wgProxyWhitelist, $wgUser;
+ global $wgProxyWhitelist, $wgUser, $wgApplyIpBlocksToXff;
if ( -1 != $this->mBlockedby ) {
return;
}
}
+ # (bug 23343) Apply IP blocks to the contents of XFF headers, if enabled
+ if ( !$block instanceof Block
+ && $wgApplyIpBlocksToXff
+ && $ip !== null
+ && !$this->isAllowed( 'proxyunbannable' )
+ && !in_array( $ip, $wgProxyWhitelist )
+ ) {
+ $xff = $this->getRequest()->getHeader( 'X-Forwarded-For' );
+ $xff = array_map( 'trim', explode( ',', $xff ) );
+ $xff = array_diff( $xff, array( $ip ) );
+ $xffblocks = Block::getBlocksForIPList( $xff, $this->isAnon(), !$bFromSlave );
+ $block = Block::chooseBlock( $xffblocks, $xff );
+ if ( $block instanceof Block ) {
+ # Mangle the reason to alert the user that the block
+ # originated from matching the X-Forwarded-For header.
+ $block->mReason = wfMessage( 'xffblockreason', $block->mReason )->text();
+ }
+ }
+
if ( $block instanceof Block ) {
wfDebug( __METHOD__ . ": Found block.\n" );
$this->mBlock = $block;
$this->mAllowUsertalk = false;
}
- # Extensions
+ // Extensions
wfRunHooks( 'GetBlockedStatus', array( &$this ) );
wfProfileOut( __METHOD__ );
/**
* Whether the given IP is in a DNS blacklist.
*
- * @param $ip String IP to check
- * @param $checkWhitelist Bool: whether to check the whitelist first
+ * @param string $ip IP to check
+ * @param bool $checkWhitelist whether to check the whitelist first
* @return Bool True if blacklisted.
*/
public function isDnsBlacklisted( $ip, $checkWhitelist = false ) {
/**
* Whether the given IP is in a given DNS blacklist.
*
- * @param $ip String IP to check
- * @param $bases String|Array of Strings: URL of the DNS blacklist
+ * @param string $ip IP to check
+ * @param string|array $bases of Strings: URL of the DNS blacklist
* @return Bool True if blacklisted.
*/
public function inDnsBlacklist( $ip, $bases ) {
* @note When using a shared cache like memcached, IP-address
* last-hit counters will be shared across wikis.
*
- * @param $action String Action to enforce; 'edit' if unspecified
+ * @param string $action Action to enforce; 'edit' if unspecified
* @return Bool True if a rate limiter was tripped
*/
public function pingLimiter( $action = 'edit' ) {
// Set the user limit key
if ( $userLimit !== false ) {
wfDebug( __METHOD__ . ": effective user limit: $userLimit\n" );
- $keys[ wfMemcKey( 'limiter', $action, 'user', $id ) ] = $userLimit;
+ $keys[wfMemcKey( 'limiter', $action, 'user', $id )] = $userLimit;
}
$triggered = false;
/**
* Check if user is blocked
*
- * @param $bFromSlave Bool Whether to check the slave database instead of the master
+ * @param bool $bFromSlave Whether to check the slave database instead of the master
* @return Bool True if blocked, false otherwise
*/
public function isBlocked( $bFromSlave = true ) { // hacked from false due to horrible probs on site
/**
* Get the block affecting the user, or null if the user is not blocked
*
- * @param $bFromSlave Bool Whether to check the slave database instead of the master
+ * @param bool $bFromSlave Whether to check the slave database instead of the master
* @return Block|null
*/
public function getBlock( $bFromSlave = true ) {
* Check if user is blocked from editing a particular article
*
* @param $title Title to check
- * @param $bFromSlave Bool whether to check the slave database instead of the master
+ * @param bool $bFromSlave whether to check the slave database instead of the master
* @return Bool
*/
function isBlockedFrom( $title, $bFromSlave = false ) {
/**
* Check if user is blocked on all wikis.
* Do not use for actual edit permission checks!
- * This is intented for quick UI checks.
+ * This is intended for quick UI checks.
*
- * @param $ip String IP address, uses current client if none given
+ * @param string $ip IP address, uses current client if none given
* @return Bool True if blocked, false otherwise
*/
public function isBlockedGlobally( $ip = '' ) {
/**
* Set the user and reload all fields according to a given ID
- * @param $v Int User ID to reload
+ * @param int $v User ID to reload
*/
public function setId( $v ) {
$this->mId = $v;
* address for an anonymous user to something other than the current
* remote IP.
*
- * @note User::newFromName() has rougly the same function, when the named user
+ * @note User::newFromName() has roughly the same function, when the named user
* does not exist.
- * @param $str String New user name to set
+ * @param string $str New user name to set
*/
public function setName( $str ) {
$this->load();
* Internal uncached check for new messages
*
* @see getNewtalk()
- * @param $field String 'user_ip' for anonymous users, 'user_id' otherwise
- * @param $id String|Int User's IP address for anonymous users, User ID otherwise
- * @param $fromMaster Bool true to fetch from the master, false for a slave
+ * @param string $field 'user_ip' for anonymous users, 'user_id' otherwise
+ * @param string|Int $id User's IP address for anonymous users, User ID otherwise
+ * @param bool $fromMaster true to fetch from the master, false for a slave
* @return Bool True if the user has new messages
*/
protected function checkNewtalk( $field, $id, $fromMaster = false ) {
/**
* Add or update the new messages flag
- * @param $field String 'user_ip' for anonymous users, 'user_id' otherwise
- * @param $id String|Int User's IP address for anonymous users, User ID otherwise
+ * @param string $field 'user_ip' for anonymous users, 'user_id' otherwise
+ * @param string|Int $id User's IP address for anonymous users, User ID otherwise
* @param $curRev Revision new, as yet unseen revision of the user talk page. Ignored if null.
* @return Bool True if successful, false otherwise
*/
/**
* Clear the new messages flag for the given user
- * @param $field String 'user_ip' for anonymous users, 'user_id' otherwise
- * @param $id String|Int User's IP address for anonymous users, User ID otherwise
+ * @param string $field 'user_ip' for anonymous users, 'user_id' otherwise
+ * @param string|Int $id User's IP address for anonymous users, User ID otherwise
* @return Bool True if successful, false otherwise
*/
protected function deleteNewtalk( $field, $id ) {
/**
* Update the 'You have new messages!' status.
- * @param $val Bool Whether the user has new messages
+ * @param bool $val Whether the user has new messages
* @param $curRev Revision new, as yet unseen revision of the user talk page. Ignored if null or !$val.
*/
public function setNewtalk( $val, $curRev = null ) {
* for reload on the next hit.
*/
public function invalidateCache() {
- if( wfReadOnly() ) {
+ if ( wfReadOnly() ) {
return;
}
$this->load();
- if( $this->mId ) {
+ if ( $this->mId ) {
$this->mTouched = self::newTouchedTimestamp();
$dbw = wfGetDB( DB_MASTER );
-
- // Prevent contention slams by checking user_touched first
- $now = $dbw->timestamp( $this->mTouched );
- $needsPurge = $dbw->selectField( 'user', '1',
- array( 'user_id' => $this->mId, 'user_touched < ' . $dbw->addQuotes( $now ) )
- );
- if ( $needsPurge ) {
- $dbw->update( 'user',
- array( 'user_touched' => $now ),
- array( 'user_id' => $this->mId, 'user_touched < ' . $dbw->addQuotes( $now ) ),
- __METHOD__
- );
- }
-
+ $userid = $this->mId;
+ $touched = $this->mTouched;
+ $dbw->onTransactionIdle( function() use ( $dbw, $userid, $touched ) {
+ // Prevent contention slams by checking user_touched first
+ $encTouched = $dbw->addQuotes( $dbw->timestamp( $touched ) );
+ $needsPurge = $dbw->selectField( 'user', '1',
+ array( 'user_id' => $userid, 'user_touched < ' . $encTouched ) );
+ if ( $needsPurge ) {
+ $dbw->update( 'user',
+ array( 'user_touched' => $dbw->timestamp( $touched ) ),
+ array( 'user_id' => $userid, 'user_touched < ' . $encTouched ),
+ __METHOD__
+ );
+ }
+ } );
$this->clearSharedCache();
}
}
/**
* Validate the cache for this account.
- * @param $timestamp String A timestamp in TS_MW format
+ * @param string $timestamp A timestamp in TS_MW format
*
* @return bool
*/
* wipes it, so the account cannot be logged in until
* a new password is set, for instance via e-mail.
*
- * @param $str String New password to set
+ * @param string $str New password to set
* @throws PasswordError on failure
*
* @return bool
/**
* Set the password and reset the random token unconditionally.
*
- * @param $str string|null New password to set or null to set an invalid
+ * @param 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.
*/
/**
* Get the user's current token.
- * @param $forceCreation Force the generation of a new token if the user doesn't have one (default=true for backwards compatibility)
+ * @param bool $forceCreation Force the generation of a new token if the user doesn't have one (default=true for backwards compatibility)
* @return String Token
*/
public function getToken( $forceCreation = true ) {
* Set the random token (used for persistent authentication)
* Called from loadDefaults() among other places.
*
- * @param $token String|bool If specified, set the token to this value
+ * @param string|bool $token If specified, set the token to this value
*/
public function setToken( $token = false ) {
$this->load();
/**
* Set the password for a password reminder or new account email
*
- * @param $str String New password to set
- * @param $throttle Bool If true, reset the throttle timestamp to the present
+ * @param string $str New password to set
+ * @param bool $throttle If true, reset the throttle timestamp to the present
*/
public function setNewpassword( $str, $throttle = true ) {
$this->load();
/**
* Set the user's e-mail address
- * @param $str String New e-mail address
+ * @param string $str New e-mail address
*/
public function setEmail( $str ) {
$this->load();
* Set the user's e-mail address and a confirmation mail if needed.
*
* @since 1.20
- * @param $str String New e-mail address
+ * @param string $str New e-mail address
* @return Status
*/
public function setEmailWithConfirmation( $str ) {
/**
* Set the user's real name
- * @param $str String New real name
+ * @param string $str New real name
*/
public function setRealName( $str ) {
$this->load();
/**
* Get the user's current setting for a given option.
*
- * @param $oname String The option to check
- * @param $defaultOverride String A default value returned if the option does not exist
- * @param $ignoreHidden Bool = whether to ignore the effects of $wgHiddenPrefs
+ * @param string $oname The option to check
+ * @param string $defaultOverride A default value returned if the option does not exist
+ * @param bool $ignoreHidden = whether to ignore the effects of $wgHiddenPrefs
* @return String User's current value for the option
* @see getBoolOption()
* @see getIntOption()
/**
* Get the user's current setting for a given option, as a boolean value.
*
- * @param $oname String The option to check
+ * @param string $oname The option to check
* @return Bool User's current value for the option
* @see getOption()
*/
/**
* Get the user's current setting for a given option, as a boolean value.
*
- * @param $oname String The option to check
- * @param $defaultOverride Int A default value returned if the option does not exist
+ * @param string $oname The option to check
+ * @param int $defaultOverride A default value returned if the option does not exist
* @return Int User's current value for the option
* @see getOption()
*/
/**
* Set the given option for a user.
*
- * @param $oname String The option to set
+ * @param string $oname The option to set
* @param $val mixed New value to set
*/
public function setOption( $oname, $val ) {
*
* @see User::listOptionKinds
* @param $context IContextSource
- * @param $options array assoc. array with options keys to check as keys. Defaults to $this->mOptions.
+ * @param array $options assoc. array with options keys to check as keys. Defaults to $this->mOptions.
* @return array the key => kind mapping data
*/
public function getOptionKinds( IContextSource $context, $options = null ) {
* Supported values are everything that can be reported by getOptionKinds()
* and 'all', which forces a reset of *all* preferences and overrides everything else.
*
- * @param $resetKinds array|string which kinds of preferences to reset. Defaults to
+ * @param array|string $resetKinds which kinds of preferences to reset. Defaults to
* array( 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' )
* for backwards-compatibility.
* @param $context IContextSource|null context source used when $resetKinds
* 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
- * @param $recache Bool Whether to avoid the cache
+ * @param bool $recache Whether to avoid the cache
* @return Array of String internal group names
*/
public function getEffectiveGroups( $recache = false ) {
* Get the list of implicit group memberships this user has.
* This includes 'user' if logged in, '*' for all accounts,
* and autopromoted groups
- * @param $recache Bool Whether to avoid the cache
+ * @param bool $recache Whether to avoid the cache
* @return Array of String internal group names
*/
public function getAutomaticGroups( $recache = false ) {
/**
* Add the user to the given group.
* This takes immediate effect.
- * @param $group String Name of the group to add
+ * @param string $group Name of the group to add
*/
public function addGroup( $group ) {
if( wfRunHooks( 'UserAddGroup', array( $this, &$group ) ) ) {
/**
* Remove the user from the given group.
* This takes immediate effect.
- * @param $group String Name of the group to remove
+ * @param string $group Name of the group to remove
*/
public function removeGroup( $group ) {
$this->load();
/**
* Set this user's options from an encoded string
- * @param $str String Encoded options to import
+ * @param string $str Encoded options to import
*
* @deprecated in 1.19 due to removal of user_options from the user table
*/
/**
* Set a cookie on the user's client. Wrapper for
* WebResponse::setCookie
- * @param $name String Name of the cookie to set
- * @param $value String Value to set
- * @param $exp Int Expiration time, as a UNIX time value;
+ * @param string $name Name of the cookie to set
+ * @param string $value Value to set
+ * @param int $exp Expiration time, as a UNIX time value;
* if 0 or not specified, use the default $wgCookieExpiration
* @param $secure Bool
* true: Force setting the secure attribute when setting the cookie
/**
* Clear a cookie on the user's client
- * @param $name String Name of the cookie to clear
+ * @param string $name Name of the cookie to clear
*/
protected function clearCookie( $name ) {
$this->setCookie( $name, '', time() - 86400 );
*
* @param $request WebRequest object to use; $wgRequest will be used if null
* is passed.
- * @param $secure Whether to force secure/insecure cookies or use default
+ * @param bool $secure Whether to force secure/insecure cookies or use default
*/
public function setCookies( $request = null, $secure = null ) {
if ( $request === null ) {
}
$this->load();
- if ( 0 == $this->mId ) return;
+ if ( 0 == $this->mId ) {
+ return;
+ }
if ( !$this->mToken ) {
// When token is empty or NULL generate a new one and then save it to the database
// This allows a wiki to re-secure itself after a leak of it's user table or $wgSecretKey
/**
* Add a user to the database, return the user object
*
- * @param $name String Username to add
- * @param $params Array of Strings Non-default parameters to save to the database as user_* fields:
+ * @param string $name Username to add
+ * @param array $params of Strings Non-default parameters to save to the database as user_* fields:
* - password The user's password hash. Password logins will be disabled if this is omitted.
* - newpassword Hash for a temporary password that has been mailed to the user
* - email The user's email address
// since it disables the parser cache, its value will always
// be 0 when this function is called by parsercache.
- $confstr = $this->getOption( 'math' );
+ $confstr = $this->getOption( 'math' );
$confstr .= '!' . $this->getStubThreshold();
$confstr .= '!' . ( $this->getOption( 'numberheadings' ) ? '1' : '' );
$confstr .= '!' . $wgLang->getCode();
/**
* Check to see if the given clear-text password is one of the accepted passwords
- * @param $password String: user password.
+ * @param string $password user password.
* @return Boolean: True if the given password is correct, otherwise False.
*/
public function checkPassword( $password ) {
* Alias for getEditToken.
* @deprecated since 1.19, use getEditToken instead.
*
- * @param $salt String|Array of Strings Optional function-specific data for hashing
+ * @param string|array $salt of Strings Optional function-specific data for hashing
* @param $request WebRequest object to use or null to use $wgRequest
* @return String The new edit token
*/
*
* @since 1.19
*
- * @param $salt String|Array of Strings Optional function-specific data for hashing
+ * @param string|array $salt of Strings Optional function-specific data for hashing
* @param $request WebRequest object to use or null to use $wgRequest
* @return String The new edit token
*/
/**
* Generate a looking random token for various uses.
*
- * @param $salt String Optional salt value
* @return String The new random token
- * @deprecated since 1.20; Use MWCryptRand for secure purposes or wfRandomString for pesudo-randomness
+ * @deprecated since 1.20; Use MWCryptRand for secure purposes or wfRandomString for pseudo-randomness
*/
- public static function generateToken( $salt = '' ) {
+ public static function generateToken() {
return MWCryptRand::generateHex( 32 );
}
* user's own login session, not a form submission from a third-party
* site.
*
- * @param $val String Input value to compare
- * @param $salt String Optional function-specific data for hashing
+ * @param string $val Input value to compare
+ * @param string $salt Optional function-specific data for hashing
* @param $request WebRequest object to use or null to use $wgRequest
* @return Boolean: Whether the token matches
*/
* Check given value against the token value stored in the session,
* ignoring the suffix.
*
- * @param $val String Input value to compare
- * @param $salt String Optional function-specific data for hashing
+ * @param string $val Input value to compare
+ * @param string $salt Optional function-specific data for hashing
* @param $request WebRequest object to use or null to use $wgRequest
* @return Boolean: Whether the token matches
*/
* Generate a new e-mail confirmation token and send a confirmation/invalidation
* mail to the user's given address.
*
- * @param $type String: message to send, either "created", "changed" or "set"
+ * @param string $type message to send, either "created", "changed" or "set"
* @return Status object
*/
public function sendConfirmationMail( $type = 'created' ) {
* Send an e-mail to this user's account. Does not check for
* confirmed status or validity.
*
- * @param $subject String Message subject
- * @param $body String Message body
- * @param $from String Optional From address; if unspecified, default $wgPasswordSender will be used
- * @param $replyto String Reply-To address
+ * @param string $subject Message subject
+ * @param string $body Message body
+ * @param string $from Optional From address; if unspecified, default $wgPasswordSender will be used
+ * @param string $replyto Reply-To address
* @return Status
*/
public function sendMail( $subject, $body, $from = null, $replyto = null ) {
}
/**
- * Return a URL the user can use to confirm their email address.
- * @param $token String Accepts the email confirmation token
+ * Return a URL the user can use to confirm their email address.
+ * @param string $token Accepts the email confirmation token
* @return String New token URL
*/
private function confirmationTokenUrl( $token ) {
/**
* Return a URL the user can use to invalidate their email address.
- * @param $token String Accepts the email confirmation token
+ * @param string $token Accepts the email confirmation token
* @return String New token URL
*/
private function invalidationTokenUrl( $token ) {
* also sometimes can get corrupted in some browsers/mailers
* (bug 6957 with Gmail and Internet Explorer).
*
- * @param $page String Special page
- * @param $token String Token
+ * @param string $page Special page
+ * @param string $token Token
* @return String Formatted URL
*/
protected function getTokenUrl( $page, $token ) {
// Hack to bypass localization of 'Special:'
$title = Title::makeTitle( NS_MAIN, "Special:$page/$token" );
- return $title->getCanonicalUrl();
+ return $title->getCanonicalURL();
}
/**
* @return bool
*/
public function confirmEmail() {
- $this->setEmailAuthenticationTimestamp( wfTimestampNow() );
- wfRunHooks( 'ConfirmEmailComplete', array( $this ) );
+ // Check if it's already confirmed, so we don't touch the database
+ // and fire the ConfirmEmailComplete hook on redundant confirmations.
+ if ( !$this->isEmailConfirmed() ) {
+ $this->setEmailAuthenticationTimestamp( wfTimestampNow() );
+ wfRunHooks( 'ConfirmEmailComplete', array( $this ) );
+ }
return true;
}
/**
* Set the e-mail authentication timestamp.
- * @param $timestamp String TS_MW timestamp
+ * @param string $timestamp TS_MW timestamp
*/
function setEmailAuthenticationTimestamp( $timestamp ) {
$this->load();
/**
* Get the permissions associated with a given list of groups
*
- * @param $groups Array of Strings List of internal group names
+ * @param array $groups of Strings List of internal group names
* @return Array of Strings List of permission key names for given groups combined
*/
public static function getGroupPermissions( $groups ) {
/**
* Get all the groups who have a given permission
*
- * @param $role String Role to check
+ * @param string $role Role to check
* @return Array of Strings List of internal group names with the given permission
*/
public static function getGroupsWithPermission( $role ) {
/**
* Check, if the given group has the given permission
*
- * @param $group String Group to check
- * @param $role String Role to check
+ * @param string $group Group to check
+ * @param string $role Role to check
* @return bool
*/
public static function groupHasPermission( $group, $role ) {
/**
* Get the localized descriptive name for a group, if it exists
*
- * @param $group String Internal group name
+ * @param string $group Internal group name
* @return String Localized descriptive group name
*/
public static function getGroupName( $group ) {
/**
* Get the localized descriptive name for a member of a group, if it exists
*
- * @param $group String Internal group name
- * @param $username String Username for gender (since 1.19)
+ * @param string $group Internal group name
+ * @param string $username Username for gender (since 1.19)
* @return String Localized name for group member
*/
public static function getGroupMember( $group, $username = '#' ) {
/**
* Get the title of a page describing a particular group
*
- * @param $group String Internal group name
+ * @param string $group Internal group name
* @return Title|Bool Title of the page if it exists, false otherwise
*/
public static function getGroupPage( $group ) {
* Create a link to the group in HTML, if available;
* else return the group name.
*
- * @param $group String Internal name of the group
- * @param $text String The text of the link
+ * @param string $group Internal name of the group
+ * @param string $text The text of the link
* @return String HTML link to the group
*/
public static function makeGroupLinkHTML( $group, $text = '' ) {
* Create a link to the group in Wikitext, if available;
* else return the group name.
*
- * @param $group String Internal name of the group
- * @param $text String The text of the link
+ * @param string $group Internal name of the group
+ * @param string $text The text of the link
* @return String Wikilink to the group
*/
public static function makeGroupLinkWiki( $group, $text = '' ) {
/**
* Returns an array of the groups that a particular group can add/remove.
*
- * @param $group String: the group to check for whether it can add/remove
+ * @param string $group the group to check for whether it can add/remove
* @return Array array( 'add' => array( addablegroups ),
* 'remove' => array( removablegroups ),
* 'add-self' => array( addablegroups to self),
}
// Re-map numeric keys of AddToSelf/RemoveFromSelf to the 'user' key for backwards compatibility
- if( empty( $wgGroupsAddToSelf['user']) || $wgGroupsAddToSelf['user'] !== true ) {
+ if( empty( $wgGroupsAddToSelf['user'] ) || $wgGroupsAddToSelf['user'] !== true ) {
foreach( $wgGroupsAddToSelf as $key => $value ) {
if( is_int( $key ) ) {
$wgGroupsAddToSelf['user'][] = $value;
}
}
- if( empty( $wgGroupsRemoveFromSelf['user']) || $wgGroupsRemoveFromSelf['user'] !== true ) {
+ if( empty( $wgGroupsRemoveFromSelf['user'] ) || $wgGroupsRemoveFromSelf['user'] !== true ) {
foreach( $wgGroupsRemoveFromSelf as $key => $value ) {
if( is_int( $key ) ) {
$wgGroupsRemoveFromSelf['user'][] = $value;
/**
* Get the description of a given right
*
- * @param $right String Right to query
+ * @param string $right Right to query
* @return String Localized description of the right
*/
public static function getRightDescription( $right ) {
/**
* Make an old-style password hash
*
- * @param $password String Plain-text password
- * @param $userId String User ID
+ * @param string $password Plain-text password
+ * @param string $userId User ID
* @return String Password hash
*/
public static function oldCrypt( $password, $userId ) {
/**
* Make a new-style password hash
*
- * @param $password String Plain-text password
+ * @param string $password Plain-text password
* @param bool|string $salt Optional salt, may be random or the user ID.
* If unspecified or false, will generate one automatically
* Compare a password hash with a plain-text password. Requires the user
* ID if there's a chance that the hash is an old-style hash.
*
- * @param $hash String Password hash
- * @param $password String Plain-text password to compare
- * @param $userId String|bool User ID for old-style password salt
+ * @param string $hash Password hash
+ * @param string $password Plain-text password to compare
+ * @param string|bool $userId User ID for old-style password salt
*
* @return Boolean
*/
* Add a newuser log entry for this user.
* Before 1.19 the return value was always true.
*
- * @param $action string|bool: account creation type.
+ * @param string|bool $action account creation type.
* - String, one of the following values:
* - 'create' for an anonymous user creating an account for himself.
* This will force the action's performer to be the created user itself,
* - false will be converted to 'create' if this object is the same as
* $wgUser and to 'create2' otherwise
*
- * @param $reason String: user supplied reason
+ * @param string $reason user supplied reason
*
* @return int|bool True if not $wgNewUserLog; otherwise ID of log item or 0 on failure
*/
/**
* Load the user options either from cache, the database or an array
*
- * @param $data Rows for the current user out of the user_properties table
+ * @param array $data Rows for the current user out of the user_properties table
*/
protected function loadOptions( $data = null ) {
global $wgContLang;
* @todo document
*/
protected function saveOptions() {
- global $wgAllowPrefChange;
-
$this->loadOptions();
// Not using getOptions(), to keep hidden preferences in database
return;
}
- $extuser = ExternalUser::newFromUser( $this );
$userId = $this->getId();
$insert_rows = array();
foreach( $saveOptions as $key => $value ) {
'up_value' => $value,
);
}
- if ( $extuser && isset( $wgAllowPrefChange[$key] ) ) {
- switch ( $wgAllowPrefChange[$key] ) {
- case 'local':
- case 'message':
- break;
- case 'semiglobal':
- case 'global':
- $extuser->setPref( $key, $value );
- }
- }
}
$dbw = wfGetDB( DB_MASTER );