From 7b972ea1a0c506a5d22df9dd3d8af46e1df30767 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 14 Nov 2008 00:46:53 +0000 Subject: [PATCH] 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 --- includes/GlobalFunctions.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 ); } -- 2.20.1