back off r94558:
authorAntoine Musso <hashar@users.mediawiki.org>
Mon, 15 Aug 2011 21:45:18 +0000 (21:45 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Mon, 15 Aug 2011 21:45:18 +0000 (21:45 +0000)
 - reverts ./includes/ProxyTools.php
 - marks tests broken

In our test suite, the first call to wfGetIP() set the static variable.
Hence the remaining of the code is only tested on the first call to it.
Resetting the static variable enlight a bug somewhere in our code where
we are calling wfGetIP() but can not reliably get an IP, somehow REMOTE_ADDR
does not exist and $wgCommandLineMode is disabled.
Will have to track this bug further when I got time.

includes/ProxyTools.php
tests/phpunit/includes/ProxyTools/wfGetIPTest.php

index f9671d9..e68729f 100644 (file)
@@ -64,18 +64,12 @@ function wfGetAgent() {
 /**
  * Work out the IP address based on various globals
  * For trusted proxies, use the XFF client IP (first of the chain)
- * @param $reset boolean Used to reset the internal static variable
- * tracking the IP address. (default: false)
  * @return string
  */
-function wfGetIP( $reset = false ) {
+function wfGetIP() {
        global $wgUsePrivateIPs, $wgCommandLineMode;
        static $ip = false;
 
-       if( $reset ) {
-               $ip = false;
-       }
-
        # Return cached result
        if ( !empty( $ip ) ) {
                return $ip;
index bef16b1..edaf0b7 100644 (file)
@@ -1,6 +1,10 @@
 <?php
 /*
  * Unit tests for wfGetIP()
+ * 
+ * FIXME: r94558 cause some test to throw an exception cause
+ * wgCommandLine is not set :-)  Resetting the static variable
+ * enlight a bug that is hidden by a previous call to wfGetIP().
  *
  * TODO: need to cover the part dealing with XFF headers.
  */
@@ -24,6 +28,9 @@ class wfGetIPTest extends MediaWikiTestCase {
                        $msg );
        }
 
+       /**
+        * @group Broken
+        */
        function testGetLoopbackAddressWhenInCommandLine() {
                global $wgCommandLineMode;
                $save = $wgCommandLineMode;
@@ -67,6 +74,7 @@ class wfGetIPTest extends MediaWikiTestCase {
 
        /**
         * @expectedException MWException
+        * @group Broken
         */
        function testLackOfRemoteAddrThrowAnException() {
                global $wgCommandLineMode;