78 protected static $messageMap = [
79 'actionthrottledtext' =>
'ratelimited',
80 'autoblockedtext' =>
'autoblocked',
81 'badaccess-group0' =>
'permissiondenied',
82 'badaccess-groups' =>
'permissiondenied',
83 'badipaddress' =>
'invalidip',
84 'blankpage' =>
'emptypage',
85 'blockedtext' =>
'blocked',
86 'cannotdelete' =>
'cantdelete',
87 'cannotundelete' =>
'cantundelete',
88 'cantmove-titleprotected' =>
'protectedtitle',
89 'cantrollback' =>
'onlyauthor',
90 'confirmedittext' =>
'confirmemail',
91 'content-not-allowed-here' =>
'contentnotallowedhere',
92 'deleteprotected' =>
'cantedit',
93 'delete-toobig' =>
'bigdelete',
94 'edit-conflict' =>
'editconflict',
95 'imagenocrossnamespace' =>
'nonfilenamespace',
96 'imagetypemismatch' =>
'filetypemismatch',
97 'importbadinterwiki' =>
'badinterwiki',
98 'importcantopen' =>
'cantopenfile',
99 'import-noarticle' =>
'badinterwiki',
100 'importnofile' =>
'nofile',
101 'importuploaderrorpartial' =>
'partialupload',
102 'importuploaderrorsize' =>
'filetoobig',
103 'importuploaderrortemp' =>
'notempdir',
104 'ipb_already_blocked' =>
'alreadyblocked',
105 'ipb_blocked_as_range' =>
'blockedasrange',
106 'ipb_cant_unblock' =>
'cantunblock',
107 'ipb_expiry_invalid' =>
'invalidexpiry',
108 'ip_range_invalid' =>
'invalidrange',
109 'mailnologin' =>
'cantsend',
110 'markedaspatrollederror-noautopatrol' =>
'noautopatrol',
111 'movenologintext' =>
'cantmove-anon',
112 'movenotallowed' =>
'cantmove',
113 'movenotallowedfile' =>
'cantmovefile',
114 'namespaceprotected' =>
'protectednamespace',
115 'nocreate-loggedin' =>
'cantcreate',
116 'nocreatetext' =>
'cantcreate-anon',
117 'noname' =>
'invaliduser',
118 'nosuchusershort' =>
'nosuchuser',
119 'notanarticle' =>
'missingtitle',
120 'nouserspecified' =>
'invaliduser',
121 'ns-specialprotected' =>
'unsupportednamespace',
122 'protect-cantedit' =>
'cantedit',
123 'protectedinterface' =>
'protectednamespace-interface',
124 'protectedpagetext' =>
'protectedpage',
125 'range_block_disabled' =>
'rangedisabled',
126 'rcpatroldisabled' =>
'patroldisabled',
127 'readonlytext' =>
'readonly',
128 'sessionfailure' =>
'badtoken',
129 'systemblockedtext' =>
'blocked',
130 'titleprotected' =>
'protectedtitle',
131 'undo-failure' =>
'undofailure',
132 'userrights-nodatabase' =>
'nosuchdatabase',
133 'userrights-no-interwiki' =>
'nointerwikiuserrights',
140 if ( $this->apiCode ===
null ) {
141 $key = $this->getKey();
142 if ( isset( self::$messageMap[$key] ) ) {
143 $this->apiCode = self::$messageMap[$key];
144 } elseif ( $key ===
'apierror-missingparam' ) {
146 $this->apiCode =
'no' . $this->getParams()[0];
147 } elseif ( substr( $key, 0, 8 ) ===
'apiwarn-' ) {
148 $this->apiCode = substr( $key, 8 );
149 } elseif ( substr( $key, 0, 9 ) ===
'apierror-' ) {
150 $this->apiCode = substr( $key, 9 );
152 $this->apiCode = $key;
160 throw new InvalidArgumentException(
"Invalid code \"$code\"" );
163 $this->apiCode =
$code;
164 if ( $data !==
null ) {
174 $this->apiData = $data;
179 'parent' => parent::serialize(),
180 'apiCode' => $this->apiCode,
181 'apiData' => $this->apiData,
187 parent::unserialize( $data[
'parent'] );
188 $this->apiCode = $data[
'apiCode'];
189 $this->apiData = $data[
'apiData'];
212 public static function create( $msg,
$code =
null, array $data =
null ) {
213 if ( is_array( $msg ) ) {
215 if ( isset( $msg[
'message'] ) ) {
216 if ( isset( $msg[
'params'] ) ) {
217 $msg = array_merge( [ $msg[
'message'] ], $msg[
'params'] );
219 $msg = [ $msg[
'message'] ];
247 if ( $msg instanceof
Message ) {
248 foreach ( get_class_vars( get_class( $this ) ) as
$key =>
$value ) {
249 if ( isset( $msg->$key ) ) {
250 $this->
$key = $msg->$key;
253 } elseif ( is_array( $msg ) ) {
254 $key = array_shift( $msg );
255 parent::__construct(
$key, $msg );
257 parent::__construct( $msg );
281 foreach ( get_class_vars( get_class( $this ) ) as
$key =>
$value ) {
282 if ( isset( $msg->$key ) ) {
283 $this->
$key = $msg->$key;
286 } elseif ( is_array( $msg ) ) {
287 $key = array_shift( $msg );
288 parent::__construct(
$key, $msg );
290 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