define( 'USER_TOKEN_LENGTH', 32 );
# Serialized record version
-define( 'MW_USER_VERSION', 4 );
+define( 'MW_USER_VERSION', 5 );
# Some punctuation to prevent editing from broken text-mangling proxies.
# FIXME: this is embedded unescaped into HTML attributes in various
'mEmailToken',
'mEmailTokenExpires',
'mRegistration',
-
+ 'mEditCount',
# user_group table
'mGroups',
);
# Try cache
$key = wfMemcKey( 'user', 'id', $this->mId );
$data = $wgMemc->get( $key );
-
if ( !is_array( $data ) || $data['mVersion'] < MW_USER_VERSION ) {
# Object is expired, load from DB
$data = false;
/**
* Count the number of edits of a user
*
+ * It should not be static and some day should be merged as proper member function / deprecated -- domas
+ *
* @param int $uid The user ID to check
* @return int
* @static
static function edits( $uid ) {
wfProfileIn( __METHOD__ );
$dbr = wfGetDB( DB_SLAVE );
-
// check if the user_editcount field has been initialized
$field = $dbr->selectField(
'user', 'user_editcount',
$this->mEmailToken = $s->user_email_token;
$this->mEmailTokenExpires = wfTimestampOrNull( TS_MW, $s->user_email_token_expires );
$this->mRegistration = wfTimestampOrNull( TS_MW, $s->user_registration );
+ $this->mEditCount = $s->user_editcount;
+ $this->getEditCount(); // revalidation for nulls
# Load group data
$res = $dbr->select( 'user_groups',
global $wgAutoConfirmAge, $wgAutoConfirmCount;
$accountAge = time() - wfTimestampOrNull( TS_UNIX, $this->mRegistration );
- $accountEditCount = User::edits( $this->mId );
- if( $accountAge >= $wgAutoConfirmAge && $accountEditCount >= $wgAutoConfirmCount ) {
+ if( $accountAge >= $wgAutoConfirmAge && $this->getEditCount() >= $wgAutoConfirmCount ) {
$this->mEffectiveGroups[] = 'autoconfirmed';
}
-
# Implicit group for users whose email addresses are confirmed
global $wgEmailAuthentication;
if( self::isValidEmailAddr( $this->mEmail ) ) {
}
return $this->mEffectiveGroups;
}
-
+
+ /* Return the edit count for the user. This is where User::edits should have been */
+ function getEditCount() {
+ if ($this->mId) {
+ if ($this->mEditCount === null ) {
+ /* Populate the count, if it has not been populated yet */
+ $this->mEditCount = User::edits($this->mId);
+ }
+ return $this->mEditCount;
+ } else {
+ /* nil */
+ return null;
+ }
+ }
+
/**
* Add the user to the given group.
* This takes immediate effect.
__METHOD__ );
}
}
+ // edit count in user cache too
+ $this->invalidateCache();
}
}