Add backward compatibility for fetchLanguageNames

Bug: 46737
Change-Id: Ife7c2834c2b2c4f2619b4a5d8e0b0aa1db595984
This commit is contained in:
Amir E. Aharoni
2013-04-30 13:33:28 +03:00
parent 4b5283182e
commit c9a5ec7f19
3 changed files with 25 additions and 6 deletions

View File

@@ -33,9 +33,15 @@ class ResourceLoaderULSModule extends ResourceLoaderModule {
*/
protected function getData() {
$vars = array();
$vars['wgULSLanguages'] = Language::fetchLanguageNames(
$this->language->getCode(), 'mwfile'
);
if ( method_exists( 'Language', 'fetchLanguageNames' ) ) {
// since 1.20
$vars['wgULSLanguages'] = Language::fetchLanguageNames(
$this->language->getCode(), 'mwfile'
);
} else {
$vars['wgULSLanguages'] = Language::getLanguageNames( false );
}
return $vars;
}

View File

@@ -105,7 +105,11 @@ class UniversalLanguageSelectorHooks {
protected static function isSupportedLanguage( $language ) {
wfProfileIn( __METHOD__ );
$supported = Language::fetchLanguageNames( null, 'mwfile' );
if ( method_exists( 'Language', 'fetchLanguageNames' ) ) {
$supported = Language::fetchLanguageNames( null, 'mwfile' ); // since 1.20
} else {
$supported = Language::getLanguageNames( false );
}
wfProfileOut( __METHOD__ );
return isset( $supported[$language] );
@@ -117,7 +121,11 @@ class UniversalLanguageSelectorHooks {
*/
protected static function getDefaultLanguage( array $preferred ) {
wfProfileIn( __METHOD__ );
$supported = Language::fetchLanguageNames( null, 'mwfile' );
if ( method_exists( 'Language', 'fetchLanguageNames' ) ) {
$supported = Language::fetchLanguageNames( null, 'mwfile' ); // since 1.20
} else {
$supported = Language::getLanguageNames( false );
}
// look for a language that is acceptable to the client
// and known to the wiki.
foreach ( $preferred as $code => $weight ) {

View File

@@ -33,7 +33,12 @@ class LanguageNameIndexer extends Maintenance {
}
public function execute() {
$languages = Language::fetchLanguageNames( null, 'all' );
if ( method_exists( 'Language', 'fetchLanguageNames' ) ) {
$languages = Language::fetchLanguageNames( null, 'all' ); // since 1.20
} else {
$languages = Language::getLanguageNames( false );
}
$all = array();
$buckets = array();
foreach ( $languages as $code => $name ) {