Stepzhou has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/120475

Change subject: Slightly saner email default on user creation with @donyu.
......................................................................

Slightly saner email default on user creation with @donyu.

Tries to use wikilanguage cookie, HTTP request Accept Header, and then
the get preferred variant in that order.

bug 40379

Change-Id: I935735a69f24841f9e5cd502ef67b6f6323606be
---
M includes/specials/SpecialUserlogin.php
1 file changed, 17 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/75/120475/1

diff --git a/includes/specials/SpecialUserlogin.php 
b/includes/specials/SpecialUserlogin.php
index bbe56ec..4f92015 100644
--- a/includes/specials/SpecialUserlogin.php
+++ b/includes/specials/SpecialUserlogin.php
@@ -108,12 +108,12 @@
                $this->mRemember = $request->getCheck( 'wpRemember' );
                $this->mFromHTTP = $request->getBool( 'fromhttp', false );
                $this->mStickHTTPS = ( !$this->mFromHTTP && 
$request->getProtocol() === 'https' ) || $request->getBool( 'wpForceHttps', 
false );
-               $this->mLanguage = $request->getText( 'uselang' );
                $this->mSkipCookieCheck = $request->getCheck( 
'wpSkipCookieCheck' );
                $this->mToken = ( $this->mType == 'signup' ) ? 
$request->getVal( 'wpCreateaccountToken' ) : $request->getVal( 'wpLoginToken' );
                $this->mReturnTo = $request->getVal( 'returnto', '' );
                $this->mReturnToQuery = $request->getVal( 'returntoquery', '' );
 
+               
                if ( $wgEnableEmail ) {
                        $this->mEmail = $request->getText( 'wpEmail' );
                } else {
@@ -139,6 +139,19 @@
                        || $returnToTitle->isSpecial( 'PasswordReset' ) ) ) {
                        $this->mReturnTo = '';
                        $this->mReturnToQuery = '';
+               }
+
+               // Try to be smart about default language preferences. First 
check
+               // the language cookie, then the HTTP Accept Header, and 
finally the
+               // uselang property.
+               $cookieLang = $request->getCookie( 'language' );
+               $acceptLang = $request->getAcceptLang();
+               if ( $cookieLang ) {
+                       $this->mLanguage = $cookieLang;
+               } else if ( count($acceptLang) > 0 ){
+                       $this->mLanguage = $acceptLang[0];
+               } else {
+                       $this->mLanguage = $request->getText( 'uselang' );
                }
        }
 
@@ -267,9 +280,9 @@
 
                # 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 ) {
+                       # If this language was set, either by language 
selection links or in the
+                       # wikilanguage cookies somehow, save that language as 
the user's preference
+                       if ( $this->mLanguage && Language::isSupportedLanguage( 
$this->mLanguage ) ) {
                                $u->setOption( 'language', $this->mLanguage );
                        } else {
 

-- 
To view, visit https://gerrit.wikimedia.org/r/120475
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I935735a69f24841f9e5cd502ef67b6f6323606be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Stepzhou <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to