r87308 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87307‎ | r87308 | r87309 >
Date:23:30, 2 May 2011
Author:kaldari
Status:resolved (Comments)
Tags:needs-parsertests 
Comment:
better language handling - abandon magic language switch in favor of using int:lang as parameter, use parser->getFunctionLang() instead of wgContLanguage in case of use in interface messages
Modified paths:
  • /trunk/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
@@ -505,14 +505,11 @@
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 == 'user' ) { // use user's interface language
510 - $parser->getOptions()->getUserLang();
511 - $result = $wgLang->sprintfDate( $format, $ts );
512 - } elseif ( $language !== '' ) { // use whatever language is passed as a parameter
 509+ if ( $language !== '' ) { // use whatever language is passed as a parameter
513510 $langObject = Language::factory( $language );
514511 $result = $langObject->sprintfDate( $format, $ts );
515512 } else { // use wiki's content language
516 - $result = $wgContLang->sprintfDate( $format, $ts );
 513+ $result = $parser->getFunctionLang()->sprintfDate( $format, $ts );
517514 }
518515 } else {
519516 return '<strong class="error">' . wfMsgForContent( 'pfunc_time_too_big' ) . '</strong>';

Follow-up revisions

RevisionCommit summaryAuthorDate
r92571follow up to r87308 - defensive programming for bogus language codeskaldari20:29, 19 July 2011
r92572follow up to r87308 - fix redundancykaldari20:31, 19 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86927adding language support to #time parser function, per bug 28655kaldari00:26, 26 April 2011

Comments

#Comment by MaxSem (talk | contribs)   04:58, 3 May 2011

Needs parser tests - I noticed this bug by pure incident.

#Comment by (talk | contribs)   16:56, 19 July 2011

Just try 28 February 1988, the result will be an internal Error! But I've no idea what's wrong.

#Comment by (talk | contribs)   16:57, 19 July 2011

Oops, works in here. But have a look at translatewiki:User:Raymond/time and try to uncomment it.

#Comment by Kaldari (talk | contribs)   20:20, 19 July 2011

int:lang doesn't exist on most wikis. I'll put in some defensive programming so that it fails gracefully.

#Comment by Kaldari (talk | contribs)   20:32, 19 July 2011

Fixed in r92571 and r92572.

Status & tagging log