From: Brion Vibber Date: Fri, 14 Nov 2008 00:46:53 +0000 (+0000) Subject: Use strict parameter on in_array() checks in wfMsgExt(). In PHP 5.1.6 this was whingi... X-Git-Tag: 1.31.0-rc.0~44349 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=7b972ea1a0c506a5d22df9dd3d8af46e1df30767;p=lhc%2Fweb%2Fwiklou.git Use strict parameter on in_array() checks in wfMsgExt(). In PHP 5.1.6 this was whinging when a Language object was passed as 'language' parameter, trying to convert it to an int (!?). Since we're only checking for exact strings, an exact match is just fine and it stops the whinging. (Saw no such problem on 5.2.6.) Example whinge: Notice: Object of class Language could not be converted to int in /Library/WebServer/Documents/trunk/includes/GlobalFunctions.php on line 742 --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a03017ee40..0542eb97f2 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -703,7 +703,7 @@ function wfMsgExt( $key, $options ) { } } - if( in_array('content', $options) ) { + if( in_array('content', $options, true ) ) { $forContent = true; $langCode = true; } elseif( array_key_exists('language', $options) ) { @@ -716,19 +716,19 @@ function wfMsgExt( $key, $options ) { $string = wfMsgGetKey( $key, /*DB*/true, $langCode, /*Transform*/false ); - if( !in_array('replaceafter', $options) ) { + if( !in_array('replaceafter', $options, true ) ) { $string = wfMsgReplaceArgs( $string, $args ); } - if( in_array('parse', $options) ) { + if( in_array('parse', $options, true ) ) { $string = $wgOut->parse( $string, true, !$forContent ); - } elseif ( in_array('parseinline', $options) ) { + } elseif ( in_array('parseinline', $options, true ) ) { $string = $wgOut->parse( $string, true, !$forContent ); $m = array(); if( preg_match( '/^

(.*)\n?<\/p>\n?$/sU', $string, $m ) ) { $string = $m[1]; } - } elseif ( in_array('parsemag', $options) ) { + } elseif ( in_array('parsemag', $options, true ) ) { global $wgMessageCache; if ( isset( $wgMessageCache ) ) { $string = $wgMessageCache->transform( $string, @@ -737,13 +737,13 @@ function wfMsgExt( $key, $options ) { } } - if ( in_array('escape', $options) ) { + if ( in_array('escape', $options, true ) ) { $string = htmlspecialchars ( $string ); - } elseif ( in_array( 'escapenoentities', $options ) ) { + } elseif ( in_array( 'escapenoentities', $options, true ) ) { $string = Sanitizer::escapeHtmlAllowEntities( $string ); } - if( in_array('replaceafter', $options) ) { + if( in_array('replaceafter', $options, true ) ) { $string = wfMsgReplaceArgs( $string, $args ); }