r92960 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92959‎ | r92960 | r92961 >
Date:20:14, 23 July 2011
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Make wfUrlEncode(null) reset the static. Two skipped tests work now.
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
@@ -35,6 +35,7 @@
3636 : null
3737 ;
3838 $_SERVER['SERVER_SOFTWARE'] = $server;
 39+ wfUrlencode( null );
3940
4041 // do the requested test
4142 $this->assertEquals(
@@ -49,6 +50,7 @@
5051 } else {
5152 $_SERVER['SERVER_SOFTWARE'] = $old;
5253 }
 54+ wfUrlencode( null );
5355 }
5456
5557 /**
@@ -59,14 +61,6 @@
6062 if( is_string( $expectations ) ) {
6163 return $expectations;
6264 } elseif( is_array( $expectations ) ) {
63 -
64 - /**
65 - * FIXME FIXME FIXME FIXME
66 - * wfUrlencode use a static variable so we can not just
67 - * change the $GLOBALS server name :(
68 - */
69 - $this->markTestSkipped( 'FIXME: wfUrlencode() use a static, thus changing $GLOBALS[SERVER_SOFTWARE] is useless' );
70 -
7165 if( !array_key_exists( $server, $expectations ) ) {
7266 throw new MWException( __METHOD__ . " expectation does not have any value for server name $server. Check the provider array.\n" );
7367 } else {
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -294,6 +294,11 @@
295295 */
296296 function wfUrlencode( $s ) {
297297 static $needle;
 298+ if ( is_null( $s ) ) {
 299+ $needle = null;
 300+ return;
 301+ }
 302+
298303 if ( is_null( $needle ) ) {
299304 $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F' );
300305 if ( !isset( $_SERVER['SERVER_SOFTWARE'] ) || ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7' ) === false ) ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r94558Tests for wfGetIP() follow up r89407...hashar20:16, 15 August 2011
r94638Tests for wfGetIP() follow up r89407...hashar14:15, 16 August 2011
r102540MFT to REL1_18 r92960...hashar17:27, 9 November 2011

Comments

#Comment by Hashar (talk | contribs)   01:45, 28 July 2011

this is a good idea :-) Thanks for fixing my FIXME!

Status & tagging log