Merge "(bug 45937) API: Check amlang in meta=allmessages"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 13 Mar 2013 15:00:27 +0000 (15:00 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 13 Mar 2013 15:00:27 +0000 (15:00 +0000)
RELEASE-NOTES-1.21
includes/api/ApiQueryAllMessages.php

index 5864069..edd7771 100644 (file)
@@ -264,6 +264,8 @@ production.
 * (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.
index 0555a39..c9811b0 100644 (file)
@@ -40,6 +40,8 @@ class ApiQueryAllMessages extends ApiQueryBase {
 
                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 @@ class ApiQueryAllMessages extends ApiQueryBase {
                );
        }
 
+       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(