r82246 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82245‎ | r82246 | r82247 >
Date:14:18, 16 February 2011
Author:philip
Status:reverted (Comments)
Tags:
Comment:
Follow r77452, r80492. Avoid to find sub-languages when load css/js messages.
Modified paths:
  • /trunk/phase3/includes/MessageCache.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/MessageCache.php
@@ -576,17 +576,6 @@
577577 return false;
578578 }
579579
580 - $lang = wfGetLangObj( $langcode );
581 - if ( !$lang ) {
582 - throw new MWException( "Bad lang code $langcode given" );
583 - }
584 -
585 - // Don't change getPreferredVariant() to getCode() / mCode, for
586 - // more details, see the comment in Language::getMessage().
587 - $langcode = $lang->getPreferredVariant();
588 -
589 - $message = false;
590 -
591580 # Normalise title-case input (with some inlining)
592581 $lckey = str_replace( ' ', '_', $key );
593582 if ( ord( $key ) < 128 ) {
@@ -597,7 +586,32 @@
598587 $uckey = $wgContLang->ucfirst( $lckey );
599588 }
600589
 590+ $lang = wfGetLangObj( $langcode );
 591+ if ( !$lang ) {
 592+ throw new MWException( "Bad lang code $langcode given" );
 593+ }
 594+
601595 /**
 596+ * Find a suitable sub-language to present the message to user,
 597+ * but prevent doing it if the message is for css/js.
 598+ *
 599+ * Some language like Chinese has multiple variant languages. Only
 600+ * getPreferredVariant() (in LanguageConverter) could return such
 601+ * sub-language. It won't effect other languages without variants.
 602+ */
 603+ $title = Title::newFromText( $uckey, NS_MEDIAWIKI );
 604+ if ( !$title->isCssOrJsPage() ) {
 605+ $langcode = $lang->getPreferredVariant();
 606+ if ( $langcode != $lang->getCode() ) {
 607+ $lang = wfGetLangObj( $langcode );
 608+ }
 609+ } else {
 610+ $langcode = $lang->getCode();
 611+ }
 612+
 613+ $message = false;
 614+
 615+ /**
602616 * Record each message request, but only once per request.
603617 * This information is not used unless $wgAdaptiveMessageCache
604618 * is enabled.
Index: trunk/phase3/languages/Language.php
@@ -1613,21 +1613,11 @@
16141614 }
16151615
16161616 function getMessage( $key ) {
1617 - // Don't change getPreferredVariant() to getCode() / mCode, because:
1618 -
1619 - // 1. Some language like Chinese has multiple variant languages. Only
1620 - // getPreferredVariant() (in LanguageConverter) could return a
1621 - // sub-language which would be more suitable for the user.
1622 - // 2. To languages without multiple variants, getPreferredVariant()
1623 - // (in FakeConverter) functions exactly same as getCode() / mCode,
1624 - // it won't break anything.
1625 -
1626 - // The same below.
1627 - return self::$dataCache->getSubitem( $this->getPreferredVariant(), 'messages', $key );
 1617+ return self::$dataCache->getSubitem( $this->mCode, 'messages', $key );
16281618 }
16291619
16301620 function getAllMessages() {
1631 - return self::$dataCache->getItem( $this->getPreferredVariant(), 'messages' );
 1621+ return self::$dataCache->getItem( $this->mCode, 'messages' );
16321622 }
16331623
16341624 function iconv( $in, $out, $string ) {

Sign-offs

UserFlagDate
Catropeinspected14:25, 16 February 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r82253revert r77452, r80492 and r82246.philip16:07, 16 February 2011
r822561.17wmf1: Partial MFT of r82246 (Language.php only)catrope16:36, 16 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r77452Select a friendly sub-language while acquiring system messages if the uselang...philip03:04, 30 November 2010
r80492Follow up r77452. Follow mark's suggest to remove getCodeForMessage() and exp...philip07:59, 18 January 2011

Comments

#Comment by Nikerabbit (talk | contribs)   15:12, 16 February 2011

What I babbled on some random IRC channels:

  • I assume the original intention is to load suitable variant text when wfMsgForContent is called. Unfortunately this breaks non-linguistic configuration data like sidebar and cs/jss and other stuff.
  • I assume the calls with wgLang aka interface language was already working fine

The check added in this commit is not going to catch all configuration related messages and will cause similar problems already seen with sidebar and cs/jss messages. Another problem is that MessageCache can't reliably tell when wfMsgForContent was called, or if the requested language just happens to be the same as content language.

#Comment by PhiLiP (talk | contribs)   15:23, 16 February 2011

But it could fix the css/js problem whatever. I think you could deploy it and I'll soon commit follow-ups to fix other problem you metioned.

#Comment by Nikerabbit (talk | contribs)   15:29, 16 February 2011

I'm just afraid that this one will stick and more workarounds will be added. I think a proper solution needs a slightly different approach.

#Comment by PhiLiP (talk | contribs)   15:36, 16 February 2011

Understand. I'll try another approach but not add any other workarounds like this one. But I need time to figure it out and I still beg you to deploy it because the zhwiki can't wait.

#Comment by Catrope (talk | contribs)   16:21, 16 February 2011

Reverted, but still needs merging in order to merge r82253.

#Comment by Catrope (talk | contribs)   16:28, 16 February 2011

...or not

Status & tagging log