Fixing User::getBlockedStatus which broke r55918. Function now works for all user...
authorTobias <churchofemacs@users.mediawiki.org>
Mon, 14 Sep 2009 19:34:18 +0000 (19:34 +0000)
committerTobias <churchofemacs@users.mediawiki.org>
Mon, 14 Sep 2009 19:34:18 +0000 (19:34 +0000)
RELEASE-NOTES
includes/User.php

index ee3d4ca..90fca3b 100644 (file)
@@ -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 ==
 
index 653b526..3d4fdac 100644 (file)
@@ -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 = '';
                }