/**
* Cache for language names
- * @var MapCacheLRU|null
+ * @var HashBagOStuff|null
*/
static private $languageNameCache;
* @return bool
*/
public static function isKnownLanguageTag( $tag ) {
- static $coreLanguageNames;
-
// Quick escape for invalid input to avoid exceptions down the line
// when code tries to process tags which are not valid at all.
if ( !self::isValidBuiltInCode( $tag ) ) {
return false;
}
- if ( $coreLanguageNames === null ) {
- global $IP;
- include "$IP/languages/Names.php";
- }
-
- if ( isset( $coreLanguageNames[$tag] )
+ if ( isset( MediaWiki\Languages\Data\Names::$names[$tag] )
|| self::fetchLanguageName( $tag, $tag ) !== ''
) {
return true;
$cacheKey = $inLanguage === null ? 'null' : $inLanguage;
$cacheKey .= ":$include";
if ( self::$languageNameCache === null ) {
- self::$languageNameCache = new MapCacheLRU( 20 );
+ self::$languageNameCache = new HashBagOStuff( array( 'maxKeys' => 20 ) );
}
- if ( self::$languageNameCache->has( $cacheKey ) ) {
- $ret = self::$languageNameCache->get( $cacheKey );
- } else {
+
+ $ret = self::$languageNameCache->get( $cacheKey );
+ if ( !$ret ) {
$ret = self::fetchLanguageNamesUncached( $inLanguage, $include );
self::$languageNameCache->set( $cacheKey, $ret );
}
*/
private static function fetchLanguageNamesUncached( $inLanguage = null, $include = 'mw' ) {
global $wgExtraLanguageNames;
- static $coreLanguageNames;
-
- if ( $coreLanguageNames === null ) {
- global $IP;
- include "$IP/languages/Names.php";
- }
// If passed an invalid language code to use, fallback to en
if ( $inLanguage !== null && !Language::isValidCode( $inLanguage ) ) {
Hooks::run( 'LanguageGetTranslatedLanguageNames', array( &$names, $inLanguage ) );
}
- $mwNames = $wgExtraLanguageNames + $coreLanguageNames;
+ $mwNames = $wgExtraLanguageNames + MediaWiki\Languages\Data\Names::$names;
foreach ( $mwNames as $mwCode => $mwName ) {
# - Prefer own MediaWiki native name when not using the hook
# - For other names just add if not added through the hook
return (bool)$this->mConverter->validateVariant( $variant );
}
- /**
- * Put custom tags (e.g. -{ }-) around math to prevent conversion
- *
- * @param string $text
- * @return string
- * @deprecated since 1.22 is no longer used
- */
- public function armourMath( $text ) {
- return $this->mConverter->armourMath( $text );
- }
-
/**
* Perform output conversion on a string, and encode for safe HTML output.
* @param string $text Text to be converted
* @return bool|string
*/
public static function getFallbackFor( $code ) {
- if ( $code === 'en' || !Language::isValidBuiltInCode( $code ) ) {
- return false;
- } else {
- $fallbacks = self::getFallbacksFor( $code );
+ $fallbacks = self::getFallbacksFor( $code );
+ if ( $fallbacks ) {
return $fallbacks[0];
}
+ return false;
}
/**