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;
187 'apiCode' => $this->apiCode,
188 'apiData' => $this->apiData,
195 $this->apiCode = $data[
'apiCode'];
196 $this->apiData = $data[
'apiData'];
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 );