Go to the documentation of this file.
75 return is_string( $code ) && (
76 preg_match(
'/^[a-zA-Z0-9_-]+$/', $code ) ||
78 preg_match(
'/^internal_api_error_[^\0\r\n]+$/', $code )
116 if ( self::$dummyTitle ===
null ) {
129 public function addWarning( $modulePath, $msg, $code =
null, $data =
null ) {
131 ->inLanguage( $this->lang )
133 ->useDatabase( $this->useDB );
144 public function addError( $modulePath, $msg, $code =
null, $data =
null ) {
146 ->inLanguage( $this->lang )
148 ->useDatabase( $this->useDB );
166 $types = (array)$types;
167 foreach (
$status->getErrors() as $error ) {
168 if ( !in_array( $error[
'type'], $types,
true ) ) {
172 if ( $error[
'type'] ===
'error' ) {
180 ->inLanguage( $this->lang )
182 ->useDatabase( $this->useDB );
183 if ( !in_array( $msg->getKey(),
$filter,
true ) ) {
202 $options += [
'code' =>
null,
'data' => [] ];
205 $msg = $exception->getMessageObject();
208 $msg = Message::newFromSpecifier( $exception );
211 if ( isset( $options[
'wrap'] ) ) {
212 $msg = $options[
'wrap'];
215 if ( !isset( $options[
'code'] ) ) {
216 $class = preg_replace(
'#^Wikimedia\\\Rdbms\\\#',
'', get_class( $exception ) );
217 $options[
'code'] =
'internal_api_error_' . $class;
218 $options[
'data'][
'errorclass'] = get_class( $exception );
225 ->inLanguage( $this->lang )
227 ->useDatabase( $this->useDB );
242 $options[
'format'] ??
null
254 ->inLanguage( $this->lang )
256 ->useDatabase( $this->useDB );
276 $formatter->addMessagesFromStatus(
null,
$status, [
$type ] );
293 $ret = preg_replace(
'!</?(var|kbd|samp|code)>!',
'"', $text );
296 $ret = Sanitizer::stripAllTags( $ret );
314 foreach ( $ret[
'params'] as $i => $param ) {
330 $value = [
'code' => $msg->getApiCode() ];
341 'text' => $msg->text(),
348 'html' => $msg->parse(),
360 $data = $msg->getApiData();
362 $value[
'data'] = $msg->getApiData() + [
377 if ( $modulePath !==
null ) {
378 $value += [
'module' => $modulePath ];
381 $path = [ $tag .
's' ];
382 $existing = $this->result->getResultData(
$path );
383 if ( $existing ===
null || !in_array( $value, $existing ) ) {
385 if ( $existing ===
null ) {
388 $this->result->addValue(
$path,
null, $value, $flags );
389 $this->result->addIndexedTagName(
$path, $tag );
Generic operation result class Has warning/error list, boolean status and arbitrary value.
const META_TYPE
Key for the 'type' metadata item.
getKey()
Returns the message key.
const NO_SIZE_CHECK
For addValue() and similar functions, do not check size while adding a value Don't use this unless yo...
getParams()
Returns the message parameters.
This class represents the result of the API operations.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
Interface for MediaWiki-localized exceptions.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Represents a title within MediaWiki.
const ADD_ON_TOP
For addValue(), setValue() and similar functions, if the value does not exist, add it as the first el...
getResultData( $path=[], $transforms=[])
Get the result data array.
Variant of the Message class.
const META_CONTENT
Key for the 'content' metadata item.
Internationalisation code.