From 78a8351111049794804af3d91e9e903d9341f721 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sun, 13 Jul 2014 22:03:00 -0700 Subject: [PATCH] Properly check whether a user exists User::newFromId() will never return false. We have to actually load from the database to see whether the user still exists. Change-Id: Id9329635717e6a4f1f34d0b2b665bb790685d2fa --- includes/context/RequestContext.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index cd18404846..efdc6db8cc 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -471,7 +471,8 @@ class RequestContext implements IContextSource { if ( $params['userId'] ) { // logged-in user $user = User::newFromId( $params['userId'] ); - if ( !$user ) { + $user->load(); + if ( !$user->getId() ) { throw new MWException( "No user with ID '{$params['userId']}'." ); } } elseif ( !IP::isValid( $params['ip'] ) ) { -- 2.20.1