From: Brion Vibber Date: Thu, 27 Dec 2007 05:10:03 +0000 (+0000) Subject: User::isAnon() via User::isLoggedIn() has unexpected behavior from an optimization... X-Git-Tag: 1.31.0-rc.0~50266 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=e971a416929e1e2e7e2d751e4c65e4dc1958db5a;p=lhc%2Fweb%2Fwiklou.git User::isAnon() via User::isLoggedIn() has unexpected behavior from an optimization if the data isn't loaded and the referenced name doesn't exist. Not sure if that's desired or not; adding a comment note on the code and using a clearer check in special:userrights --- diff --git a/includes/SpecialUserrights.php b/includes/SpecialUserrights.php index a2d78c7096..c5ab9655ba 100644 --- a/includes/SpecialUserrights.php +++ b/includes/SpecialUserrights.php @@ -208,7 +208,7 @@ class UserrightsForm extends HTMLForm { $user = UserRightsProxy::newFromName( $database, $name ); } - if( !$user || $user->isAnon() ) { + if( !$user || $user->getId() == 0 ) { $wgOut->addWikiText( wfMsg( 'nosuchusershort', wfEscapeWikiText( $username ) ) ); return null; } diff --git a/includes/User.php b/includes/User.php index e7bbda97b2..c22ed5fe9d 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1729,6 +1729,7 @@ class User { * Returns true if the user is not an anonymous visitor. * * @return bool + * @fixme "special-case optimization" may fail for an object referring to a user that doesn't exist in the system. */ function isLoggedIn() { if( $this->mId === null and $this->mName !== null ) {