85 protected static $messageMap = [
86 'actionthrottledtext' =>
'ratelimited',
87 'autoblockedtext' =>
'autoblocked',
88 'badaccess-group0' =>
'permissiondenied',
89 'badaccess-groups' =>
'permissiondenied',
90 'badipaddress' =>
'invalidip',
91 'blankpage' =>
'emptypage',
92 'blockedtext' =>
'blocked',
93 'cannotdelete' =>
'cantdelete',
94 'cannotundelete' =>
'cantundelete',
95 'cantmove-titleprotected' =>
'protectedtitle',
96 'cantrollback' =>
'onlyauthor',
97 'confirmedittext' =>
'confirmemail',
98 'content-not-allowed-here' =>
'contentnotallowedhere',
99 'deleteprotected' =>
'cantedit',
100 'delete-toobig' =>
'bigdelete',
101 'edit-conflict' =>
'editconflict',
102 'imagenocrossnamespace' =>
'nonfilenamespace',
103 'imagetypemismatch' =>
'filetypemismatch',
104 'importbadinterwiki' =>
'badinterwiki',
105 'importcantopen' =>
'cantopenfile',
106 'import-noarticle' =>
'badinterwiki',
107 'importnofile' =>
'nofile',
108 'importuploaderrorpartial' =>
'partialupload',
109 'importuploaderrorsize' =>
'filetoobig',
110 'importuploaderrortemp' =>
'notempdir',
111 'ipb_already_blocked' =>
'alreadyblocked',
112 'ipb_blocked_as_range' =>
'blockedasrange',
113 'ipb_cant_unblock' =>
'cantunblock',
114 'ipb_expiry_invalid' =>
'invalidexpiry',
115 'ip_range_invalid' =>
'invalidrange',
116 'mailnologin' =>
'cantsend',
117 'markedaspatrollederror-noautopatrol' =>
'noautopatrol',
118 'movenologintext' =>
'cantmove-anon',
119 'movenotallowed' =>
'cantmove',
120 'movenotallowedfile' =>
'cantmovefile',
121 'namespaceprotected' =>
'protectednamespace',
122 'nocreate-loggedin' =>
'cantcreate',
123 'nocreatetext' =>
'cantcreate-anon',
124 'noname' =>
'invaliduser',
125 'nosuchusershort' =>
'nosuchuser',
126 'notanarticle' =>
'missingtitle',
127 'nouserspecified' =>
'invaliduser',
128 'ns-specialprotected' =>
'unsupportednamespace',
129 'protect-cantedit' =>
'cantedit',
130 'protectedinterface' =>
'protectednamespace-interface',
131 'protectedpagetext' =>
'protectedpage',
132 'range_block_disabled' =>
'rangedisabled',
133 'rcpatroldisabled' =>
'patroldisabled',
134 'readonlytext' =>
'readonly',
135 'sessionfailure' =>
'badtoken',
136 'systemblockedtext' =>
'blocked',
137 'titleprotected' =>
'protectedtitle',
138 'undo-failure' =>
'undofailure',
139 'userrights-nodatabase' =>
'nosuchdatabase',
140 'userrights-no-interwiki' =>
'nointerwikiuserrights',
147 if ( $this->apiCode ===
null ) {
148 $key = $this->getKey();
149 if ( isset( self::$messageMap[$key] ) ) {
150 $this->apiCode = self::$messageMap[$key];
151 } elseif ( $key ===
'apierror-missingparam' ) {
153 $this->apiCode =
'no' . $this->getParams()[0];
154 } elseif ( substr( $key, 0, 8 ) ===
'apiwarn-' ) {
155 $this->apiCode = substr( $key, 8 );
156 } elseif ( substr( $key, 0, 9 ) ===
'apierror-' ) {
157 $this->apiCode = substr( $key, 9 );
159 $this->apiCode = $key;
167 throw new InvalidArgumentException(
"Invalid code \"$code\"" );
170 $this->apiCode =
$code;
171 if ( $data !==
null ) {
181 $this->apiData = $data;
186 'parent' => parent::serialize(),
187 'apiCode' => $this->apiCode,
188 'apiData' => $this->apiData,
194 parent::unserialize( $data[
'parent'] );
195 $this->apiCode = $data[
'apiCode'];
196 $this->apiData = $data[
'apiData'];
219 public static function create( $msg,
$code =
null, array $data =
null ) {
220 if ( is_array( $msg ) ) {
222 if ( isset( $msg[
'message'] ) ) {
223 if ( isset( $msg[
'params'] ) ) {
224 $msg = array_merge( [ $msg[
'message'] ], $msg[
'params'] );
226 $msg = [ $msg[
'message'] ];
254 if ( $msg instanceof
Message ) {
255 foreach ( get_class_vars( get_class( $this ) ) as
$key =>
$value ) {
256 if ( isset( $msg->$key ) ) {
257 $this->
$key = $msg->$key;
260 } elseif ( is_array( $msg ) ) {
261 $key = array_shift( $msg );
262 parent::__construct(
$key, $msg );
264 parent::__construct( $msg );
288 foreach ( get_class_vars( get_class( $this ) ) as
$key =>
$value ) {
289 if ( isset( $msg->$key ) ) {
290 $this->
$key = $msg->$key;
293 } elseif ( is_array( $msg ) ) {
294 $key = array_shift( $msg );
295 parent::__construct(
$key, $msg );
297 parent::__construct( $msg );
unserialize( $serialized)
setApiCode( $code, array $data=null)
Extension of Message implementing IApiMessage.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
__construct( $msg, $code=null, array $data=null)
Extension of RawMessage implementing IApiMessage.
__construct( $msg, $code=null, array $data=null)
The Message class provides methods which fulfil two basic services:
string $key
The message key.
Variant of the Message class.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
trait ApiMessageTrait
Trait to implement the IApiMessage interface for Message subclasses.
Interface for messages with machine-readable data for use by the API.
setApiCode( $code, array $data=null)
Sets the machine-readable code for use by the API.
getApiCode()
Returns a machine-readable code for use by the API.
setApiData(array $data)
Sets additional machine-readable data about the error condition.
getApiData()
Returns additional machine-readable data about the error condition.
foreach( $res as $row) $serialized