r73118 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73117‎ | r73118 | r73119 >
Date:16:05, 16 September 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Refine the semantics of codeMap.

The targets of mapped language code pairs are now disallowed, unless they are also mapped to something else.
The previous behaviour caused problems with for example sync-group, which loops over all language codes.
If we had mapping no (MW) -> nb (PROJECT), we would essentially import nb (PROJECT) messages as no (MW)
and also as nb (MW), because nb was not mapped to anything, thus resulting the code itself.
Modified paths:
  • /trunk/extensions/Translate/Groups.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Groups.php
@@ -399,9 +399,21 @@
400400 }
401401
402402 public function mapCode( $code ) {
 403+ if ( !isset( $this->conf['FILES']['codeMap'] ) ) {
 404+ return $code;
 405+ }
 406+
403407 if ( isset( $this->conf['FILES']['codeMap'][$code] ) ) {
404408 return $this->conf['FILES']['codeMap'][$code];
405409 } else {
 410+ if ( !isset( $this->reverseCodeMap ) ) {
 411+ $this->reverseCodeMap = array_flip( $this->conf['FILES']['codeMap'] );
 412+ }
 413+
 414+ if ( isset( $this->reverseCodeMap[$code] ) ) {
 415+ return 'x-invalidLanguageCode';
 416+ }
 417+
406418 return $code;
407419 }
408420 }

Status & tagging log