From 4bc595fa1cb7096be777f79ecf1504b311061517 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 5 Nov 2005 07:10:09 +0000 Subject: [PATCH] * (bug 3666) Don't spew PHP warnings in prefs on unrecognized site language --- RELEASE-NOTES | 1 + includes/SpecialPreferences.php | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 9e19c0fc5f..524d002707 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -205,6 +205,7 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 3877) Render math images into temp directory, then move to hashed subdir so you can render new math images and have them work * (bug 3797) Don't expand variables and sigs in comments +* (bug 3666) Don't spew PHP warnings in prefs on unrecognized site language === Caveats === diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index ea453bdfbe..838e43e57d 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -552,12 +552,21 @@ class PreferencesForm { ) ); + /** + * Make sure the site language is in the list; a custom language code + * might not have a defined name... + */ + $languages = $wgLang->getLanguageNames(); + if( !array_key_exists( $wgContLanguageCode, $languages ) ) { + $languages[$wgContLanguageCode] = $wgContLanguageCode; + } + ksort( $languages ); + /** * If a bogus value is set, default to the content language. * Otherwise, no default is selected and the user ends up * with an Afrikaans interface since it's first in the list. */ - $languages = $wgLang->getLanguageNames(); $selectedLang = isset( $languages[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode; $selbox = null; foreach($languages as $code => $name) { @@ -579,11 +588,13 @@ class PreferencesForm { /* see if there are multiple language variants to choose from*/ if(!$wgDisableLangConversion) { $variants = $wgContLang->getVariants(); + $variantArray = array(); foreach($variants as $v) { $v = str_replace( '_', '-', strtolower($v)); - if($name = $languages[$v]) { - $variantArray[$v] = $name; + if( array_key_exists( $v, $languages ) ) { + // If it doesn't have a name, we'll pretend it doesn't exist + $variantArray[$v] = $languages[$v]; } } -- 2.20.1