From e6a2eaea64dbdca783a1518b50a28266e99e0a68 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 14 Sep 2009 19:34:18 +0000 Subject: [PATCH] Fixing User::getBlockedStatus which broke r55918. Function now works for all user objects, not just wgUser --- RELEASE-NOTES | 2 ++ includes/User.php | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ee3d4ca289..90fca3bc29 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -500,6 +500,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 20634) The installer-created database user will now have all rights on the database so that upgrades will go more smoothly. * (bug 18180) Special:Export ignores limit, dir, offset parameters +* User::getBlockedStatus() works for all kinds of user objects and doesn't + assume the user object is equal to the current-user object ($wgUser) == API changes in 1.16 == diff --git a/includes/User.php b/includes/User.php index 653b526c9a..3d4fdac846 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1066,7 +1066,7 @@ class User { * done against master. */ function getBlockedStatus( $bFromSlave = true ) { - global $wgEnableSorbs, $wgProxyWhitelist; + global $wgEnableSorbs, $wgProxyWhitelist, $wgUser; if ( -1 != $this->mBlockedby ) { wfDebug( "User::getBlockedStatus: already loaded.\n" ); @@ -1086,9 +1086,25 @@ class User { $this->mBlockedby = 0; $this->mHideName = 0; $this->mAllowUsertalk = 0; - $ip = wfGetIP(); - if ($this->isAllowed( 'ipblock-exempt' ) ) { + # Check if we are looking at an IP or a logged-in user + if ( $this->isIP( $this->getName() ) ) { + $ip = $this->getName(); + } + else { + # Check if we are looking at the current user + # If we don't, and the user is logged in, we don't know about + # his IP / autoblock status, so ignore autoblock of current user's IP + if ( $this->getID() != $wgUser->getID() ) { + $ip = ''; + } + else { + # Get IP of current user + $ip = wfGetIP(); + } + } + + if ( $this->isAllowed( 'ipblock-exempt' ) ) { # Exempt from all types of IP-block $ip = ''; } -- 2.20.1