X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FUser.php;h=84f02afcc7e13333c1e8cd5afd38b3b39e7b8ea1;hb=ea8032b078c18bd9fa93899513acfde3e4731116;hp=d3332fdd76ead1c7a16742ef59eb214c4483a0c9;hpb=b5b480d285fd1202097224839b7f7884f2579cb7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/User.php b/includes/User.php index d3332fdd76..84f02afcc7 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1028,7 +1028,7 @@ class User { } $dbr = wfGetDB( DB_MASTER ); - $s = $dbr->selectRow( 'user', '*', array( 'user_id' => $this->mId ), __METHOD__ ); + $s = $dbr->selectRow( 'user', self::selectFields(), array( 'user_id' => $this->mId ), __METHOD__ ); wfRunHooks( 'UserLoadFromDatabase', array( $this, &$s ) ); @@ -1283,11 +1283,11 @@ class User { } # User/IP blocking - $block = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave ); + $block = Block::newFromTarget( $this, $ip, !$bFromSlave ); # Proxy blocking if ( !$block instanceof Block && $ip !== null && !$this->isAllowed( 'proxyunbannable' ) - && !in_array( $ip, $wgProxyWhitelist ) ) + && !in_array( $ip, $wgProxyWhitelist ) ) { # Local list if ( self::isLocallyBlockedProxy( $ip ) ) { @@ -1926,10 +1926,19 @@ class User { $this->mTouched = self::newTouchedTimestamp(); $dbw = wfGetDB( DB_MASTER ); - $dbw->update( 'user', - array( 'user_touched' => $dbw->timestamp( $this->mTouched ) ), - array( 'user_id' => $this->mId ), - __METHOD__ ); + + // 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__ + ); + } $this->clearSharedCache(); } @@ -2281,7 +2290,10 @@ class User { * Reset all options to the site defaults */ public function resetOptions() { + $this->load(); + $this->mOptions = self::getDefaultOptions(); + $this->mOptionsLoaded = true; } /** @@ -3011,7 +3023,7 @@ class User { */ public function getPageRenderingHash() { wfDeprecated( __METHOD__, '1.17' ); - + global $wgUseDynamicDates, $wgRenderHashAppend, $wgLang, $wgContLang; if( $this->mHash ){ return $this->mHash; @@ -3362,7 +3374,7 @@ class User { * @return String New token URL */ private function invalidationTokenUrl( $token ) { - return $this->getTokenUrl( 'Invalidateemail', $token ); + return $this->getTokenUrl( 'InvalidateEmail', $token ); } /** @@ -4006,7 +4018,7 @@ class User { $res = $dbr->select( 'user_properties', - '*', + array( 'up_property', 'up_value' ), array( 'up_user' => $this->getId() ), __METHOD__ ); @@ -4129,4 +4141,28 @@ class User { return $ret; } + + /** + * Return the list of user fields that should be selected to create + * a new user object. + * @return array + */ + public static function selectFields() { + return array( + 'user_id', + 'user_name', + 'user_real_name', + 'user_password', + 'user_newpassword', + 'user_newpass_time', + 'user_email', + 'user_touched', + 'user_token', + 'user_email_authenticated', + 'user_email_token', + 'user_email_token_expires', + 'user_registration', + 'user_editcount', + ); + } }