* (bug 3666) Don't spew PHP warnings in prefs on unrecognized site language
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 5 Nov 2005 07:10:09 +0000 (07:10 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 5 Nov 2005 07:10:09 +0000 (07:10 +0000)
RELEASE-NOTES
includes/SpecialPreferences.php

index 9e19c0f..524d002 100644 (file)
@@ -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 ===
index ea453bd..838e43e 100644 (file)
@@ -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];
                                }
                        }