put in r110285 again now that 1.19 branched
[lhc/web/wiklou.git] / includes / User.php
index 0940766..c56e2ff 100644 (file)
@@ -197,7 +197,7 @@ class User {
         */
        var $mNewtalk, $mDatePreference, $mBlockedby, $mHash, $mRights,
                $mBlockreason, $mEffectiveGroups, $mImplicitGroups, $mFormerGroups, $mBlockedGlobally,
-               $mLocked, $mHideName, $mOptions, $mDisplayName;
+               $mLocked, $mHideName, $mOptions;
 
        /**
         * @var WebRequest
@@ -1191,7 +1191,6 @@ class User {
                $this->mEffectiveGroups = null;
                $this->mImplicitGroups = null;
                $this->mOptions = null;
-               $this->mDisplayName = null;
 
                if ( $reloadFrom ) {
                        $this->mLoadedItems = array();
@@ -2140,32 +2139,6 @@ class User {
                $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.
         *
@@ -2780,6 +2753,14 @@ class User {
 
                $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,
@@ -3186,14 +3167,14 @@ class User {
 
        /**
         * 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 );
        }
 
@@ -3937,7 +3918,7 @@ class User {
        }
 
        /**
-        * 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
@@ -4016,6 +3997,7 @@ class User {
                                __METHOD__
                        );
 
+                       $this->mOptionOverrides = array();
                        foreach ( $res as $row ) {
                                $this->mOptionOverrides[$row->up_property] = $row->up_value;
                                $this->mOptions[$row->up_property] = $row->up_value;