/**
* @return String
*/
- function __toString(){
+ function __toString() {
return $this->getName();
}
wfRunHooks( 'UserLoadAfterLoadFromSession', array( $this ) );
break;
default:
+ wfProfileOut( __METHOD__ );
throw new MWException( "Unrecognised value for User->mFrom: \"{$this->mFrom}\"" );
}
wfProfileOut( __METHOD__ );
$this->$name = $data[$name];
}
}
+
+ $this->mLoadedItems = true;
+
return true;
}
* User::getCanonicalName(), except that true is accepted as an alias
* for 'valid', for BC.
*
- * @return User object, or false if the username is invalid
+ * @return User|bool User object, or false if the username is invalid
* (e.g. if it contains illegal characters or is an IP address). If the
* username is not present in the database, the result will be a user object
* with a name, zero user ID and default settings.
$this->mRights = null;
$this->mEffectiveGroups = null;
$this->mImplicitGroups = null;
+ $this->mGroups = null;
$this->mOptions = null;
$this->mOptionsLoaded = false;
$this->mEditCount = null;
* @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;
}
/**
*
* @return bool
*/
- public function isAllowedAny( /*...*/ ){
+ public function isAllowedAny( /*...*/ ) {
$permissions = func_get_args();
foreach( $permissions as $permission ){
if( $this->isAllowed( $permission ) ){
* @internal param $varargs string
* @return bool True if the user is allowed to perform *all* of the given actions
*/
- public function isAllowedAll( /*...*/ ){
+ public function isAllowedAll( /*...*/ ) {
$permissions = func_get_args();
foreach( $permissions as $permission ){
if( !$this->isAllowed( $permission ) ){
* so it is still advisable to make the call conditional on isLoggedIn(),
* and to commit the transaction after calling.
*
+ * @throws MWException
* @return Status
*/
public function addToDatabase() {