X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiErrorFormatter.php;h=c637752dfb01ce9f286343f3bc07d4983c78dd1a;hb=9ea0a461d95180a2eea6fbda0391ac27b4c3e5fc;hp=c52b731bbdb3b0f616b689317a9c9b0648cdcafd;hpb=f4e63f6047131a1dd6f8bd6dfafcfba44b22873d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiErrorFormatter.php b/includes/api/ApiErrorFormatter.php index c52b731bbd..c637752dfb 100644 --- a/includes/api/ApiErrorFormatter.php +++ b/includes/api/ApiErrorFormatter.php @@ -112,7 +112,7 @@ class ApiErrorFormatter { * Add warnings and errors from a StatusValue object to the result * @param string|null $modulePath * @param StatusValue $status - * @param string[] $types 'warning' and/or 'error' + * @param string[]|string $types 'warning' and/or 'error' */ public function addMessagesFromStatus( $modulePath, StatusValue $status, $types = [ 'warning', 'error' ] @@ -160,6 +160,9 @@ class ApiErrorFormatter { if ( $exception instanceof ILocalizedException ) { $msg = $exception->getMessageObject(); $params = []; + } elseif ( $exception instanceof MessageSpecifier ) { + $msg = Message::newFromSpecifier( $exception ); + $params = []; } else { // Extract code and data from the exception, if applicable if ( $exception instanceof UsageException ) { @@ -176,7 +179,8 @@ class ApiErrorFormatter { } else { $msg = new RawMessage( '$1' ); if ( !isset( $options['code'] ) ) { - $options['code'] = 'internal_api_error_' . get_class( $exception ); + $class = preg_replace( '#^Wikimedia\\\Rdbms\\\#', '', get_class( $exception ) ); + $options['code'] = 'internal_api_error_' . $class; } } $params = [ wfEscapeWikiText( $exception->getMessage() ) ]; @@ -253,7 +257,7 @@ class ApiErrorFormatter { $ret = preg_replace( '!!', '"', $text ); // Strip tags and decode. - $ret = html_entity_decode( strip_tags( $ret ), ENT_QUOTES | ENT_HTML5 ); + $ret = Sanitizer::stripAllTags( $ret ); return $ret; } @@ -357,9 +361,8 @@ class ApiErrorFormatter { * @deprecated Only for backwards compatibility, do not use * @ingroup API */ -// @codingStandardsIgnoreStart Squiz.Classes.ValidClassName.NotCamelCaps +// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps class ApiErrorFormatter_BackCompat extends ApiErrorFormatter { - // @codingStandardsIgnoreEnd /** * @param ApiResult $result Into which data will be added