Follow-up I0b781c11 (2a55449): use User::getAutomaticGroups().
[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( $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, $token = array();
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 * @return array array(tokenname => function)
51 */
52 protected function getTokenFunctions() {
53 // Don't call the hooks twice
54 if ( isset( $this->tokenFunctions ) ) {
55 return $this->tokenFunctions;
56 }
57
58 // If we're in JSON callback mode, no tokens can be obtained
59 if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
60 return array();
61 }
62
63 $this->tokenFunctions = array(
64 'patrol' => array( 'ApiQueryRecentChanges', 'getPatrolToken' )
65 );
66 wfRunHooks( 'APIQueryRecentChangesTokens', array( &$this->tokenFunctions ) );
67 return $this->tokenFunctions;
68 }
69
70 /**
71 * @param $pageid
72 * @param $title
73 * @param $rc RecentChange (optional)
74 * @return bool|String
75 */
76 public static function getPatrolToken( $pageid, $title, $rc = null ) {
77 global $wgUser;
78
79 $validTokenUser = false;
80
81 if ( $rc ) {
82 if ( ( $wgUser->useRCPatrol() && $rc->getAttribute( 'rc_type' ) == RC_EDIT ) ||
83 ( $wgUser->useNPPatrol() && $rc->getAttribute( 'rc_type' ) == RC_NEW ) )
84 {
85 $validTokenUser = true;
86 }
87 } else {
88 if ( $wgUser->useRCPatrol() || $wgUser->useNPPatrol() ) {
89 $validTokenUser = true;
90 }
91 }
92
93 if ( $validTokenUser ) {
94 // The patrol token is always the same, let's exploit that
95 static $cachedPatrolToken = null;
96 if ( is_null( $cachedPatrolToken ) ) {
97 $cachedPatrolToken = $wgUser->getEditToken( 'patrol' );
98 }
99 return $cachedPatrolToken;
100 } else {
101 return false;
102 }
103
104 }
105
106 /**
107 * Sets internal state to include the desired properties in the output.
108 * @param $prop Array associative array of properties, only keys are used here
109 */
110 public function initProperties( $prop ) {
111 $this->fld_comment = isset( $prop['comment'] );
112 $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
113 $this->fld_user = isset( $prop['user'] );
114 $this->fld_userid = isset( $prop['userid'] );
115 $this->fld_flags = isset( $prop['flags'] );
116 $this->fld_timestamp = isset( $prop['timestamp'] );
117 $this->fld_title = isset( $prop['title'] );
118 $this->fld_ids = isset( $prop['ids'] );
119 $this->fld_sizes = isset( $prop['sizes'] );
120 $this->fld_redirect = isset( $prop['redirect'] );
121 $this->fld_patrolled = isset( $prop['patrolled'] );
122 $this->fld_loginfo = isset( $prop['loginfo'] );
123 $this->fld_tags = isset( $prop['tags'] );
124 }
125
126 public function execute() {
127 $this->run();
128 }
129
130 public function executeGenerator( $resultPageSet ) {
131 $this->run( $resultPageSet );
132 }
133
134 /**
135 * Generates and outputs the result of this query based upon the provided parameters.
136 *
137 * @param $resultPageSet ApiPageSet
138 */
139 public function run( $resultPageSet = null ) {
140 $user = $this->getUser();
141 /* Get the parameters of the request. */
142 $params = $this->extractRequestParams();
143
144 /* Build our basic query. Namely, something along the lines of:
145 * SELECT * FROM recentchanges WHERE rc_timestamp > $start
146 * AND rc_timestamp < $end AND rc_namespace = $namespace
147 * AND rc_deleted = 0
148 */
149 $this->addTables( 'recentchanges' );
150 $index = array( 'recentchanges' => 'rc_timestamp' ); // May change
151 $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
152 $this->addWhereFld( 'rc_namespace', $params['namespace'] );
153 $this->addWhereFld( 'rc_deleted', 0 );
154
155 if ( !is_null( $params['type'] ) ) {
156 $this->addWhereFld( 'rc_type', $this->parseRCType( $params['type'] ) );
157 }
158
159 if ( !is_null( $params['show'] ) ) {
160 $show = array_flip( $params['show'] );
161
162 /* Check for conflicting parameters. */
163 if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
164 || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
165 || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
166 || ( isset( $show['redirect'] ) && isset( $show['!redirect'] ) )
167 || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
168 ) {
169 $this->dieUsageMsg( 'show' );
170 }
171
172 // Check permissions
173 if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) {
174 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
175 $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
176 }
177 }
178
179 /* Add additional conditions to query depending upon parameters. */
180 $this->addWhereIf( 'rc_minor = 0', isset( $show['!minor'] ) );
181 $this->addWhereIf( 'rc_minor != 0', isset( $show['minor'] ) );
182 $this->addWhereIf( 'rc_bot = 0', isset( $show['!bot'] ) );
183 $this->addWhereIf( 'rc_bot != 0', isset( $show['bot'] ) );
184 $this->addWhereIf( 'rc_user = 0', isset( $show['anon'] ) );
185 $this->addWhereIf( 'rc_user != 0', isset( $show['!anon'] ) );
186 $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
187 $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
188 $this->addWhereIf( 'page_is_redirect = 1', isset( $show['redirect'] ) );
189
190 // Don't throw log entries out the window here
191 $this->addWhereIf( 'page_is_redirect = 0 OR page_is_redirect IS NULL', isset( $show['!redirect'] ) );
192 }
193
194 if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) {
195 $this->dieUsage( 'user and excludeuser cannot be used together', 'user-excludeuser' );
196 }
197
198 if ( !is_null( $params['user'] ) ) {
199 $this->addWhereFld( 'rc_user_text', $params['user'] );
200 $index['recentchanges'] = 'rc_user_text';
201 }
202
203 if ( !is_null( $params['excludeuser'] ) ) {
204 // We don't use the rc_user_text index here because
205 // * it would require us to sort by rc_user_text before rc_timestamp
206 // * the != condition doesn't throw out too many rows anyway
207 $this->addWhere( 'rc_user_text != ' . $this->getDB()->addQuotes( $params['excludeuser'] ) );
208 }
209
210 /* Add the fields we're concerned with to our query. */
211 $this->addFields( array(
212 'rc_timestamp',
213 'rc_namespace',
214 'rc_title',
215 'rc_cur_id',
216 'rc_type',
217 'rc_moved_to_ns',
218 'rc_moved_to_title',
219 'rc_deleted'
220 ) );
221
222 $showRedirects = false;
223 /* Determine what properties we need to display. */
224 if ( !is_null( $params['prop'] ) ) {
225 $prop = array_flip( $params['prop'] );
226
227 /* Set up internal members based upon params. */
228 $this->initProperties( $prop );
229
230 if ( $this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
231 $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
232 }
233
234 /* Add fields to our query if they are specified as a needed parameter. */
235 $this->addFieldsIf( array( 'rc_id', 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids );
236 $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
237 $this->addFieldsIf( 'rc_user', $this->fld_user );
238 $this->addFieldsIf( 'rc_user_text', $this->fld_user || $this->fld_userid );
239 $this->addFieldsIf( array( 'rc_minor', 'rc_new', 'rc_bot' ) , $this->fld_flags );
240 $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes );
241 $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled );
242 $this->addFieldsIf( array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ), $this->fld_loginfo );
243 $showRedirects = $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] );
244 }
245
246 if ( $this->fld_tags ) {
247 $this->addTables( 'tag_summary' );
248 $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rc_id=ts_rc_id' ) ) ) );
249 $this->addFields( 'ts_tags' );
250 }
251
252 if ( $params['toponly'] || $showRedirects ) {
253 $this->addTables( 'page' );
254 $this->addJoinConds( array( 'page' => array( 'LEFT JOIN', array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) );
255 $this->addFields( 'page_is_redirect' );
256
257 if ( $params['toponly'] ) {
258 $this->addWhere( 'rc_this_oldid = page_latest' );
259 }
260 }
261
262 if ( !is_null( $params['tag'] ) ) {
263 $this->addTables( 'change_tag' );
264 $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rc_id=ct_rc_id' ) ) ) );
265 $this->addWhereFld( 'ct_tag' , $params['tag'] );
266 global $wgOldChangeTagsIndex;
267 $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
268 }
269
270 $this->token = $params['token'];
271 $this->addOption( 'LIMIT', $params['limit'] + 1 );
272 $this->addOption( 'USE INDEX', $index );
273
274 $count = 0;
275 /* Perform the actual query. */
276 $res = $this->select( __METHOD__ );
277
278 $titles = array();
279
280 $result = $this->getResult();
281
282 /* Iterate through the rows, adding data extracted from them to our query result. */
283 foreach ( $res as $row ) {
284 if ( ++ $count > $params['limit'] ) {
285 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
286 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
287 break;
288 }
289
290 if ( is_null( $resultPageSet ) ) {
291 /* Extract the data from a single row. */
292 $vals = $this->extractRowInfo( $row );
293
294 /* Add that row's data to our final output. */
295 if ( !$vals ) {
296 continue;
297 }
298 $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
299 if ( !$fit ) {
300 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
301 break;
302 }
303 } else {
304 $titles[] = Title::makeTitle( $row->rc_namespace, $row->rc_title );
305 }
306 }
307
308 if ( is_null( $resultPageSet ) ) {
309 /* Format the result */
310 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' );
311 } else {
312 $resultPageSet->populateFromTitles( $titles );
313 }
314 }
315
316 /**
317 * Extracts from a single sql row the data needed to describe one recent change.
318 *
319 * @param $row The row from which to extract the data.
320 * @return array An array mapping strings (descriptors) to their respective string values.
321 * @access public
322 */
323 public function extractRowInfo( $row ) {
324 /* If page was moved somewhere, get the title of the move target. */
325 $movedToTitle = false;
326 if ( isset( $row->rc_moved_to_title ) && $row->rc_moved_to_title !== '' ) {
327 $movedToTitle = Title::makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title );
328 }
329
330 /* Determine the title of the page that has been changed. */
331 $title = Title::makeTitle( $row->rc_namespace, $row->rc_title );
332
333 /* Our output data. */
334 $vals = array();
335
336 $type = intval( $row->rc_type );
337
338 /* Determine what kind of change this was. */
339 switch ( $type ) {
340 case RC_EDIT:
341 $vals['type'] = 'edit';
342 break;
343 case RC_NEW:
344 $vals['type'] = 'new';
345 break;
346 case RC_MOVE:
347 $vals['type'] = 'move';
348 break;
349 case RC_LOG:
350 $vals['type'] = 'log';
351 break;
352 case RC_MOVE_OVER_REDIRECT:
353 $vals['type'] = 'move over redirect';
354 break;
355 default:
356 $vals['type'] = $type;
357 }
358
359 /* Create a new entry in the result for the title. */
360 if ( $this->fld_title ) {
361 ApiQueryBase::addTitleInfo( $vals, $title );
362 if ( $movedToTitle ) {
363 ApiQueryBase::addTitleInfo( $vals, $movedToTitle, 'new_' );
364 }
365 }
366
367 /* Add ids, such as rcid, pageid, revid, and oldid to the change's info. */
368 if ( $this->fld_ids ) {
369 $vals['rcid'] = intval( $row->rc_id );
370 $vals['pageid'] = intval( $row->rc_cur_id );
371 $vals['revid'] = intval( $row->rc_this_oldid );
372 $vals['old_revid'] = intval( $row->rc_last_oldid );
373 }
374
375 /* Add user data and 'anon' flag, if use is anonymous. */
376 if ( $this->fld_user || $this->fld_userid ) {
377
378 if ( $this->fld_user ) {
379 $vals['user'] = $row->rc_user_text;
380 }
381
382 if ( $this->fld_userid ) {
383 $vals['userid'] = $row->rc_user;
384 }
385
386 if ( !$row->rc_user ) {
387 $vals['anon'] = '';
388 }
389 }
390
391 /* Add flags, such as new, minor, bot. */
392 if ( $this->fld_flags ) {
393 if ( $row->rc_bot ) {
394 $vals['bot'] = '';
395 }
396 if ( $row->rc_new ) {
397 $vals['new'] = '';
398 }
399 if ( $row->rc_minor ) {
400 $vals['minor'] = '';
401 }
402 }
403
404 /* Add sizes of each revision. (Only available on 1.10+) */
405 if ( $this->fld_sizes ) {
406 $vals['oldlen'] = intval( $row->rc_old_len );
407 $vals['newlen'] = intval( $row->rc_new_len );
408 }
409
410 /* Add the timestamp. */
411 if ( $this->fld_timestamp ) {
412 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rc_timestamp );
413 }
414
415 /* Add edit summary / log summary. */
416 if ( $this->fld_comment && isset( $row->rc_comment ) ) {
417 $vals['comment'] = $row->rc_comment;
418 }
419
420 if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
421 $vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title );
422 }
423
424 if ( $this->fld_redirect ) {
425 if ( $row->page_is_redirect ) {
426 $vals['redirect'] = '';
427 }
428 }
429
430 /* Add the patrolled flag */
431 if ( $this->fld_patrolled && $row->rc_patrolled == 1 ) {
432 $vals['patrolled'] = '';
433 }
434
435 if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
436 $vals['logid'] = intval( $row->rc_logid );
437 $vals['logtype'] = $row->rc_log_type;
438 $vals['logaction'] = $row->rc_log_action;
439 $logEntry = DatabaseLogEntry::newFromRow( (array)$row );
440 ApiQueryLogEvents::addLogParams(
441 $this->getResult(),
442 $vals,
443 $logEntry->getParameters(),
444 $logEntry->getType(),
445 $logEntry->getSubtype(),
446 $logEntry->getTimestamp()
447 );
448 }
449
450 if ( $this->fld_tags ) {
451 if ( $row->ts_tags ) {
452 $tags = explode( ',', $row->ts_tags );
453 $this->getResult()->setIndexedTagName( $tags, 'tag' );
454 $vals['tags'] = $tags;
455 } else {
456 $vals['tags'] = array();
457 }
458 }
459
460 if ( !is_null( $this->token ) ) {
461 $tokenFunctions = $this->getTokenFunctions();
462 foreach ( $this->token as $t ) {
463 $val = call_user_func( $tokenFunctions[$t], $row->rc_cur_id,
464 $title, RecentChange::newFromRow( $row ) );
465 if ( $val === false ) {
466 $this->setWarning( "Action '$t' is not allowed for the current user" );
467 } else {
468 $vals[$t . 'token'] = $val;
469 }
470 }
471 }
472
473 return $vals;
474 }
475
476 private function parseRCType( $type ) {
477 if ( is_array( $type ) ) {
478 $retval = array();
479 foreach ( $type as $t ) {
480 $retval[] = $this->parseRCType( $t );
481 }
482 return $retval;
483 }
484 switch( $type ) {
485 case 'edit':
486 return RC_EDIT;
487 case 'new':
488 return RC_NEW;
489 case 'log':
490 return RC_LOG;
491 }
492 }
493
494 public function getCacheMode( $params ) {
495 if ( isset( $params['show'] ) ) {
496 foreach ( $params['show'] as $show ) {
497 if ( $show === 'patrolled' || $show === '!patrolled' ) {
498 return 'private';
499 }
500 }
501 }
502 if ( isset( $params['token'] ) ) {
503 return 'private';
504 }
505 if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
506 // formatComment() calls wfMsg() among other things
507 return 'anon-public-user-private';
508 }
509 return 'public';
510 }
511
512 public function getAllowedParams() {
513 return array(
514 'start' => array(
515 ApiBase::PARAM_TYPE => 'timestamp'
516 ),
517 'end' => array(
518 ApiBase::PARAM_TYPE => 'timestamp'
519 ),
520 'dir' => array(
521 ApiBase::PARAM_DFLT => 'older',
522 ApiBase::PARAM_TYPE => array(
523 'newer',
524 'older'
525 )
526 ),
527 'namespace' => array(
528 ApiBase::PARAM_ISMULTI => true,
529 ApiBase::PARAM_TYPE => 'namespace'
530 ),
531 'user' => array(
532 ApiBase::PARAM_TYPE => 'user'
533 ),
534 'excludeuser' => array(
535 ApiBase::PARAM_TYPE => 'user'
536 ),
537 'tag' => null,
538 'prop' => array(
539 ApiBase::PARAM_ISMULTI => true,
540 ApiBase::PARAM_DFLT => 'title|timestamp|ids',
541 ApiBase::PARAM_TYPE => array(
542 'user',
543 'userid',
544 'comment',
545 'parsedcomment',
546 'flags',
547 'timestamp',
548 'title',
549 'ids',
550 'sizes',
551 'redirect',
552 'patrolled',
553 'loginfo',
554 'tags'
555 )
556 ),
557 'token' => array(
558 ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
559 ApiBase::PARAM_ISMULTI => true
560 ),
561 'show' => array(
562 ApiBase::PARAM_ISMULTI => true,
563 ApiBase::PARAM_TYPE => array(
564 'minor',
565 '!minor',
566 'bot',
567 '!bot',
568 'anon',
569 '!anon',
570 'redirect',
571 '!redirect',
572 'patrolled',
573 '!patrolled'
574 )
575 ),
576 'limit' => array(
577 ApiBase::PARAM_DFLT => 10,
578 ApiBase::PARAM_TYPE => 'limit',
579 ApiBase::PARAM_MIN => 1,
580 ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
581 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
582 ),
583 'type' => array(
584 ApiBase::PARAM_ISMULTI => true,
585 ApiBase::PARAM_TYPE => array(
586 'edit',
587 'new',
588 'log'
589 )
590 ),
591 'toponly' => false,
592 );
593 }
594
595 public function getParamDescription() {
596 $p = $this->getModulePrefix();
597 return array(
598 'start' => 'The timestamp to start enumerating from',
599 'end' => 'The timestamp to end enumerating',
600 'dir' => $this->getDirectionDescription( $p ),
601 'namespace' => 'Filter log entries to only this namespace(s)',
602 'user' => 'Only list changes by this user',
603 'excludeuser' => 'Don\'t list changes by this user',
604 'prop' => array(
605 'Include additional pieces of information',
606 ' user - Adds the user responsible for the edit and tags if they are an IP',
607 ' userid - Adds the user id responsible for the edit',
608 ' comment - Adds the comment for the edit',
609 ' parsedcomment - Adds the parsed comment for the edit',
610 ' flags - Adds flags for the edit',
611 ' timestamp - Adds timestamp of the edit',
612 ' title - Adds the page title of the edit',
613 ' ids - Adds the page ID, recent changes ID and the new and old revision ID',
614 ' sizes - Adds the new and old page length in bytes',
615 ' redirect - Tags edit if page is a redirect',
616 ' patrolled - Tags edits that have been patrolled',
617 ' loginfo - Adds log information (logid, logtype, etc) to log entries',
618 ' tags - Lists tags for the entry',
619 ),
620 'token' => 'Which tokens to obtain for each change',
621 'show' => array(
622 'Show only items that meet this criteria.',
623 "For example, to see only minor edits done by logged-in users, set {$p}show=minor|!anon"
624 ),
625 'type' => 'Which types of changes to show',
626 'limit' => 'How many total changes to return',
627 'tag' => 'Only list changes tagged with this tag',
628 'toponly' => 'Only list changes which are the latest revision',
629 );
630 }
631
632 public function getResultProperties() {
633 global $wgLogTypes;
634 $props = array(
635 '' => array(
636 'type' => array(
637 ApiBase::PROP_TYPE => array(
638 'edit',
639 'new',
640 'move',
641 'log',
642 'move over redirect'
643 )
644 )
645 ),
646 'title' => array(
647 'ns' => 'namespace',
648 'title' => 'string',
649 'new_ns' => array(
650 ApiBase::PROP_TYPE => 'namespace',
651 ApiBase::PROP_NULLABLE => true
652 ),
653 'new_title' => array(
654 ApiBase::PROP_TYPE => 'string',
655 ApiBase::PROP_NULLABLE => true
656 )
657 ),
658 'ids' => array(
659 'rcid' => 'integer',
660 'pageid' => 'integer',
661 'revid' => 'integer',
662 'old_revid' => 'integer'
663 ),
664 'user' => array(
665 'user' => 'string',
666 'anon' => 'boolean'
667 ),
668 'userid' => array(
669 'userid' => 'integer',
670 'anon' => 'boolean'
671 ),
672 'flags' => array(
673 'bot' => 'boolean',
674 'new' => 'boolean',
675 'minor' => 'boolean'
676 ),
677 'sizes' => array(
678 'oldlen' => 'integer',
679 'newlen' => 'integer'
680 ),
681 'timestamp' => array(
682 'timestamp' => 'timestamp'
683 ),
684 'comment' => array(
685 'comment' => array(
686 ApiBase::PROP_TYPE => 'string',
687 ApiBase::PROP_NULLABLE => true
688 )
689 ),
690 'parsedcomment' => array(
691 'parsedcomment' => array(
692 ApiBase::PROP_TYPE => 'string',
693 ApiBase::PROP_NULLABLE => true
694 )
695 ),
696 'redirect' => array(
697 'redirect' => 'boolean'
698 ),
699 'patrolled' => array(
700 'patrolled' => 'boolean'
701 ),
702 'loginfo' => array(
703 'logid' => array(
704 ApiBase::PROP_TYPE => 'integer',
705 ApiBase::PROP_NULLABLE => true
706 ),
707 'logtype' => array(
708 ApiBase::PROP_TYPE => $wgLogTypes,
709 ApiBase::PROP_NULLABLE => true
710 ),
711 'logaction' => array(
712 ApiBase::PROP_TYPE => 'string',
713 ApiBase::PROP_NULLABLE => true
714 )
715 )
716 );
717
718 self::addTokenProperties( $props, $this->getTokenFunctions() );
719
720 return $props;
721 }
722
723 public function getDescription() {
724 return 'Enumerate recent changes';
725 }
726
727 public function getPossibleErrors() {
728 return array_merge( parent::getPossibleErrors(), array(
729 array( 'show' ),
730 array( 'code' => 'permissiondenied', 'info' => 'You need the patrol right to request the patrolled flag' ),
731 array( 'code' => 'user-excludeuser', 'info' => 'user and excludeuser cannot be used together' ),
732 ) );
733 }
734
735 public function getExamples() {
736 return array(
737 'api.php?action=query&list=recentchanges'
738 );
739 }
740
741 public function getHelpUrls() {
742 return 'https://www.mediawiki.org/wiki/API:Recentchanges';
743 }
744
745 public function getVersion() {
746 return __CLASS__ . ': $Id$';
747 }
748 }