X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=blobdiff_plain;f=includes%2Fuser%2FUser.php;h=ba6bb08a736dc143915a4b35fa025e440a504a1b;hb=c3e549a732b8ed47973a28aa350d3c5b6b96928c;hp=5b073158d32434703b8bb867e5d4e22f24e99a57;hpb=f9de826875126e34e4f58e17e722631876741586;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/user/User.php b/includes/user/User.php index 5b073158d3..ba6bb08a73 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -46,18 +46,20 @@ use Wikimedia\Rdbms\IDatabase; * of the database. */ class User implements IDBAccessObject, UserIdentity { + /** - * @const int Number of characters in user_token field. + * Number of characters required for the user_token field. */ const TOKEN_LENGTH = 32; /** - * @const string An invalid value for user_token + * An invalid string value for the user_token field. */ const INVALID_TOKEN = '*** INVALID ***'; /** - * @const int Serialized record version. + * Version number to tag cached versions of serialized User objects. Should be increased when + * {@link $mCacheVars} or one of it's members changes. */ const VERSION = 13; @@ -1288,17 +1290,6 @@ class User implements IDBAccessObject, UserIdentity { return $name; } - /** - * Return a random password. - * - * @deprecated since 1.27, use PasswordFactory::generateRandomPasswordString() - * @return string New random password - */ - public static function randomPassword() { - global $wgMinimalPasswordLength; - return PasswordFactory::generateRandomPasswordString( $wgMinimalPasswordLength ); - } - /** * Set cached properties to default. * @@ -1715,7 +1706,7 @@ class User implements IDBAccessObject, UserIdentity { if ( $success ) { $this->mTouched = $newTouched; - $this->clearSharedCache(); + $this->clearSharedCache( 'changed' ); } else { // Clears on failure too since that is desired if the cache is stale $this->clearSharedCache( 'refresh' ); @@ -2771,29 +2762,26 @@ class User implements IDBAccessObject, UserIdentity { * * Called implicitly from invalidateCache() and saveSettings(). * - * @param string $mode Use 'refresh' to clear now; otherwise before DB commit + * @param string $mode Use 'refresh' to clear now or 'changed' to clear before DB commit */ - public function clearSharedCache( $mode = 'changed' ) { + public function clearSharedCache( $mode = 'refresh' ) { if ( !$this->getId() ) { return; } + $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); $key = $this->getCacheKey( $cache ); + if ( $mode === 'refresh' ) { - $cache->delete( $key, 1 ); + $cache->delete( $key, 1 ); // low tombstone/"hold-off" TTL } else { - $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); - if ( $lb->hasOrMadeRecentMasterChanges() ) { - $lb->getConnection( DB_MASTER )->onTransactionPreCommitOrIdle( - function () use ( $cache, $key ) { - $cache->delete( $key ); - }, - __METHOD__ - ); - } else { - $cache->delete( $key ); - } + $lb->getConnection( DB_MASTER )->onTransactionPreCommitOrIdle( + function () use ( $cache, $key ) { + $cache->delete( $key ); + }, + __METHOD__ + ); } } @@ -2804,7 +2792,7 @@ class User implements IDBAccessObject, UserIdentity { */ public function invalidateCache() { $this->touch(); - $this->clearSharedCache(); + $this->clearSharedCache( 'changed' ); } /** @@ -4255,7 +4243,7 @@ class User implements IDBAccessObject, UserIdentity { $this->saveOptions(); Hooks::run( 'UserSaveSettings', [ $this ] ); - $this->clearSharedCache(); + $this->clearSharedCache( 'changed' ); $this->getUserPage()->purgeSquid(); }