var $mId, $mName, $mRealName, $mPassword, $mNewpassword, $mNewpassTime,
$mEmail, $mTouched, $mToken, $mEmailAuthenticated,
$mEmailToken, $mEmailTokenExpires, $mRegistration, $mGroups, $mOptionOverrides,
- $mCookiePassword, $mEditCount, $mAllowUsertalk;
+ $mEditCount, $mAllowUsertalk;
//@}
/**
*/
var $mNewtalk, $mDatePreference, $mBlockedby, $mHash, $mRights,
$mBlockreason, $mEffectiveGroups, $mImplicitGroups, $mFormerGroups, $mBlockedGlobally,
- $mLocked, $mHideName, $mOptions, $mDisplayName;
+ $mLocked, $mHideName, $mOptions;
/**
* @var WebRequest
/**
* Get the username corresponding to a given user ID
* @param $id Int User ID
- * @return String|false The corresponding username
+ * @return String|bool The corresponding username
*/
public static function whoIs( $id ) {
$dbr = wfGetDB( DB_SLAVE );
* Get the real name of a user given their user ID
*
* @param $id Int User ID
- * @return String|false The corresponding user's real name
+ * @return String|bool The corresponding user's real name
*/
public static function whoIsReal( $id ) {
$dbr = wfGetDB( DB_SLAVE );
return null;
}
+ if ( User::isIP( $name ) ) {
+ # Cannot exist
+ return null;
+ }
+
if ( isset( self::$idCacheByName[$name] ) ) {
return self::$idCacheByName[$name];
}
$this->mEffectiveGroups = null;
$this->mImplicitGroups = null;
$this->mOptions = null;
- $this->mDisplayName = null;
if ( $reloadFrom ) {
$this->mLoadedItems = array();
}
}
- /**
- * Set the cookie password
- *
- * @param $str String New cookie password
- */
- private function setCookiePassword( $str ) {
- $this->load();
- $this->mCookiePassword = md5( $str );
- }
-
/**
* Set the password for a password reminder or new account email
*
$this->mRealName = $str;
}
- /**
- * Return the name of this user we should used to display in the user interface
- * @return String The user's display name
- */
- public function getDisplayName() {
- global $wgRealNameInInterface;
- if ( is_null( $this->mDisplayName ) ) {
- $displayName = null;
-
- // Allow hooks to set a display name
- wfRunHooks( 'UserDisplayName', array( $this, &$displayName ) );
-
- if ( is_null( $displayName ) && $wgRealNameInInterface && $this->getRealName() ) {
- // If $wgRealNameInInterface is true use the real name as the display name if it's set
- $displayName = $this->getRealName();
- }
-
- if ( is_null( $displayName ) ) {
- $displayName = $this->getName();
- }
-
- $this->mDisplayName = $displayName;
- }
- return $this->mDisplayName;
- }
-
/**
* Get the user's current setting for a given option.
*
* @deprecated since 1.18 Use ->getSkin() in the most relevant outputting context you have
*/
public function getSkin() {
- # wfDeprecated( __METHOD__, '1.18' ); // r106070 but still used in some extensions
+ wfDeprecated( __METHOD__, '1.18' );
return RequestContext::getMain()->getSkin();
}
$this->invalidateCache();
}
- /**
- * Cleans up watchlist by removing invalid entries from it
- */
- public function cleanupWatchlist() {
- $dbw = wfGetDB( DB_MASTER );
- $dbw->delete( 'watchlist', array( 'wl_namespace < 0', 'wl_user' => $this->getId() ), __METHOD__ );
- }
-
/**
* Clear the user's notification timestamp for the given title.
* If e-notif e-mails are on, they will receive notification mails on
// The query to find out if it is watched is cached both in memcached and per-invocation,
// and when it does have to be executed, it can be on a slave
// If this is the user's newtalk page, we always update the timestamp
- if( $title->getNamespace() == NS_USER_TALK &&
+ $force = '';
+ if ( $title->getNamespace() == NS_USER_TALK &&
$title->getText() == $this->getName() )
{
- $watched = true;
- } else {
- $watched = $this->isWatched( $title );
+ $force = 'force';
}
- // If the page is watched by the user (or may be watched), update the timestamp on any
- // any matching rows
- if ( $watched ) {
- $dbw = wfGetDB( DB_MASTER );
- $dbw->update( 'watchlist',
- array( /* SET */
- 'wl_notificationtimestamp' => null
- ), array( /* WHERE */
- 'wl_title' => $title->getDBkey(),
- 'wl_namespace' => $title->getNamespace(),
- 'wl_user' => $this->getID()
- ), __METHOD__
- );
- }
+ $wi = WatchedItem::fromUserTitle( $this, $title );
+ $wi->resetNotificationTimestamp( $force );
}
/**
$this->load();
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
+ // Simply by setting every cell in the user_token column to NULL and letting them be
+ // regenerated as users log back into the wiki.
+ $this->setToken();
+ $this->saveSettings();
+ }
$session = array(
'wsUserID' => $this->mId,
'wsToken' => $this->mToken,
'user_token' => $user->mToken,
'user_registration' => $dbw->timestamp( $user->mRegistration ),
'user_editcount' => 0,
+ 'user_touched' => $dbw->timestamp( self::newTouchedTimestamp() ),
);
foreach ( $params as $name => $value ) {
$fields["user_$name"] = $value;
*/
public function addToDatabase() {
$this->load();
+
+ $this->mTouched = self::newTouchedTimestamp();
+
$dbw = wfGetDB( DB_MASTER );
$seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
$dbw->insert( 'user',
'user_token' => $this->mToken,
'user_registration' => $dbw->timestamp( $this->mRegistration ),
'user_editcount' => 0,
+ 'user_touched' => $dbw->timestamp( $this->mTouched ),
), __METHOD__
);
$this->mId = $dbw->insertId();
/**
* Alias for getEditToken.
- * @deprecated since 1.19, use getEditToken instead. Warnings in 1.21.
+ * @deprecated since 1.19, use getEditToken instead.
*
* @param $salt String|Array 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
*/
public function editToken( $salt = '', $request = null ) {
- # wfDeprecated( __METHOD__, '1.19' );
+ wfDeprecated( __METHOD__, '1.19' );
return $this->getEditToken( $salt, $request );
}
*
* @note Call saveSettings() after calling this function to commit the change.
*
- * @return true
+ * @return bool
*/
public function confirmEmail() {
$this->setEmailAuthenticationTimestamp( wfTimestampNow() );
* address if it was already confirmed.
*
* @note Call saveSettings() after calling this function to commit the change.
- * @return true
+ * @return bool Returns true
*/
function invalidateEmail() {
$this->load();
}
/**
- * Add a newuser log entry for this user
+ * Add a newuser log entry for this user. Before 1.19 the return value was always true.
*
* @param $byEmail Boolean: account made by email?
* @param $reason String: user supplied reason
* Add an autocreate newuser log entry for this user
* Used by things like CentralAuth and perhaps other authplugins.
*
- * @return true
+ * @return bool
*/
public function addNewUserLogEntryAutoCreate() {
global $wgNewUserLog;
__METHOD__
);
+ $this->mOptionOverrides = array();
foreach ( $res as $row ) {
$this->mOptionOverrides[$row->up_property] = $row->up_value;
$this->mOptions[$row->up_property] = $row->up_value;