X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryAllMessages.php;h=6b1d5a2a7ca5b8281d5812e4a90c4ad6fbae2417;hb=edbc9edd09ac2f34a97a81aa917a51a0c45649a8;hp=b0ecca856a53ee1887835a15988c46a3d4bfa3de;hpb=66b9ab2c28b78cd15ce7ae253185d6d5413d72c1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryAllMessages.php b/includes/api/ApiQueryAllMessages.php index b0ecca856a..6b1d5a2a7c 100644 --- a/includes/api/ApiQueryAllMessages.php +++ b/includes/api/ApiQueryAllMessages.php @@ -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'] ); } @@ -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; @@ -240,10 +241,10 @@ class ApiQueryAllMessages extends ApiQueryBase { 'messages' => 'Which messages to output. "*" (default) means all messages', 'prop' => 'Which properties to get', 'enableparser' => array( 'Set to enable parser, will preprocess the wikitext of message', - 'Will substitute magic words, handle templates etc.' ), + 'Will substitute magic words, handle templates etc.' ), 'nocontent' => 'If set, do not include the content of the messages in the output.', 'includelocal' => array( "Also include local messages, i.e. messages that don't exist in the software but do exist as a MediaWiki: page.", - "This lists all MediaWiki: pages, so it will also list those that aren't 'really' messages such as Common.js", + "This lists all MediaWiki: pages, so it will also list those that aren't 'really' messages such as Common.js", ), 'title' => 'Page name to use as context when parsing message (for enableparser option)', 'args' => 'Arguments to be substituted into 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(