Merge "Set initial language and variant user preferences to user's preferred variant...
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 18 Mar 2013 00:11:19 +0000 (00:11 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 18 Mar 2013 00:11:19 +0000 (00:11 +0000)
includes/specials/SpecialUserlogin.php

index dc350bf..eef6691 100644 (file)
@@ -230,7 +230,7 @@ class LoginForm extends SpecialPage {
         * @return bool
         */
        function addNewAccount() {
-               global $wgUser, $wgEmailAuthentication, $wgLoginLanguageSelector;
+               global $wgContLang, $wgUser, $wgEmailAuthentication, $wgLoginLanguageSelector;
 
                # Create the account and abort if there's a problem doing so
                $status = $this->addNewAccountInternal();
@@ -242,10 +242,22 @@ class LoginForm extends SpecialPage {
 
                $u = $status->getValue();
 
-               # If we showed up language selection links, and one was in use, be
-               # smart (and sensible) and save that language as the user's preference
-               if( $wgLoginLanguageSelector && $this->mLanguage ) {
-                       $u->setOption( 'language', $this->mLanguage );
+               # Only save preferences if the user is not creating an account for someone else.
+               if ( $this->getUser()->isAnon() ) {
+                       # If we showed up language selection links, and one was in use, be
+                       # smart (and sensible) and save that language as the user's preference
+                       if( $wgLoginLanguageSelector && $this->mLanguage ) {
+                               $u->setOption( 'language', $this->mLanguage );
+                       } else {
+
+                               # Otherwise the user's language preference defaults to $wgContLang,
+                               # but it may be better to set it to their preferred $wgContLang variant,
+                               # based on browser preferences or URL parameters.
+                               $u->setOption( 'language', $wgContLang->getPreferredVariant() );
+                       }
+                       if ( $wgContLang->hasVariants() ) {
+                               $u->setOption( 'variant', $wgContLang->getPreferredVariant() );
+                       }
                }
 
                $out = $this->getOutput();