From 1f6c59acfc6406c89ca6fd561b3c8f07d23a122f Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 9 Mar 2010 19:27:36 +0000 Subject: [PATCH] Avoid fatal on login if username is invalid title Steps to reproduce: Try logging in with a 256-character username. Expected result: Friendly error message saying the name is invalid. Actual result: Fatal error: Call to a member function getName() on a non-object in /var/www/git-trunk/phase3/includes/specials/SpecialUserlogin.php on line 433 Fix: If you want to check whether something is a User object, check whether it's a User object. There are things other than null that don't behave like User objects. --- includes/specials/SpecialUserlogin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index baced16094..5d5a771046 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -430,7 +430,7 @@ class LoginForm { # TODO: Allow some magic here for invalid external names, e.g., let the # user choose a different wiki name. $u = User::newFromName( $this->mName ); - if( is_null( $u ) || !User::isUsableName( $u->getName() ) ) { + if( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) { return self::ILLEGAL; } -- 2.20.1