From: Platonides Date: Mon, 26 Nov 2012 21:56:42 +0000 (+0100) Subject: Move around User::getEditCount() code. X-Git-Tag: 1.31.0-rc.0~21501^2 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=5e309c21b4429dc48d0f696d568ebc6a22dd8f81;p=lhc%2Fweb%2Fwiklou.git Move around User::getEditCount() code. It's simpler to do an early return and catch almost everything in the profiling. Change-Id: I2306c7b39d9808989f11d7d9d34db06c39d51820 --- diff --git a/includes/User.php b/includes/User.php index 0aa613afca..f55281e24e 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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 ( !$this->getId() ) { + return null; + } - if( $count === null ) { - // it has not been initialized. do so. - $count = $this->initEditCount(); - } - wfProfileOut( __METHOD__ ); - $this->mEditCount = intval( $count ); + 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(); } - return $this->mEditCount; - } else { - /* nil */ - return null; + $this->mEditCount = intval( $count ); + wfProfileOut( __METHOD__ ); } + return $this->mEditCount; } /**