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

Change subject: (bug 45937) API: Check amlang in meta=allmessages
......................................................................


(bug 45937) API: Check amlang in meta=allmessages

Language::factory() throws an exception if given a syntactically invalid
code. Check the code beforehand to generate a proper error message.

Bug: 45937
Change-Id: I521e6f7ffc44becb302fde33c1df3879baa4045a
---
M RELEASE-NOTES-1.21
M includes/api/ApiQueryAllMessages.php
2 files changed, 10 insertions(+), 0 deletions(-)

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



diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21
index 883fb8b..76811ce 100644
--- a/RELEASE-NOTES-1.21
+++ b/RELEASE-NOTES-1.21
@@ -259,6 +259,8 @@
 * (bug 33304) list=allpages will no longer return duplicate entries when
   querying protection.
 * (bug 33304) list=allpages will now find really old indefinite protections.
+* (bug 45937) meta=allmessages will report a syntactically invalid lang as a
+  proper error instead of as an uncaught exception.
 
 === API internal changes in 1.21 ===
 * For debugging only, a new global $wgDebugAPI removes many API restrictions 
when true.
diff --git a/includes/api/ApiQueryAllMessages.php 
b/includes/api/ApiQueryAllMessages.php
index 0555a39..c9811b0 100644
--- a/includes/api/ApiQueryAllMessages.php
+++ b/includes/api/ApiQueryAllMessages.php
@@ -40,6 +40,8 @@
 
                if ( is_null( $params['lang'] ) ) {
                        $langObj = $this->getLanguage();
+               } elseif ( !Language::isValidCode( $params['lang'] ) ) {
+                       $this->dieUsage( 'Invalid language code for parameter 
lang', 'invalidlang' );
                } else {
                        $langObj = Language::factory( $params['lang'] );
                }
@@ -255,6 +257,12 @@
                );
        }
 
+       public function getPossibleErrors() {
+               return array_merge( parent::getPossibleErrors(), array(
+                       array( 'code' => 'invalidlang', 'info' => 'Invalid 
language code for parameter lang' ),
+               ) );
+       }
+
        public function getResultProperties() {
                return array(
                        '' => array(

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I521e6f7ffc44becb302fde33c1df3879baa4045a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to