34 protected static $messageMap = [
35 'actionthrottledtext' =>
'ratelimited',
36 'autoblockedtext' =>
'autoblocked',
37 'badaccess-group0' =>
'permissiondenied',
38 'badaccess-groups' =>
'permissiondenied',
39 'badipaddress' =>
'invalidip',
40 'blankpage' =>
'emptypage',
41 'blockedtext' =>
'blocked',
42 'blockedtext-composite' =>
'blocked',
43 'blockedtext-partial' =>
'blocked',
44 'cannotdelete' =>
'cantdelete',
45 'cannotundelete' =>
'cantundelete',
46 'cantmove-titleprotected' =>
'protectedtitle',
47 'cantrollback' =>
'onlyauthor',
48 'confirmedittext' =>
'confirmemail',
49 'content-not-allowed-here' =>
'contentnotallowedhere',
50 'deleteprotected' =>
'cantedit',
51 'delete-toobig' =>
'bigdelete',
52 'edit-conflict' =>
'editconflict',
53 'imagenocrossnamespace' =>
'nonfilenamespace',
54 'imagetypemismatch' =>
'filetypemismatch',
55 'importbadinterwiki' =>
'badinterwiki',
56 'importcantopen' =>
'cantopenfile',
57 'import-noarticle' =>
'badinterwiki',
58 'importnofile' =>
'nofile',
59 'importuploaderrorpartial' =>
'partialupload',
60 'importuploaderrorsize' =>
'filetoobig',
61 'importuploaderrortemp' =>
'notempdir',
62 'ipb_already_blocked' =>
'alreadyblocked',
63 'ipb_blocked_as_range' =>
'blockedasrange',
64 'ipb_cant_unblock' =>
'cantunblock',
65 'ipb_expiry_invalid' =>
'invalidexpiry',
66 'ip_range_invalid' =>
'invalidrange',
67 'mailnologin' =>
'cantsend',
68 'markedaspatrollederror-noautopatrol' =>
'noautopatrol',
69 'movenologintext' =>
'cantmove-anon',
70 'movenotallowed' =>
'cantmove',
71 'movenotallowedfile' =>
'cantmovefile',
72 'namespaceprotected' =>
'protectednamespace',
73 'nocreate-loggedin' =>
'cantcreate',
74 'nocreatetext' =>
'cantcreate-anon',
75 'noname' =>
'invaliduser',
76 'nosuchusershort' =>
'nosuchuser',
77 'notanarticle' =>
'missingtitle',
78 'nouserspecified' =>
'invaliduser',
79 'ns-specialprotected' =>
'unsupportednamespace',
80 'protect-cantedit' =>
'cantedit',
81 'protectedinterface' =>
'protectednamespace-interface',
82 'protectedpagetext' =>
'protectedpage',
83 'range_block_disabled' =>
'rangedisabled',
84 'rcpatroldisabled' =>
'patroldisabled',
85 'readonlytext' =>
'readonly',
86 'sessionfailure' =>
'badtoken',
87 'systemblockedtext' =>
'blocked',
88 'titleprotected' =>
'protectedtitle',
89 'undo-failure' =>
'undofailure',
90 'userrights-nodatabase' =>
'nosuchdatabase',
91 'userrights-no-interwiki' =>
'nointerwikiuserrights',
98 if ( $this->apiCode ===
null ) {
99 $key = $this->getKey();
100 if ( isset( self::$messageMap[$key] ) ) {
101 $this->apiCode = self::$messageMap[$key];
102 } elseif ( $key ===
'apierror-missingparam' ) {
104 $this->apiCode =
'no' . $this->getParams()[0];
105 } elseif ( substr( $key, 0, 8 ) ===
'apiwarn-' ) {
106 $this->apiCode = substr( $key, 8 );
107 } elseif ( substr( $key, 0, 9 ) ===
'apierror-' ) {
108 $this->apiCode = substr( $key, 9 );
110 $this->apiCode = $key;
114 $this->apiCode = preg_replace(
'/[^a-zA-Z0-9_-]/',
'_', $this->apiCode );
121 throw new InvalidArgumentException(
"Invalid code \"$code\"" );
124 $this->apiCode = $code;
125 if ( $data !==
null ) {
135 $this->apiData = $data;
141 'apiCode' => $this->apiCode,
142 'apiData' => $this->apiData,
149 $this->apiCode = $data[
'apiCode'];
150 $this->apiData = $data[
'apiData'];