* 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' ]
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 ) {
} 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() ) ];
$ret = preg_replace( '!</?(var|kbd|samp|code)>!', '"', $text );
// Strip tags and decode.
- $ret = html_entity_decode( strip_tags( $ret ), ENT_QUOTES | ENT_HTML5 );
+ $ret = Sanitizer::stripAllTags( $ret );
return $ret;
}
* @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