Index: trunk/phase3/includes/api/ApiMove.php |
— | — | @@ -46,8 +46,6 @@ |
47 | 47 | $this->requireOnlyOneParameter( $params, 'from', 'fromid' ); |
48 | 48 | if ( !isset( $params['to'] ) ) |
49 | 49 | $this->dieUsageMsg( array( 'missingparam', 'to' ) ); |
50 | | - if ( !isset( $params['token'] ) ) |
51 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
52 | 50 | if ( !$wgUser->matchEditToken( $params['token'] ) ) |
53 | 51 | $this->dieUsageMsg( array( 'sessionfailure' ) ); |
54 | 52 | |
— | — | @@ -215,7 +213,6 @@ |
216 | 214 | public function getPossibleErrors() { |
217 | 215 | return array_merge( parent::getPossibleErrors(), array( |
218 | 216 | array( 'missingparam', 'to' ), |
219 | | - array( 'missingparam', 'token' ), |
220 | 217 | array( 'sessionfailure' ), |
221 | 218 | array( 'invalidtitle', 'from' ), |
222 | 219 | array( 'nosuchpageid', 'fromid' ), |
— | — | @@ -224,6 +221,10 @@ |
225 | 222 | array( 'sharedfile-exists' ), |
226 | 223 | ) ); |
227 | 224 | } |
| 225 | + |
| 226 | + public function requiresToken() { |
| 227 | + return true; |
| 228 | + } |
228 | 229 | |
229 | 230 | protected function getExamples() { |
230 | 231 | return array ( |
Index: trunk/phase3/includes/api/ApiParse.php |
— | — | @@ -325,4 +325,4 @@ |
326 | 326 | public function getVersion() { |
327 | 327 | return __CLASS__ . ': $Id$'; |
328 | 328 | } |
329 | | -} |
| 329 | +} |
\ No newline at end of file |
Index: trunk/phase3/includes/api/ApiProtect.php |
— | — | @@ -43,8 +43,6 @@ |
44 | 44 | $titleObj = null; |
45 | 45 | if ( !isset( $params['title'] ) ) |
46 | 46 | $this->dieUsageMsg( array( 'missingparam', 'title' ) ); |
47 | | - if ( !isset( $params['token'] ) ) |
48 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
49 | 47 | if ( empty( $params['protections'] ) ) |
50 | 48 | $this->dieUsageMsg( array( 'missingparam', 'protections' ) ); |
51 | 49 | |
— | — | @@ -177,7 +175,6 @@ |
178 | 176 | public function getPossibleErrors() { |
179 | 177 | return array_merge( parent::getPossibleErrors(), array( |
180 | 178 | array( 'missingparam', 'title' ), |
181 | | - array( 'missingparam', 'token' ), |
182 | 179 | array( 'missingparam', 'protections' ), |
183 | 180 | array( 'sessionfailure' ), |
184 | 181 | array( 'invalidtitle', 'title' ), |
— | — | @@ -190,6 +187,10 @@ |
191 | 188 | array( 'pastexpiry', 'expiry' ), |
192 | 189 | ) ); |
193 | 190 | } |
| 191 | + |
| 192 | + public function requiresToken() { |
| 193 | + return true; |
| 194 | + } |
194 | 195 | |
195 | 196 | protected function getExamples() { |
196 | 197 | return array ( |
Index: trunk/phase3/includes/api/ApiRollback.php |
— | — | @@ -44,8 +44,6 @@ |
45 | 45 | $this->dieUsageMsg( array( 'missingparam', 'title' ) ); |
46 | 46 | if ( !isset( $params['user'] ) ) |
47 | 47 | $this->dieUsageMsg( array( 'missingparam', 'user' ) ); |
48 | | - if ( !isset( $params['token'] ) ) |
49 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
50 | 48 | |
51 | 49 | $titleObj = Title::newFromText( $params['title'] ); |
52 | 50 | if ( !$titleObj ) |
— | — | @@ -118,12 +116,15 @@ |
119 | 117 | return array_merge( parent::getPossibleErrors(), array( |
120 | 118 | array( 'missingparam', 'title' ), |
121 | 119 | array( 'missingparam', 'user' ), |
122 | | - array( 'missingparam', 'token' ), |
123 | 120 | array( 'invalidtitle', 'title' ), |
124 | 121 | array( 'notanarticle' ), |
125 | 122 | array( 'invaliduser', 'user' ), |
126 | 123 | ) ); |
127 | 124 | } |
| 125 | + |
| 126 | + public function requiresToken() { |
| 127 | + return true; |
| 128 | + } |
128 | 129 | |
129 | 130 | protected function getExamples() { |
130 | 131 | return array ( |
Index: trunk/phase3/includes/api/ApiUserrights.php |
— | — | @@ -41,8 +41,6 @@ |
42 | 42 | $params = $this->extractRequestParams(); |
43 | 43 | if ( is_null( $params['user'] ) ) |
44 | 44 | $this->dieUsageMsg( array( 'missingparam', 'user' ) ); |
45 | | - if ( is_null( $params['token'] ) ) |
46 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
47 | 45 | |
48 | 46 | $form = new UserrightsPage; |
49 | 47 | $user = $form->fetchUser( $params['user'] ); |
— | — | @@ -109,10 +107,13 @@ |
110 | 108 | public function getPossibleErrors() { |
111 | 109 | return array_merge( parent::getPossibleErrors(), array( |
112 | 110 | array( 'missingparam', 'user' ), |
113 | | - array( 'missingparam', 'token' ), |
114 | 111 | array( 'sessionfailure' ), |
115 | 112 | ) ); |
116 | 113 | } |
| 114 | + |
| 115 | + public function requiresToken() { |
| 116 | + return true; |
| 117 | + } |
117 | 118 | |
118 | 119 | protected function getExamples() { |
119 | 120 | return array ( |
Index: trunk/phase3/includes/api/ApiDelete.php |
— | — | @@ -51,8 +51,6 @@ |
52 | 52 | $params = $this->extractRequestParams(); |
53 | 53 | |
54 | 54 | $this->requireOnlyOneParameter( $params, 'title', 'pageid' ); |
55 | | - if ( !isset( $params['token'] ) ) |
56 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
57 | 55 | |
58 | 56 | if ( isset( $params['title'] ) ) |
59 | 57 | { |
— | — | @@ -214,13 +212,16 @@ |
215 | 213 | |
216 | 214 | public function getPossibleErrors() { |
217 | 215 | return array_merge( parent::getPossibleErrors(), array( |
218 | | - array( 'missingparam', 'token' ), |
219 | 216 | array( 'invalidtitle', 'title' ), |
220 | 217 | array( 'nosuchpageid', 'pageid' ), |
221 | 218 | array( 'notanarticle' ), |
222 | 219 | array( 'hookaborted', 'error' ), |
223 | 220 | ) ); |
224 | 221 | } |
| 222 | + |
| 223 | + public function requiresToken() { |
| 224 | + return true; |
| 225 | + } |
225 | 226 | |
226 | 227 | protected function getExamples() { |
227 | 228 | return array ( |
Index: trunk/phase3/includes/api/ApiImport.php |
— | — | @@ -44,8 +44,6 @@ |
45 | 45 | if ( !$wgUser->isAllowed( 'import' ) ) |
46 | 46 | $this->dieUsageMsg( array( 'cantimport' ) ); |
47 | 47 | $params = $this->extractRequestParams(); |
48 | | - if ( !isset( $params['token'] ) ) |
49 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
50 | 48 | if ( !$wgUser->matchEditToken( $params['token'] ) ) |
51 | 49 | $this->dieUsageMsg( array( 'sessionfailure' ) ); |
52 | 50 | |
— | — | @@ -146,7 +144,6 @@ |
147 | 145 | public function getPossibleErrors() { |
148 | 146 | return array_merge( parent::getPossibleErrors(), array( |
149 | 147 | array( 'cantimport' ), |
150 | | - array( 'missingparam', 'token' ), |
151 | 148 | array( 'sessionfailure' ), |
152 | 149 | array( 'missingparam', 'interwikipage' ), |
153 | 150 | array( 'cantimport-upload' ), |
— | — | @@ -154,6 +151,10 @@ |
155 | 152 | array( 'import-unknownerror', 'result' ), |
156 | 153 | ) ); |
157 | 154 | } |
| 155 | + |
| 156 | + public function requiresToken() { |
| 157 | + return true; |
| 158 | + } |
158 | 159 | |
159 | 160 | protected function getExamples() { |
160 | 161 | return array( |
Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -53,9 +53,6 @@ |
54 | 54 | $params['undo'] == 0 ) |
55 | 55 | $this->dieUsageMsg( array( 'missingtext' ) ); |
56 | 56 | |
57 | | - if ( is_null( $params['token'] ) ) |
58 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
59 | | - |
60 | 57 | if ( !$wgUser->matchEditToken( $params['token'] ) ) |
61 | 58 | $this->dieUsageMsg( array( 'sessionfailure' ) ); |
62 | 59 | |
— | — | @@ -350,7 +347,6 @@ |
351 | 348 | return array_merge( parent::getPossibleErrors(), array( |
352 | 349 | array( 'missingparam', 'title' ), |
353 | 350 | array( 'missingtext' ), |
354 | | - array( 'missingparam', 'token' ), |
355 | 351 | array( 'sessionfailure' ), |
356 | 352 | array( 'invalidtitle', 'title' ), |
357 | 353 | array( 'createonly-exists' ), |
— | — | @@ -466,6 +462,10 @@ |
467 | 463 | 'undoafter' => 'Undo all revisions from undo to this one. If not set, just undo one revision', |
468 | 464 | ); |
469 | 465 | } |
| 466 | + |
| 467 | + public function requiresToken() { |
| 468 | + return true; |
| 469 | + } |
470 | 470 | |
471 | 471 | protected function getExamples() { |
472 | 472 | return array ( |
Index: trunk/phase3/includes/api/ApiUnblock.php |
— | — | @@ -57,8 +57,6 @@ |
58 | 58 | $this->dieUsageMsg( array( 'unblock-notarget' ) ); |
59 | 59 | if ( !is_null( $params['id'] ) && !is_null( $params['user'] ) ) |
60 | 60 | $this->dieUsageMsg( array( 'unblock-idanduser' ) ); |
61 | | - if ( is_null( $params['token'] ) ) |
62 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
63 | 61 | if ( !$wgUser->matchEditToken( $params['token'] ) ) |
64 | 62 | $this->dieUsageMsg( array( 'sessionfailure' ) ); |
65 | 63 | if ( !$wgUser->isAllowed( 'block' ) ) |
— | — | @@ -115,11 +113,14 @@ |
116 | 114 | return array_merge( parent::getPossibleErrors(), array( |
117 | 115 | array( 'unblock-notarget' ), |
118 | 116 | array( 'unblock-idanduser' ), |
119 | | - array( 'missingparam', 'token' ), |
120 | 117 | array( 'sessionfailure' ), |
121 | 118 | array( 'cantunblock' ), |
122 | 119 | ) ); |
123 | 120 | } |
| 121 | + |
| 122 | + public function requiresToken() { |
| 123 | + return true; |
| 124 | + } |
124 | 125 | |
125 | 126 | protected function getExamples() { |
126 | 127 | return array ( |
Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -378,11 +378,15 @@ |
379 | 379 | if ( !is_string( $this->mAction ) ) { |
380 | 380 | $this->dieUsage( "The API requires a valid action parameter", 'unknown_action' ); |
381 | 381 | } |
382 | | - |
| 382 | + |
383 | 383 | // Instantiate the module requested by the user |
384 | 384 | $module = new $this->mModules[$this->mAction] ( $this, $this->mAction ); |
385 | 385 | $this->mModule = $module; |
386 | 386 | |
| 387 | + //Die if token required, but not provided (unless there is a gettoken parameter) |
| 388 | + if ( $module->requiresToken() && is_null( $params['token'] ) && !is_null( $params['gettoken'] ) ) |
| 389 | + $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
| 390 | + |
387 | 391 | if ( $module->shouldCheckMaxlag() && isset( $params['maxlag'] ) ) { |
388 | 392 | // Check for maxlag |
389 | 393 | global $wgShowHostnames; |
Index: trunk/phase3/includes/api/ApiEmailUser.php |
— | — | @@ -48,8 +48,6 @@ |
49 | 49 | $this->dieUsageMsg( array( 'missingparam', 'target' ) ); |
50 | 50 | if ( !isset( $params['text'] ) ) |
51 | 51 | $this->dieUsageMsg( array( 'missingparam', 'text' ) ); |
52 | | - if ( !isset( $params['token'] ) ) |
53 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
54 | 52 | |
55 | 53 | // Validate target |
56 | 54 | $targetUser = EmailUserForm::validateEmailTarget( $params['target'] ); |
— | — | @@ -111,9 +109,12 @@ |
112 | 110 | array( 'usermaildisabled' ), |
113 | 111 | array( 'missingparam', 'target' ), |
114 | 112 | array( 'missingparam', 'text' ), |
115 | | - array( 'missingparam', 'token' ), |
116 | 113 | ) ); |
117 | 114 | } |
| 115 | + |
| 116 | + public function requiresToken() { |
| 117 | + return true; |
| 118 | + } |
118 | 119 | |
119 | 120 | protected function getExamples() { |
120 | 121 | return array ( |
Index: trunk/phase3/includes/api/ApiBlock.php |
— | — | @@ -61,8 +61,6 @@ |
62 | 62 | |
63 | 63 | if ( is_null( $params['user'] ) ) |
64 | 64 | $this->dieUsageMsg( array( 'missingparam', 'user' ) ); |
65 | | - if ( is_null( $params['token'] ) ) |
66 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
67 | 65 | if ( !$wgUser->matchEditToken( $params['token'] ) ) |
68 | 66 | $this->dieUsageMsg( array( 'sessionfailure' ) ); |
69 | 67 | if ( !$wgUser->isAllowed( 'block' ) ) |
— | — | @@ -163,13 +161,16 @@ |
164 | 162 | public function getPossibleErrors() { |
165 | 163 | return array_merge( parent::getPossibleErrors(), array( |
166 | 164 | array( 'missingparam', 'user' ), |
167 | | - array( 'missingparam', 'token' ), |
168 | 165 | array( 'sessionfailure' ), |
169 | 166 | array( 'cantblock' ), |
170 | 167 | array( 'canthide' ), |
171 | 168 | array( 'cantblock-email' ), |
172 | 169 | ) ); |
173 | 170 | } |
| 171 | + |
| 172 | + public function requiresToken() { |
| 173 | + return true; |
| 174 | + } |
174 | 175 | |
175 | 176 | protected function getExamples() { |
176 | 177 | return array ( |
Index: trunk/phase3/includes/api/ApiPatrol.php |
— | — | @@ -44,8 +44,6 @@ |
45 | 45 | global $wgUser; |
46 | 46 | $params = $this->extractRequestParams(); |
47 | 47 | |
48 | | - if ( !isset( $params['token'] ) ) |
49 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
50 | 48 | if ( !isset( $params['rcid'] ) ) |
51 | 49 | $this->dieUsageMsg( array( 'missingparam', 'rcid' ) ); |
52 | 50 | if ( !$wgUser->matchEditToken( $params['token'] ) ) |
— | — | @@ -92,12 +90,15 @@ |
93 | 91 | |
94 | 92 | public function getPossibleErrors() { |
95 | 93 | return array_merge( parent::getPossibleErrors(), array( |
96 | | - array( 'missingparam', 'token' ), |
97 | 94 | array( 'missingparam', 'rcid' ), |
98 | 95 | array( 'sessionfailure' ), |
99 | 96 | array( 'nosuchrcid', 'rcid' ), |
100 | 97 | ) ); |
101 | 98 | } |
| 99 | + |
| 100 | + public function requiresToken() { |
| 101 | + return true; |
| 102 | + } |
102 | 103 | |
103 | 104 | protected function getExamples() { |
104 | 105 | return array( |
Index: trunk/phase3/includes/api/ApiUndelete.php |
— | — | @@ -43,8 +43,6 @@ |
44 | 44 | $titleObj = null; |
45 | 45 | if ( !isset( $params['title'] ) ) |
46 | 46 | $this->dieUsageMsg( array( 'missingparam', 'title' ) ); |
47 | | - if ( !isset( $params['token'] ) ) |
48 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
49 | 47 | |
50 | 48 | if ( !$wgUser->isAllowed( 'undelete' ) ) |
51 | 49 | $this->dieUsageMsg( array( 'permdenied-undelete' ) ); |
— | — | @@ -123,7 +121,6 @@ |
124 | 122 | public function getPossibleErrors() { |
125 | 123 | return array_merge( parent::getPossibleErrors(), array( |
126 | 124 | array( 'missingparam', 'title' ), |
127 | | - array( 'missingparam', 'token' ), |
128 | 125 | array( 'permdenied-undelete' ), |
129 | 126 | array( 'blockedtext' ), |
130 | 127 | array( 'sessionfailure' ), |
— | — | @@ -131,6 +128,10 @@ |
132 | 129 | array( 'cannotundelete' ), |
133 | 130 | ) ); |
134 | 131 | } |
| 132 | + |
| 133 | + public function requiresToken() { |
| 134 | + return true; |
| 135 | + } |
135 | 136 | |
136 | 137 | protected function getExamples() { |
137 | 138 | return array ( |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -965,6 +965,14 @@ |
966 | 966 | public function mustBePosted() { |
967 | 967 | return false; |
968 | 968 | } |
| 969 | + |
| 970 | + /** |
| 971 | + * Indicates whether this module needs a token to preform the request |
| 972 | + * @returns bool |
| 973 | + */ |
| 974 | + public function requiresToken() { |
| 975 | + return false; |
| 976 | + } |
969 | 977 | |
970 | 978 | /** |
971 | 979 | * Returns a list of all possible errors returned by the module |
— | — | @@ -985,6 +993,10 @@ |
986 | 994 | $ret[] = array ( 'writerequired' ); |
987 | 995 | $ret[] = array ( 'writedisabled' ); |
988 | 996 | } |
| 997 | + |
| 998 | + if ( $this->requiresToken() ) { |
| 999 | + $ret[] = array( 'missingparam', 'token' ); |
| 1000 | + } |
989 | 1001 | |
990 | 1002 | return $ret; |
991 | 1003 | } |
Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -48,8 +48,6 @@ |
49 | 49 | $request = $this->getMain()->getRequest(); |
50 | 50 | |
51 | 51 | // Do token checks: |
52 | | - if ( is_null( $this->mParams['token'] ) ) |
53 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
54 | 52 | if ( !$wgUser->matchEditToken( $this->mParams['token'] ) ) |
55 | 53 | $this->dieUsageMsg( array( 'sessionfailure' ) ); |
56 | 54 | |
— | — | @@ -330,7 +328,6 @@ |
331 | 329 | public function getPossibleErrors() { |
332 | 330 | return array_merge( parent::getPossibleErrors(), array( |
333 | 331 | array( 'uploaddisabled' ), |
334 | | - array( 'missingparam', 'token' ), |
335 | 332 | array( 'sessionfailure' ), |
336 | 333 | array( 'invalid-session-key' ), |
337 | 334 | array( 'uploaddisabled' ), |
— | — | @@ -349,6 +346,10 @@ |
350 | 347 | array( 'code' => 'internal-error', 'info' => 'An internal error occurred' ), |
351 | 348 | ) ); |
352 | 349 | } |
| 350 | + |
| 351 | + public function requiresToken() { |
| 352 | + return true; |
| 353 | + } |
353 | 354 | |
354 | 355 | protected function getExamples() { |
355 | 356 | return array( |