Index: trunk/extensions/cldr/LanguageNames.body.php |
— | — | @@ -83,39 +83,47 @@ |
84 | 84 | * @return an associative array of language codes and localized language names |
85 | 85 | */ |
86 | 86 | private static function loadLanguage( $code ) { |
87 | | - if ( !isset( self::$cache[$code] ) ) { |
88 | | - wfProfileIn( __METHOD__ . '-recache' ); |
| 87 | + if ( isset( self::$cache[$code] ) ) { |
| 88 | + return self::$cache[$code]; |
| 89 | + } |
89 | 90 | |
90 | | - /* Load override for wrong or missing entries in cldr */ |
91 | | - $override = dirname( __FILE__ ) . '/LocalNames/' . self::getOverrideFileName( $code ); |
92 | | - if ( Language::isValidBuiltInCode( $code ) && file_exists( $override ) ) { |
93 | | - $languageNames = false; |
94 | | - require( $override ); |
95 | | - if ( is_array( $languageNames ) ) { |
96 | | - self::$cache[$code] = $languageNames; |
97 | | - } |
| 91 | + self::$cache[$code] = array(); |
| 92 | + |
| 93 | + if ( !Language::isValidBuiltInCode( $code ) ) { |
| 94 | + return array(); |
| 95 | + } |
| 96 | + |
| 97 | + wfProfileIn( __METHOD__ . '-recache' ); |
| 98 | + |
| 99 | + /* Load override for wrong or missing entries in cldr */ |
| 100 | + $override = dirname( __FILE__ ) . '/LocalNames/' . self::getOverrideFileName( $code ); |
| 101 | + if ( file_exists( $override ) ) { |
| 102 | + $languageNames = false; |
| 103 | + require( $override ); |
| 104 | + if ( is_array( $languageNames ) ) { |
| 105 | + self::$cache[$code] = $languageNames; |
98 | 106 | } |
| 107 | + } |
99 | 108 | |
100 | | - $filename = dirname( __FILE__ ) . '/CldrNames/' . self::getFileName( $code ); |
101 | | - if ( Language::isValidBuiltInCode( $code ) && file_exists( $filename ) ) { |
102 | | - $languageNames = false; |
103 | | - require( $filename ); |
104 | | - if ( is_array( $languageNames ) ) { |
105 | | - if ( isset( self::$cache[$code] ) ) { |
106 | | - // Add to existing list of localized language names |
107 | | - self::$cache[$code] = self::$cache[$code] + $languageNames; |
108 | | - } else { |
109 | | - // No list exists, so create it |
110 | | - self::$cache[$code] = $languageNames; |
111 | | - } |
| 109 | + $filename = dirname( __FILE__ ) . '/CldrNames/' . self::getFileName( $code ); |
| 110 | + if ( file_exists( $filename ) ) { |
| 111 | + $languageNames = false; |
| 112 | + require( $filename ); |
| 113 | + if ( is_array( $languageNames ) ) { |
| 114 | + if ( isset( self::$cache[$code] ) ) { |
| 115 | + // Add to existing list of localized language names |
| 116 | + self::$cache[$code] = self::$cache[$code] + $languageNames; |
| 117 | + } else { |
| 118 | + // No list exists, so create it |
| 119 | + self::$cache[$code] = $languageNames; |
112 | 120 | } |
113 | | - } else { |
114 | | - wfDebug( __METHOD__ . ": Unable to load language names for $filename\n" ); |
115 | 121 | } |
116 | | - wfProfileOut( __METHOD__ . '-recache' ); |
| 122 | + } else { |
| 123 | + wfDebug( __METHOD__ . ": Unable to load language names for $filename\n" ); |
117 | 124 | } |
| 125 | + wfProfileOut( __METHOD__ . '-recache' ); |
118 | 126 | |
119 | | - return isset( self::$cache[$code] ) ? self::$cache[$code] : array(); |
| 127 | + return self::$cache[$code]; |
120 | 128 | } |
121 | 129 | |
122 | 130 | /** |