r92571 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92570‎ | r92571 | r92572 >
Date:20:29, 19 July 2011
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
follow up to r87308 - defensive programming for bogus language codes
Modified paths:
  • /trunk/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
@@ -505,10 +505,12 @@
506506 return '<strong class="error">' . wfMsgForContent( 'pfunc_time_too_long' ) . '</strong>';
507507 } else {
508508 if ( $ts < 100000000000000 ) { // Language can't deal with years after 9999
509 - if ( $language !== '' ) { // use whatever language is passed as a parameter
 509+ if ( $language !== '' && Language::isValidBuiltInCode( $language ) ) {
 510+ // use whatever language is passed as a parameter
510511 $langObject = Language::factory( $language );
511512 $result = $langObject->sprintfDate( $format, $ts );
512 - } else { // use wiki's content language
 513+ } else {
 514+ // use wiki's content language
513515 $result = $parser->getFunctionLang()->sprintfDate( $format, $ts );
514516 }
515517 } else {

Sign-offs

UserFlagDate
Nikerabbitinspected09:01, 20 July 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r95628MFT to REL1_18 (extensions)...hashar15:32, 28 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r87308better language handling - abandon magic language switch in favor of using in...kaldari23:30, 2 May 2011

Comments

#Comment by Nikerabbit (talk | contribs)   09:01, 20 July 2011

Would we want to print an error message instead? This doesn't catch things like foo which look like a valid language code bug which are not. Those fallback to English, while this fallbacks to content language. Can possible by confusing from users point of view.

#Comment by Kaldari (talk | contribs)   00:50, 29 July 2011

Since there are a lot of different ways this parserfunction could be used, I'm personally more comfortable falling back to the Wiki content language than outputting an error, but if others feel differently I'm open to changing it.

Status & tagging log