http://www.mediawiki.org/wiki/Special:Code/MediaWiki/56325

Revision: 56325
Author:   churchofemacs
Date:     2009-09-14 19:34:18 +0000 (Mon, 14 Sep 2009)

Log Message:
-----------
Fixing User::getBlockedStatus which broke r55918. Function now works for all 
user objects, not just wgUser

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES
    trunk/phase3/includes/User.php

Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES  2009-09-14 18:58:25 UTC (rev 56324)
+++ trunk/phase3/RELEASE-NOTES  2009-09-14 19:34:18 UTC (rev 56325)
@@ -500,6 +500,8 @@
 * (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 ==
 

Modified: trunk/phase3/includes/User.php
===================================================================
--- trunk/phase3/includes/User.php      2009-09-14 18:58:25 UTC (rev 56324)
+++ trunk/phase3/includes/User.php      2009-09-14 19:34:18 UTC (rev 56325)
@@ -1066,7 +1066,7 @@
         *                    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 @@
                $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 = '';
                }



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to