From e971a416929e1e2e7e2d751e4c65e4dc1958db5a Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 27 Dec 2007 05:10:03 +0000 Subject: [PATCH] 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 --- includes/SpecialUserrights.php | 2 +- includes/User.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 ) { -- 2.20.1