X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FUser.php;h=6df41ee073d13894c2ecfacb8c6b51b3bbb41c5d;hp=9b958f42dd1dabf26f85bef61699555895116097;hb=b60dded47b7c4437a21baea8ee0780243340abb6;hpb=b73b2456896c949cfe319ff310521679566ecbcf diff --git a/includes/User.php b/includes/User.php index 9b958f42dd..6df41ee073 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1591,7 +1591,7 @@ class User implements IDBAccessObject { # We only need to worry about passing the IP address to the Block generator if the # user is not immune to autoblocks/hardblocks, and they are the current user so we # know which IP address they're actually coming from - if ( !$this->isAllowed( 'ipblock-exempt' ) && $this->getID() == $wgUser->getID() ) { + if ( !$this->isAllowed( 'ipblock-exempt' ) && $this->equals( $wgUser ) ) { $ip = $this->getRequest()->getIP(); } else { $ip = null; @@ -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(); - } ); } /**