Fixes for r51774:
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Fri, 12 Jun 2009 09:17:21 +0000 (09:17 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Fri, 12 Jun 2009 09:17:21 +0000 (09:17 +0000)
* declare $ip and $ipchain so that it doesn't throw notices and warnings
* don't set $ip to false after getting it from $_SERVER['REMOTE_ADDR'], otherwise it won't work when there's no XFF header
* fix logic when throwing the exception: throw it when there's no IP

includes/ProxyTools.php

index dc30d0e..fe31376 100644 (file)
@@ -74,6 +74,9 @@ function wfGetIP() {
                return $wgIP;
        }
 
+       $ipchain = array();
+       $ip = false;
+
        /* collect the originating ips */
        # Client connecting to this webserver
        if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
@@ -82,8 +85,6 @@ function wfGetIP() {
        if( $ip ) {
                $ipchain[] = $ip;
        }
-       
-       $ip = false;
 
        # Append XFF on to $ipchain
        $forwardedFor = wfGetForwardedFor();
@@ -108,7 +109,7 @@ function wfGetIP() {
                }
        }
 
-       if( $ip ) {
+       if( !$ip ) {
                throw new MWException( "Unable to determine IP" );
        }