Merge "Use User::equals() where applicable in the class"
[lhc/web/wiklou.git] / includes / User.php
index fddceab..6df41ee 100644 (file)
@@ -2438,6 +2438,7 @@ class User implements IDBAccessObject {
         */
        public function setInternalPassword( $str ) {
                $this->setToken();
+               $this->setOption( 'watchlisttoken', false );
 
                $passwordFactory = self::getPasswordFactory();
                $this->mPassword = $passwordFactory->newFromPlaintext( $str );
@@ -2715,20 +2716,24 @@ class User implements IDBAccessObject {
         * @return string|bool User's current value for the option, or false if this option is disabled.
         * @see resetTokenFromOption()
         * @see getOption()
+        * @deprecated 1.26 Applications should use the OAuth extension
         */
        public function getTokenFromOption( $oname ) {
                global $wgHiddenPrefs;
-               if ( in_array( $oname, $wgHiddenPrefs ) ) {
+
+               $id = $this->getId();
+               if ( !$id || in_array( $oname, $wgHiddenPrefs ) ) {
                        return false;
                }
 
                $token = $this->getOption( $oname );
                if ( !$token ) {
-                       $token = $this->resetTokenFromOption( $oname );
-                       if ( !wfReadOnly() ) {
-                               $this->saveSettings();
-                       }
+                       // Default to a value based on the user token to avoid space
+                       // wasted on storing tokens for all users. When this option
+                       // is set manually by the user, only then is it stored.
+                       $token = hash_hmac( 'sha1', "$oname:$id", $this->getToken() );
                }
+
                return $token;
        }
 
@@ -3208,10 +3213,10 @@ class User implements IDBAccessObject {
        /**
         * Check if user is allowed to access a feature / make an action
         *
-        * @param string $permissions,... Permissions to test
+        * @param string ... Permissions to test
         * @return bool True if user is allowed to perform *any* of the given actions
         */
-       public function isAllowedAny( /*...*/ ) {
+       public function isAllowedAny() {
                $permissions = func_get_args();
                foreach ( $permissions as $permission ) {
                        if ( $this->isAllowed( $permission ) ) {
@@ -3223,10 +3228,10 @@ class User implements IDBAccessObject {
 
        /**
         *
-        * @param string $permissions,... Permissions to test
+        * @param string ... Permissions to test
         * @return bool True if the user is allowed to perform *all* of the given actions
         */
-       public function isAllowedAll( /*...*/ ) {
+       public function isAllowedAll() {
                $permissions = func_get_args();
                foreach ( $permissions as $permission ) {
                        if ( !$this->isAllowed( $permission ) ) {
@@ -3704,14 +3709,6 @@ class User implements IDBAccessObject {
                Hooks::run( 'UserSaveSettings', array( $this ) );
                $this->clearSharedCache();
                $this->getUserPage()->invalidateCache();
-
-               // T95839: clear the cache again post-commit to reduce race conditions
-               // where stale values are written back to the cache by other threads.
-               // Note: this *still* doesn't deal with REPEATABLE-READ snapshot lag...
-               $that = $this;
-               $dbw->onTransactionIdle( function() use ( $that ) {
-                       $that->clearSharedCache();
-               } );
        }
 
        /**