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;
180 'apiCode' => $this->apiCode,
181 'apiData' => $this->apiData,
188 $this->apiCode = $data[
'apiCode'];
189 $this->apiData = $data[
'apiData'];
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 );