From 4b504768553c38bb41e6fc0df41d3e7e76b2f4af Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Fri, 15 May 2015 12:44:38 -0700 Subject: [PATCH] Always pass a valid User object to LoginUserMigrated hook Follows up 777078176f0b2. Bug: T96174 Change-Id: I76d33ff5340fbf216c11ff06e2a1b9e01d46ba90 --- includes/specials/SpecialUserlogin.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index c4da642b10..64a6f7244e 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -710,7 +710,11 @@ class LoginForm extends SpecialPage { } $u = User::newFromName( $this->mUsername ); + if ( $u === false ) { + return self::ILLEGAL; + } + $msg = null; // Give extensions a way to indicate the username has been updated, // rather than telling the user the account doesn't exist. if ( !Hooks::run( 'LoginUserMigrated', array( $u, &$msg ) ) ) { @@ -718,7 +722,7 @@ class LoginForm extends SpecialPage { return self::USER_MIGRATED; } - if ( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) { + if ( !User::isUsableName( $u->getName() ) ) { return self::ILLEGAL; } @@ -736,7 +740,6 @@ class LoginForm extends SpecialPage { // Give general extensions, such as a captcha, a chance to abort logins $abort = self::ABORTED; - $msg = null; if ( !Hooks::run( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$msg ) ) ) { $this->mAbortLoginErrorMsg = $msg; -- 2.20.1