Merge "Drop index oi_name_archive_name on table oldimage"
[lhc/web/wiklou.git] / includes / api / ApiQueryRecentChanges.php
1 <?php
2 /**
3 *
4 *
5 * Created on Oct 19, 2006
6 *
7 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 */
26
27 /**
28 * A query action to enumerate the recent changes that were done to the wiki.
29 * Various filters are supported.
30 *
31 * @ingroup API
32 */
33 class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
34
35 public function __construct( ApiQuery $query, $moduleName ) {
36 parent::__construct( $query, $moduleName, 'rc' );
37 }
38
39 private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
40 $fld_flags = false, $fld_timestamp = false, $fld_title = false, $fld_ids = false,
41 $fld_sizes = false, $fld_redirect = false, $fld_patrolled = false, $fld_loginfo = false,
42 $fld_tags = false, $fld_sha1 = false, $token = [];
43
44 private $tokenFunctions;
45
46 /**
47 * Get an array mapping token names to their handler functions.
48 * The prototype for a token function is func($pageid, $title, $rc)
49 * it should return a token or false (permission denied)
50 * @deprecated since 1.24
51 * @return array [ tokenname => function ]
52 */
53 protected function getTokenFunctions() {
54 // Don't call the hooks twice
55 if ( isset( $this->tokenFunctions ) ) {
56 return $this->tokenFunctions;
57 }
58
59 // If we're in a mode that breaks the same-origin policy, no tokens can
60 // be obtained
61 if ( $this->lacksSameOriginSecurity() ) {
62 return [];
63 }
64
65 $this->tokenFunctions = [
66 'patrol' => [ 'ApiQueryRecentChanges', 'getPatrolToken' ]
67 ];
68 Hooks::run( 'APIQueryRecentChangesTokens', [ &$this->tokenFunctions ] );
69
70 return $this->tokenFunctions;
71 }
72
73 /**
74 * @deprecated since 1.24
75 * @param int $pageid
76 * @param Title $title
77 * @param RecentChange|null $rc
78 * @return bool|string
79 */
80 public static function getPatrolToken( $pageid, $title, $rc = null ) {
81 global $wgUser;
82
83 $validTokenUser = false;
84
85 if ( $rc ) {
86 if ( ( $wgUser->useRCPatrol() && $rc->getAttribute( 'rc_type' ) == RC_EDIT ) ||
87 ( $wgUser->useNPPatrol() && $rc->getAttribute( 'rc_type' ) == RC_NEW )
88 ) {
89 $validTokenUser = true;
90 }
91 } elseif ( $wgUser->useRCPatrol() || $wgUser->useNPPatrol() ) {
92 $validTokenUser = true;
93 }
94
95 if ( $validTokenUser ) {
96 // The patrol token is always the same, let's exploit that
97 static $cachedPatrolToken = null;
98
99 if ( is_null( $cachedPatrolToken ) ) {
100 $cachedPatrolToken = $wgUser->getEditToken( 'patrol' );
101 }
102
103 return $cachedPatrolToken;
104 }
105
106 return false;
107 }
108
109 /**
110 * Sets internal state to include the desired properties in the output.
111 * @param array $prop Associative array of properties, only keys are used here
112 */
113 public function initProperties( $prop ) {
114 $this->fld_comment = isset( $prop['comment'] );
115 $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
116 $this->fld_user = isset( $prop['user'] );
117 $this->fld_userid = isset( $prop['userid'] );
118 $this->fld_flags = isset( $prop['flags'] );
119 $this->fld_timestamp = isset( $prop['timestamp'] );
120 $this->fld_title = isset( $prop['title'] );
121 $this->fld_ids = isset( $prop['ids'] );
122 $this->fld_sizes = isset( $prop['sizes'] );
123 $this->fld_redirect = isset( $prop['redirect'] );
124 $this->fld_patrolled = isset( $prop['patrolled'] );
125 $this->fld_loginfo = isset( $prop['loginfo'] );
126 $this->fld_tags = isset( $prop['tags'] );
127 $this->fld_sha1 = isset( $prop['sha1'] );
128 }
129
130 public function execute() {
131 $this->run();
132 }
133
134 public function executeGenerator( $resultPageSet ) {
135 $this->run( $resultPageSet );
136 }
137
138 /**
139 * Generates and outputs the result of this query based upon the provided parameters.
140 *
141 * @param ApiPageSet $resultPageSet
142 */
143 public function run( $resultPageSet = null ) {
144 $user = $this->getUser();
145 /* Get the parameters of the request. */
146 $params = $this->extractRequestParams();
147
148 /* Build our basic query. Namely, something along the lines of:
149 * SELECT * FROM recentchanges WHERE rc_timestamp > $start
150 * AND rc_timestamp < $end AND rc_namespace = $namespace
151 */
152 $this->addTables( 'recentchanges' );
153 $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
154
155 if ( !is_null( $params['continue'] ) ) {
156 $cont = explode( '|', $params['continue'] );
157 $this->dieContinueUsageIf( count( $cont ) != 2 );
158 $db = $this->getDB();
159 $timestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
160 $id = intval( $cont[1] );
161 $this->dieContinueUsageIf( $id != $cont[1] );
162 $op = $params['dir'] === 'older' ? '<' : '>';
163 $this->addWhere(
164 "rc_timestamp $op $timestamp OR " .
165 "(rc_timestamp = $timestamp AND " .
166 "rc_id $op= $id)"
167 );
168 }
169
170 $order = $params['dir'] === 'older' ? 'DESC' : 'ASC';
171 $this->addOption( 'ORDER BY', [
172 "rc_timestamp $order",
173 "rc_id $order",
174 ] );
175
176 $this->addWhereFld( 'rc_namespace', $params['namespace'] );
177
178 if ( !is_null( $params['type'] ) ) {
179 try {
180 $this->addWhereFld( 'rc_type', RecentChange::parseToRCType( $params['type'] ) );
181 } catch ( Exception $e ) {
182 ApiBase::dieDebug( __METHOD__, $e->getMessage() );
183 }
184 }
185
186 if ( !is_null( $params['show'] ) ) {
187 $show = array_flip( $params['show'] );
188
189 /* Check for conflicting parameters. */
190 if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
191 || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
192 || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
193 || ( isset( $show['redirect'] ) && isset( $show['!redirect'] ) )
194 || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
195 || ( isset( $show['patrolled'] ) && isset( $show['unpatrolled'] ) )
196 || ( isset( $show['!patrolled'] ) && isset( $show['unpatrolled'] ) )
197 ) {
198 $this->dieWithError( 'apierror-show' );
199 }
200
201 // Check permissions
202 if ( isset( $show['patrolled'] )
203 || isset( $show['!patrolled'] )
204 || isset( $show['unpatrolled'] )
205 ) {
206 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
207 $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' );
208 }
209 }
210
211 /* Add additional conditions to query depending upon parameters. */
212 $this->addWhereIf( 'rc_minor = 0', isset( $show['!minor'] ) );
213 $this->addWhereIf( 'rc_minor != 0', isset( $show['minor'] ) );
214 $this->addWhereIf( 'rc_bot = 0', isset( $show['!bot'] ) );
215 $this->addWhereIf( 'rc_bot != 0', isset( $show['bot'] ) );
216 $this->addWhereIf( 'rc_user = 0', isset( $show['anon'] ) );
217 $this->addWhereIf( 'rc_user != 0', isset( $show['!anon'] ) );
218 $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
219 $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
220 $this->addWhereIf( 'page_is_redirect = 1', isset( $show['redirect'] ) );
221
222 if ( isset( $show['unpatrolled'] ) ) {
223 // See ChangesList::isUnpatrolled
224 if ( $user->useRCPatrol() ) {
225 $this->addWhere( 'rc_patrolled = 0' );
226 } elseif ( $user->useNPPatrol() ) {
227 $this->addWhere( 'rc_patrolled = 0' );
228 $this->addWhereFld( 'rc_type', RC_NEW );
229 }
230 }
231
232 // Don't throw log entries out the window here
233 $this->addWhereIf(
234 'page_is_redirect = 0 OR page_is_redirect IS NULL',
235 isset( $show['!redirect'] )
236 );
237 }
238
239 $this->requireMaxOneParameter( $params, 'user', 'excludeuser' );
240
241 if ( !is_null( $params['user'] ) ) {
242 $this->addWhereFld( 'rc_user_text', $params['user'] );
243 }
244
245 if ( !is_null( $params['excludeuser'] ) ) {
246 // We don't use the rc_user_text index here because
247 // * it would require us to sort by rc_user_text before rc_timestamp
248 // * the != condition doesn't throw out too many rows anyway
249 $this->addWhere( 'rc_user_text != ' . $this->getDB()->addQuotes( $params['excludeuser'] ) );
250 }
251
252 /* Add the fields we're concerned with to our query. */
253 $this->addFields( [
254 'rc_id',
255 'rc_timestamp',
256 'rc_namespace',
257 'rc_title',
258 'rc_cur_id',
259 'rc_type',
260 'rc_deleted'
261 ] );
262
263 $showRedirects = false;
264 /* Determine what properties we need to display. */
265 if ( !is_null( $params['prop'] ) ) {
266 $prop = array_flip( $params['prop'] );
267
268 /* Set up internal members based upon params. */
269 $this->initProperties( $prop );
270
271 if ( $this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
272 $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' );
273 }
274
275 /* Add fields to our query if they are specified as a needed parameter. */
276 $this->addFieldsIf( [ 'rc_this_oldid', 'rc_last_oldid' ], $this->fld_ids );
277 $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
278 $this->addFieldsIf( 'rc_user', $this->fld_user || $this->fld_userid );
279 $this->addFieldsIf( 'rc_user_text', $this->fld_user );
280 $this->addFieldsIf( [ 'rc_minor', 'rc_type', 'rc_bot' ], $this->fld_flags );
281 $this->addFieldsIf( [ 'rc_old_len', 'rc_new_len' ], $this->fld_sizes );
282 $this->addFieldsIf( [ 'rc_patrolled', 'rc_log_type' ], $this->fld_patrolled );
283 $this->addFieldsIf(
284 [ 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ],
285 $this->fld_loginfo
286 );
287 $showRedirects = $this->fld_redirect || isset( $show['redirect'] )
288 || isset( $show['!redirect'] );
289 }
290 $this->addFieldsIf( [ 'rc_this_oldid' ],
291 $resultPageSet && $params['generaterevisions'] );
292
293 if ( $this->fld_tags ) {
294 $this->addTables( 'tag_summary' );
295 $this->addJoinConds( [ 'tag_summary' => [ 'LEFT JOIN', [ 'rc_id=ts_rc_id' ] ] ] );
296 $this->addFields( 'ts_tags' );
297 }
298
299 if ( $this->fld_sha1 ) {
300 $this->addTables( 'revision' );
301 $this->addJoinConds( [ 'revision' => [ 'LEFT JOIN',
302 [ 'rc_this_oldid=rev_id' ] ] ] );
303 $this->addFields( [ 'rev_sha1', 'rev_deleted' ] );
304 }
305
306 if ( $params['toponly'] || $showRedirects ) {
307 $this->addTables( 'page' );
308 $this->addJoinConds( [ 'page' => [ 'LEFT JOIN',
309 [ 'rc_namespace=page_namespace', 'rc_title=page_title' ] ] ] );
310 $this->addFields( 'page_is_redirect' );
311
312 if ( $params['toponly'] ) {
313 $this->addWhere( 'rc_this_oldid = page_latest' );
314 }
315 }
316
317 if ( !is_null( $params['tag'] ) ) {
318 $this->addTables( 'change_tag' );
319 $this->addJoinConds( [ 'change_tag' => [ 'INNER JOIN', [ 'rc_id=ct_rc_id' ] ] ] );
320 $this->addWhereFld( 'ct_tag', $params['tag'] );
321 }
322
323 // Paranoia: avoid brute force searches (T19342)
324 if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
325 if ( !$user->isAllowed( 'deletedhistory' ) ) {
326 $bitmask = Revision::DELETED_USER;
327 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
328 $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
329 } else {
330 $bitmask = 0;
331 }
332 if ( $bitmask ) {
333 $this->addWhere( $this->getDB()->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask" );
334 }
335 }
336 if ( $this->getRequest()->getCheck( 'namespace' ) ) {
337 // LogPage::DELETED_ACTION hides the affected page, too.
338 if ( !$user->isAllowed( 'deletedhistory' ) ) {
339 $bitmask = LogPage::DELETED_ACTION;
340 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
341 $bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
342 } else {
343 $bitmask = 0;
344 }
345 if ( $bitmask ) {
346 $this->addWhere( $this->getDB()->makeList( [
347 'rc_type != ' . RC_LOG,
348 $this->getDB()->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
349 ], LIST_OR ) );
350 }
351 }
352
353 $this->token = $params['token'];
354 $this->addOption( 'LIMIT', $params['limit'] + 1 );
355
356 $hookData = [];
357 $count = 0;
358 /* Perform the actual query. */
359 $res = $this->select( __METHOD__, [], $hookData );
360
361 $revids = [];
362 $titles = [];
363
364 $result = $this->getResult();
365
366 /* Iterate through the rows, adding data extracted from them to our query result. */
367 foreach ( $res as $row ) {
368 if ( $count === 0 && $resultPageSet !== null ) {
369 // Set the non-continue since the list of recentchanges is
370 // prone to having entries added at the start frequently.
371 $this->getContinuationManager()->addGeneratorNonContinueParam(
372 $this, 'continue', "$row->rc_timestamp|$row->rc_id"
373 );
374 }
375 if ( ++$count > $params['limit'] ) {
376 // We've reached the one extra which shows that there are
377 // additional pages to be had. Stop here...
378 $this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" );
379 break;
380 }
381
382 if ( is_null( $resultPageSet ) ) {
383 /* Extract the data from a single row. */
384 $vals = $this->extractRowInfo( $row );
385
386 /* Add that row's data to our final output. */
387 $fit = $this->processRow( $row, $vals, $hookData ) &&
388 $result->addValue( [ 'query', $this->getModuleName() ], null, $vals );
389 if ( !$fit ) {
390 $this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" );
391 break;
392 }
393 } elseif ( $params['generaterevisions'] ) {
394 $revid = (int)$row->rc_this_oldid;
395 if ( $revid > 0 ) {
396 $revids[] = $revid;
397 }
398 } else {
399 $titles[] = Title::makeTitle( $row->rc_namespace, $row->rc_title );
400 }
401 }
402
403 if ( is_null( $resultPageSet ) ) {
404 /* Format the result */
405 $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'rc' );
406 } elseif ( $params['generaterevisions'] ) {
407 $resultPageSet->populateFromRevisionIDs( $revids );
408 } else {
409 $resultPageSet->populateFromTitles( $titles );
410 }
411 }
412
413 /**
414 * Extracts from a single sql row the data needed to describe one recent change.
415 *
416 * @param stdClass $row The row from which to extract the data.
417 * @return array An array mapping strings (descriptors) to their respective string values.
418 * @access public
419 */
420 public function extractRowInfo( $row ) {
421 /* Determine the title of the page that has been changed. */
422 $title = Title::makeTitle( $row->rc_namespace, $row->rc_title );
423 $user = $this->getUser();
424
425 /* Our output data. */
426 $vals = [];
427
428 $type = intval( $row->rc_type );
429 $vals['type'] = RecentChange::parseFromRCType( $type );
430
431 $anyHidden = false;
432
433 /* Create a new entry in the result for the title. */
434 if ( $this->fld_title || $this->fld_ids ) {
435 if ( $type === RC_LOG && ( $row->rc_deleted & LogPage::DELETED_ACTION ) ) {
436 $vals['actionhidden'] = true;
437 $anyHidden = true;
438 }
439 if ( $type !== RC_LOG ||
440 LogEventsList::userCanBitfield( $row->rc_deleted, LogPage::DELETED_ACTION, $user )
441 ) {
442 if ( $this->fld_title ) {
443 ApiQueryBase::addTitleInfo( $vals, $title );
444 }
445 if ( $this->fld_ids ) {
446 $vals['pageid'] = intval( $row->rc_cur_id );
447 $vals['revid'] = intval( $row->rc_this_oldid );
448 $vals['old_revid'] = intval( $row->rc_last_oldid );
449 }
450 }
451 }
452
453 if ( $this->fld_ids ) {
454 $vals['rcid'] = intval( $row->rc_id );
455 }
456
457 /* Add user data and 'anon' flag, if user is anonymous. */
458 if ( $this->fld_user || $this->fld_userid ) {
459 if ( $row->rc_deleted & Revision::DELETED_USER ) {
460 $vals['userhidden'] = true;
461 $anyHidden = true;
462 }
463 if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_USER, $user ) ) {
464 if ( $this->fld_user ) {
465 $vals['user'] = $row->rc_user_text;
466 }
467
468 if ( $this->fld_userid ) {
469 $vals['userid'] = (int)$row->rc_user;
470 }
471
472 if ( !$row->rc_user ) {
473 $vals['anon'] = true;
474 }
475 }
476 }
477
478 /* Add flags, such as new, minor, bot. */
479 if ( $this->fld_flags ) {
480 $vals['bot'] = (bool)$row->rc_bot;
481 $vals['new'] = $row->rc_type == RC_NEW;
482 $vals['minor'] = (bool)$row->rc_minor;
483 }
484
485 /* Add sizes of each revision. (Only available on 1.10+) */
486 if ( $this->fld_sizes ) {
487 $vals['oldlen'] = intval( $row->rc_old_len );
488 $vals['newlen'] = intval( $row->rc_new_len );
489 }
490
491 /* Add the timestamp. */
492 if ( $this->fld_timestamp ) {
493 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rc_timestamp );
494 }
495
496 /* Add edit summary / log summary. */
497 if ( $this->fld_comment || $this->fld_parsedcomment ) {
498 if ( $row->rc_deleted & Revision::DELETED_COMMENT ) {
499 $vals['commenthidden'] = true;
500 $anyHidden = true;
501 }
502 if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_COMMENT, $user ) ) {
503 if ( $this->fld_comment && isset( $row->rc_comment ) ) {
504 $vals['comment'] = $row->rc_comment;
505 }
506
507 if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
508 $vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title );
509 }
510 }
511 }
512
513 if ( $this->fld_redirect ) {
514 $vals['redirect'] = (bool)$row->page_is_redirect;
515 }
516
517 /* Add the patrolled flag */
518 if ( $this->fld_patrolled ) {
519 $vals['patrolled'] = $row->rc_patrolled == 1;
520 $vals['unpatrolled'] = ChangesList::isUnpatrolled( $row, $user );
521 }
522
523 if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
524 if ( $row->rc_deleted & LogPage::DELETED_ACTION ) {
525 $vals['actionhidden'] = true;
526 $anyHidden = true;
527 }
528 if ( LogEventsList::userCanBitfield( $row->rc_deleted, LogPage::DELETED_ACTION, $user ) ) {
529 $vals['logid'] = intval( $row->rc_logid );
530 $vals['logtype'] = $row->rc_log_type;
531 $vals['logaction'] = $row->rc_log_action;
532 $vals['logparams'] = LogFormatter::newFromRow( $row )->formatParametersForApi();
533 }
534 }
535
536 if ( $this->fld_tags ) {
537 if ( $row->ts_tags ) {
538 $tags = explode( ',', $row->ts_tags );
539 ApiResult::setIndexedTagName( $tags, 'tag' );
540 $vals['tags'] = $tags;
541 } else {
542 $vals['tags'] = [];
543 }
544 }
545
546 if ( $this->fld_sha1 && $row->rev_sha1 !== null ) {
547 if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
548 $vals['sha1hidden'] = true;
549 $anyHidden = true;
550 }
551 if ( Revision::userCanBitfield( $row->rev_deleted, Revision::DELETED_TEXT, $user ) ) {
552 if ( $row->rev_sha1 !== '' ) {
553 $vals['sha1'] = Wikimedia\base_convert( $row->rev_sha1, 36, 16, 40 );
554 } else {
555 $vals['sha1'] = '';
556 }
557 }
558 }
559
560 if ( !is_null( $this->token ) ) {
561 $tokenFunctions = $this->getTokenFunctions();
562 foreach ( $this->token as $t ) {
563 $val = call_user_func( $tokenFunctions[$t], $row->rc_cur_id,
564 $title, RecentChange::newFromRow( $row ) );
565 if ( $val === false ) {
566 $this->addWarning( [ 'apiwarn-tokennotallowed', $t ] );
567 } else {
568 $vals[$t . 'token'] = $val;
569 }
570 }
571 }
572
573 if ( $anyHidden && ( $row->rc_deleted & Revision::DELETED_RESTRICTED ) ) {
574 $vals['suppressed'] = true;
575 }
576
577 return $vals;
578 }
579
580 public function getCacheMode( $params ) {
581 if ( isset( $params['show'] ) ) {
582 foreach ( $params['show'] as $show ) {
583 if ( $show === 'patrolled' || $show === '!patrolled' ) {
584 return 'private';
585 }
586 }
587 }
588 if ( isset( $params['token'] ) ) {
589 return 'private';
590 }
591 if ( $this->userCanSeeRevDel() ) {
592 return 'private';
593 }
594 if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
595 // formatComment() calls wfMessage() among other things
596 return 'anon-public-user-private';
597 }
598
599 return 'public';
600 }
601
602 public function getAllowedParams() {
603 return [
604 'start' => [
605 ApiBase::PARAM_TYPE => 'timestamp'
606 ],
607 'end' => [
608 ApiBase::PARAM_TYPE => 'timestamp'
609 ],
610 'dir' => [
611 ApiBase::PARAM_DFLT => 'older',
612 ApiBase::PARAM_TYPE => [
613 'newer',
614 'older'
615 ],
616 ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
617 ],
618 'namespace' => [
619 ApiBase::PARAM_ISMULTI => true,
620 ApiBase::PARAM_TYPE => 'namespace',
621 ApiBase::PARAM_EXTRA_NAMESPACES => [ NS_MEDIA, NS_SPECIAL ],
622 ],
623 'user' => [
624 ApiBase::PARAM_TYPE => 'user'
625 ],
626 'excludeuser' => [
627 ApiBase::PARAM_TYPE => 'user'
628 ],
629 'tag' => null,
630 'prop' => [
631 ApiBase::PARAM_ISMULTI => true,
632 ApiBase::PARAM_DFLT => 'title|timestamp|ids',
633 ApiBase::PARAM_TYPE => [
634 'user',
635 'userid',
636 'comment',
637 'parsedcomment',
638 'flags',
639 'timestamp',
640 'title',
641 'ids',
642 'sizes',
643 'redirect',
644 'patrolled',
645 'loginfo',
646 'tags',
647 'sha1',
648 ],
649 ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
650 ],
651 'token' => [
652 ApiBase::PARAM_DEPRECATED => true,
653 ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
654 ApiBase::PARAM_ISMULTI => true
655 ],
656 'show' => [
657 ApiBase::PARAM_ISMULTI => true,
658 ApiBase::PARAM_TYPE => [
659 'minor',
660 '!minor',
661 'bot',
662 '!bot',
663 'anon',
664 '!anon',
665 'redirect',
666 '!redirect',
667 'patrolled',
668 '!patrolled',
669 'unpatrolled'
670 ]
671 ],
672 'limit' => [
673 ApiBase::PARAM_DFLT => 10,
674 ApiBase::PARAM_TYPE => 'limit',
675 ApiBase::PARAM_MIN => 1,
676 ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
677 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
678 ],
679 'type' => [
680 ApiBase::PARAM_DFLT => 'edit|new|log|categorize',
681 ApiBase::PARAM_ISMULTI => true,
682 ApiBase::PARAM_TYPE => RecentChange::getChangeTypes()
683 ],
684 'toponly' => false,
685 'continue' => [
686 ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
687 ],
688 'generaterevisions' => false,
689 ];
690 }
691
692 protected function getExamplesMessages() {
693 return [
694 'action=query&list=recentchanges'
695 => 'apihelp-query+recentchanges-example-simple',
696 'action=query&generator=recentchanges&grcshow=!patrolled&prop=info'
697 => 'apihelp-query+recentchanges-example-generator',
698 ];
699 }
700
701 public function getHelpUrls() {
702 return 'https://www.mediawiki.org/wiki/API:Recentchanges';
703 }
704 }