Merge "Web installer: correctly show note for I4ecd0659"
[lhc/web/wiklou.git] / includes / api / ApiQueryAllMessages.php
index 6b6b1a3..d47c7b7 100644 (file)
@@ -39,8 +39,9 @@ class ApiQueryAllMessages extends ApiQueryBase {
                $params = $this->extractRequestParams();
 
                if ( is_null( $params['lang'] ) ) {
-                       global $wgLang;
-                       $langObj = $wgLang;
+                       $langObj = $this->getLanguage();
+               } elseif ( !Language::isValidCode( $params['lang'] ) ) {
+                       $this->dieUsage( 'Invalid language code for parameter lang', 'invalidlang' );
                } else {
                        $langObj = Language::factory( $params['lang'] );
                }
@@ -48,7 +49,7 @@ class ApiQueryAllMessages extends ApiQueryBase {
                if ( $params['enableparser'] ) {
                        if ( !is_null( $params['title'] ) ) {
                                $title = Title::newFromText( $params['title'] );
-                               if ( !$title ) {
+                               if ( !$title || $title->isExternal() ) {
                                        $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
                                }
                        } else {
@@ -86,7 +87,7 @@ class ApiQueryAllMessages extends ApiQueryBase {
                        foreach ( $messages_target as $message ) {
                                // === 0: must be at beginning of string (position 0)
                                if ( strpos( $message, $params['prefix'] ) === 0 ) {
-                                       if( !$skip ) {
+                                       if ( !$skip ) {
                                                $skip = true;
                                        }
                                        $messages_filtered[] = $message;
@@ -256,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(