From: Kunal Mehta Date: Mon, 14 Jul 2014 05:03:00 +0000 (-0700) Subject: Properly check whether a user exists X-Git-Tag: 1.31.0-rc.0~14956^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=78a8351111049794804af3d91e9e903d9341f721;p=lhc%2Fweb%2Fwiklou.git 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 --- 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'] ) ) {