Merge "XmlSelect: Fix PHPDoc param comments for addOption() & formatOptions()"
[lhc/web/wiklou.git] / includes / api / ApiErrorFormatter.php
index ef28b73..9669464 100644 (file)
@@ -153,9 +153,10 @@ class ApiErrorFormatter {
         * @param string|null $modulePath
         * @param StatusValue $status
         * @param string[]|string $types 'warning' and/or 'error'
+        * @param string[] $filter Messages to filter out (since 1.33)
         */
        public function addMessagesFromStatus(
-               $modulePath, StatusValue $status, $types = [ 'warning', 'error' ]
+               $modulePath, StatusValue $status, $types = [ 'warning', 'error' ], array $filter = []
        ) {
                if ( $status->isGood() || !$status->getErrors() ) {
                        return;
@@ -178,7 +179,9 @@ class ApiErrorFormatter {
                                ->inLanguage( $this->lang )
                                ->title( $this->getDummyTitle() )
                                ->useDatabase( $this->useDB );
-                       $this->addWarningOrError( $tag, $modulePath, $msg );
+                       if ( !in_array( $msg->getKey(), $filter, true ) ) {
+                               $this->addWarningOrError( $tag, $modulePath, $msg );
+                       }
                }
        }
 
@@ -211,6 +214,7 @@ class ApiErrorFormatter {
                                if ( !isset( $options['code'] ) ) {
                                        $class = preg_replace( '#^Wikimedia\\\Rdbms\\\#', '', get_class( $exception ) );
                                        $options['code'] = 'internal_api_error_' . $class;
+                                       $options['data']['errorclass'] = get_class( $exception );
                                }
                        }
                        $params = [ wfEscapeWikiText( $exception->getMessage() ) ];