From: Aryeh Gregor Date: Fri, 26 Sep 2008 21:31:10 +0000 (+0000) Subject: Fix for 41288, don't raise errors for language parameter X-Git-Tag: 1.31.0-rc.0~45076 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=82d21903e6b7aa7b463b8f5de4287b367e69907b;p=lhc%2Fweb%2Fwiklou.git Fix for 41288, don't raise errors for language parameter The documentation didn't make it clear that the wfMsgExt() array can take a single associative parameter. I've clarified this, and fixed error-checking for that. Also adjusted indentation in the comment for clarity (one space isn't enough). --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 301e2a8ade..2366ca78a5 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -666,16 +666,19 @@ function wfMsgWikiHtml( $key ) { /** * Returns message in the requested format * @param string $key Key of the message - * @param array $options Processing rules: - * parse: parses wikitext to html - * parseinline: parses wikitext to html and removes the surrounding p's added by parser or tidy - * escape: filters message through htmlspecialchars - * escapenoentities: same, but allows entity references like   through - * replaceafter: parameters are substituted after parsing or escaping - * parsemag: transform the message using magic phrases - * content: fetch message for content language instead of interface - * language: language code to fetch message for (overriden by content), its behaviour - * with parser, parseinline and parsemag is undefined. + * @param array $options Processing rules. Can take the following options: + * parse: parses wikitext to html + * parseinline: parses wikitext to html and removes the surrounding + * p's added by parser or tidy + * escape: filters message through htmlspecialchars + * escapenoentities: same, but allows entity references like   through + * replaceafter: parameters are substituted after parsing or escaping + * parsemag: transform the message using magic phrases + * content: fetch message for content language instead of interface + * Also can accept a single associative argument, of the form 'language' => 'xx': + * language: language code to fetch message for (overriden by + * content), its behaviour with parser, parseinline and parsemag + * is undefined. * Behavior for conflicting options (e.g., parse+parseinline) is undefined. */ function wfMsgExt( $key, $options ) { @@ -689,12 +692,15 @@ function wfMsgExt( $key, $options ) { $options = array($options); } - foreach( $options as $option ) { - if( !in_array( $option, array( 'parse', 'parseinline', 'escape', - 'escapenoentities', 'replaceafter', 'parsemag', 'content', - 'language' ) ) ) { - trigger_error( "wfMsgExt called with incorrect parameter $option", - E_USER_WARNING ); + foreach( $options as $arrayKey => $option ) { + if( !preg_match( '/^[0-9]+|language$/', $arrayKey ) ) { + # An unknown index, neither numeric nor "language" + trigger_error( "wfMsgExt called with incorrect parameter key $arrayKey", E_USER_WARNING ); + } elseif( preg_match( '/^[0-9]+$/', $arrayKey ) && !in_array( $option, + array( 'parse', 'parseinline', 'escape', 'escapenoentities', + 'replaceafter', 'parsemag', 'content' ) ) ) { + # A numeric index with unknown value + trigger_error( "wfMsgExt called with incorrect parameter $option", E_USER_WARNING ); } }