jenkins-bot has submitted this change and it was merged.

Change subject: Set lang in api createaccount regardless of 
$wgLoginLanguageSelector
......................................................................


Set lang in api createaccount regardless of $wgLoginLanguageSelector

$wgLoginLanguageSelector is related to how the interface of
special:userlogin works. It doesn't make sense to listen to it
in the api module

Also throw error if invalid lang code is specified (for sanity)

Change-Id: Ibf72fd5a318cadc450b3b579757ee8145864a27a
---
M includes/api/ApiCreateAccount.php
1 file changed, 10 insertions(+), 4 deletions(-)

Approvals:
  Demon: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/api/ApiCreateAccount.php 
b/includes/api/ApiCreateAccount.php
index 55c60cc..1eb1aa5 100644
--- a/includes/api/ApiCreateAccount.php
+++ b/includes/api/ApiCreateAccount.php
@@ -54,6 +54,10 @@
                        $this->dieUsageMsg( 'noemail' );
                }
 
+               if ( $params['language'] && !Language::isSupportedLanguage( 
$params['language'] ) ) {
+                       $this->dieUsage( 'Invalid language parameter', 
'langinvalid' );
+               }
+
                $context = new DerivativeContext( $this->getContext() );
                $context->setRequest( new DerivativeRequest(
                        $this->getContext()->getRequest(),
@@ -80,12 +84,10 @@
                $result = array();
                if( $status->isGood() ) {
                        // Success!
+                       global $wgEmailAuthentication;
                        $user = $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
-                       global $wgLoginLanguageSelector, $wgEmailAuthentication;
-                       if( $wgLoginLanguageSelector && $params['language'] ) {
+                       if( $params['language'] ) {
                                $user->setOption( 'language', 
$params['language'] );
                        }
 
@@ -275,6 +277,10 @@
                        'code' => 'aborted',
                        'info' => 'Account creation aborted by hook (info may 
vary)'
                );
+               $errors[] = array(
+                       'code' => 'langinvalid',
+                       'info' => 'Invalid language parameter'
+               );
 
                // 'passwordtooshort' has parameters. :(
                global $wgMinimalPasswordLength;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibf72fd5a318cadc450b3b579757ee8145864a27a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Demon <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to