From: Platonides Date: Sat, 23 Jul 2011 20:14:12 +0000 (+0000) Subject: Make wfUrlEncode(null) reset the static. Two skipped tests work now. X-Git-Tag: 1.31.0-rc.0~28663 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=53b0052df1859b6114e1294074faa3ddf1f74b83;p=lhc%2Fweb%2Fwiklou.git Make wfUrlEncode(null) reset the static. Two skipped tests work now. --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 397c7ef813..d6c433e873 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -294,6 +294,11 @@ function wfRandom() { */ function wfUrlencode( $s ) { static $needle; + if ( is_null( $s ) ) { + $needle = null; + return; + } + if ( is_null( $needle ) ) { $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F' ); if ( !isset( $_SERVER['SERVER_SOFTWARE'] ) || ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7' ) === false ) ) { diff --git a/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php b/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php index 97a7844125..cd1a8dbd24 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php @@ -35,6 +35,7 @@ class wfUrlencodeTest extends MediaWikiTestCase { : null ; $_SERVER['SERVER_SOFTWARE'] = $server; + wfUrlencode( null ); // do the requested test $this->assertEquals( @@ -49,6 +50,7 @@ class wfUrlencodeTest extends MediaWikiTestCase { } else { $_SERVER['SERVER_SOFTWARE'] = $old; } + wfUrlencode( null ); } /** @@ -59,14 +61,6 @@ class wfUrlencodeTest extends MediaWikiTestCase { if( is_string( $expectations ) ) { return $expectations; } elseif( is_array( $expectations ) ) { - - /** - * FIXME FIXME FIXME FIXME - * wfUrlencode use a static variable so we can not just - * change the $GLOBALS server name :( - */ - $this->markTestSkipped( 'FIXME: wfUrlencode() use a static, thus changing $GLOBALS[SERVER_SOFTWARE] is useless' ); - if( !array_key_exists( $server, $expectations ) ) { throw new MWException( __METHOD__ . " expectation does not have any value for server name $server. Check the provider array.\n" ); } else {