* 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;
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.
*
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' );
*
* 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__
+ );
}
}
*/
public function invalidateCache() {
$this->touch();
- $this->clearSharedCache();
+ $this->clearSharedCache( 'changed' );
}
/**
$this->saveOptions();
Hooks::run( 'UserSaveSettings', [ $this ] );
- $this->clearSharedCache();
+ $this->clearSharedCache( 'changed' );
$this->getUserPage()->purgeSquid();
}