From: Tobias Date: Mon, 14 Sep 2009 19:34:18 +0000 (+0000) Subject: Fixing User::getBlockedStatus which broke r55918. Function now works for all user... X-Git-Tag: 1.31.0-rc.0~39737 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=e6a2eaea64dbdca783a1518b50a28266e99e0a68;p=lhc%2Fweb%2Fwiklou.git Fixing User::getBlockedStatus which broke r55918. Function now works for all user objects, not just wgUser --- 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 = ''; }