Philip Tzou wrote:
> If you can't download the diff attachment, here it is:
The attachment was stripped, so it wasn't sent with the proper mime.
> Index: includes/MessageCache.php
>> ===================================================================
>> --- includes/MessageCache.php (版本 77398)
>> +++ includes/MessageCache.php (工作副本)
>> @@ -550,7 +550,7 @@
>> throw new MWException( "Bad lang code $langcode given" );
>> }
>>
>> - $langcode = $lang->getCode();
>> + $langcode = $lang->getCodeForMessage();
>>
>> $message = false;
>>
>> Index: languages/Language.php
>> ===================================================================
>> --- languages/Language.php (版本 77398)
>> +++ languages/Language.php (工作副本)
>> @@ -1545,11 +1545,11 @@
>> }
>>
>> function getMessage( $key ) {
>> - return self::$dataCache->getSubitem( $this->mCode, 'messages',
>> $key );
>> + return self::$dataCache->getSubitem( $this->mCodeForMessage,
>> 'messages', $key );
>> }
>>
>> function getAllMessages() {
>> - return self::$dataCache->getItem( $this->mCode, 'messages' );
>> + return self::$dataCache->getItem( $this->mCodeForMessage,
>> 'messages' );
>> }
I think $this->mCodeForMessage should be $this->getCodeForMessage() here
($this->mCode is set in construction, mCodeForMessage is not)
>> + /**
>> + * Get langcode for message
>> + * Some language, like Chinese (zh, without any suffix), has multiple
>> + * interface languages, we could choose a better one for user.
>> + *
>> + * @return string
>> + */
>> + function getCodeForMessage() {
Is CodeForMessage a good name for this?
Why is this function needed? It seems to be equivalent to calling
getPreferredVariant() But with result caching, which
getPreferredVariant() intentionally avoids.
>> + // cache the result
>> + if ( !isset( $this->mCodeForMessage ) ) {
>> + if ( $this->hasVariants() ) {
>> + return $this->mCodeForMessage =
>> $this->getPreferredVariant();
>> + } else {
>> + return $this->mCodeForMessage = $this->mCode;
>> + }
>> + } else {
>> + return $this->mCodeForMessage;
>> + }
>> + }
>>
>> function setCode( $code ) {
>> $this->mCode = $code;
>>
Set code should invalidate mCodeForMessage
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l