Move around User::getEditCount() code.
It's simpler to do an early return and catch almost everything in the profiling. Change-Id: I2306c7b39d9808989f11d7d9d34db06c39d51820
This commit is contained in:
parent
720a682425
commit
5e309c21b4
1 changed files with 21 additions and 22 deletions
|
|
@ -2454,30 +2454,29 @@ class User {
|
|||
* @return Int
|
||||
*/
|
||||
public function getEditCount() {
|
||||
if( $this->getId() ) {
|
||||
if ( !isset( $this->mEditCount ) ) {
|
||||
/* Populate the count, if it has not been populated yet */
|
||||
wfProfileIn( __METHOD__ );
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
// check if the user_editcount field has been initialized
|
||||
$count = $dbr->selectField(
|
||||
'user', 'user_editcount',
|
||||
array( 'user_id' => $this->mId ),
|
||||
__METHOD__
|
||||
);
|
||||
|
||||
if( $count === null ) {
|
||||
// it has not been initialized. do so.
|
||||
$count = $this->initEditCount();
|
||||
}
|
||||
wfProfileOut( __METHOD__ );
|
||||
$this->mEditCount = intval( $count );
|
||||
}
|
||||
return $this->mEditCount;
|
||||
} else {
|
||||
/* nil */
|
||||
if ( !$this->getId() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( !isset( $this->mEditCount ) ) {
|
||||
/* Populate the count, if it has not been populated yet */
|
||||
wfProfileIn( __METHOD__ );
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
// check if the user_editcount field has been initialized
|
||||
$count = $dbr->selectField(
|
||||
'user', 'user_editcount',
|
||||
array( 'user_id' => $this->mId ),
|
||||
__METHOD__
|
||||
);
|
||||
|
||||
if( $count === null ) {
|
||||
// it has not been initialized. do so.
|
||||
$count = $this->initEditCount();
|
||||
}
|
||||
$this->mEditCount = intval( $count );
|
||||
wfProfileOut( __METHOD__ );
|
||||
}
|
||||
return $this->mEditCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue