- 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.
/**
* 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;
<?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.
*/
$msg );
}
+ /**
+ * @group Broken
+ */
function testGetLoopbackAddressWhenInCommandLine() {
global $wgCommandLineMode;
$save = $wgCommandLineMode;
/**
* @expectedException MWException
+ * @group Broken
*/
function testLackOfRemoteAddrThrowAnException() {
global $wgCommandLineMode;