From: Gergő Tisza Date: Thu, 21 Mar 2019 16:00:49 +0000 (-0700) Subject: Rearrange code in User::getBlockedStatus to avoid isAllowed calls X-Git-Tag: 1.34.0-rc.0~2429^2 X-Git-Url: https://git.cyclocoop.org/admin/Duna?a=commitdiff_plain;h=02387b7dc81e7719c4edb96f0806310fbb9f9c1c;p=lhc%2Fweb%2Fwiklou.git Rearrange code in User::getBlockedStatus to avoid isAllowed calls User::isAllowed() triggers session loading, which results in a loop if it is called during session loading. Session providers need to check block status when $wgBlockDisablesLogin is enabled, so try to avoid isAllowed calls in that situation. Bug: T218608 Change-Id: Iab24923c613d6aeed4b574f587fc4cee8f33077c --- diff --git a/includes/user/User.php b/includes/user/User.php index 786f2882c4..fe15034c4e 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -1844,16 +1844,14 @@ class User implements IDBAccessObject, UserIdentity { # user is not immune to autoblocks/hardblocks, and they are the current user so we # know which IP address they're actually coming from $ip = null; - if ( !$this->isAllowed( 'ipblock-exempt' ) ) { - $sessionUser = RequestContext::getMain()->getUser(); - // the session user is set up towards the end of Setup.php. Until then, - // assume it's a logged-out user. - $globalUserName = $sessionUser->isSafeToLoad() - ? $sessionUser->getName() - : IP::sanitizeIP( $sessionUser->getRequest()->getIP() ); - if ( $this->getName() === $globalUserName ) { - $ip = $this->getRequest()->getIP(); - } + $sessionUser = RequestContext::getMain()->getUser(); + // the session user is set up towards the end of Setup.php. Until then, + // assume it's a logged-out user. + $globalUserName = $sessionUser->isSafeToLoad() + ? $sessionUser->getName() + : IP::sanitizeIP( $sessionUser->getRequest()->getIP() ); + if ( $this->getName() === $globalUserName && !$this->isAllowed( 'ipblock-exempt' ) ) { + $ip = $this->getRequest()->getIP(); } // User/IP blocking