Merge "Revert "Function for "pretty timestamps" that are human readable and understan...
[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_deleted'
218 ) );
219
220 $showRedirects = false;
221 /* Determine what properties we need to display. */
222 if ( !is_null( $params['prop'] ) ) {
223 $prop = array_flip( $params['prop'] );
224
225 /* Set up internal members based upon params. */
226 $this->initProperties( $prop );
227
228 if ( $this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
229 $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
230 }
231
232 /* Add fields to our query if they are specified as a needed parameter. */
233 $this->addFieldsIf( array( 'rc_id', 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids );
234 $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
235 $this->addFieldsIf( 'rc_user', $this->fld_user );
236 $this->addFieldsIf( 'rc_user_text', $this->fld_user || $this->fld_userid );
237 $this->addFieldsIf( array( 'rc_minor', 'rc_type', 'rc_bot' ) , $this->fld_flags );
238 $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes );
239 $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled );
240 $this->addFieldsIf( array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ), $this->fld_loginfo );
241 $showRedirects = $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] );
242 }
243
244 if ( $this->fld_tags ) {
245 $this->addTables( 'tag_summary' );
246 $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rc_id=ts_rc_id' ) ) ) );
247 $this->addFields( 'ts_tags' );
248 }
249
250 if ( $params['toponly'] || $showRedirects ) {
251 $this->addTables( 'page' );
252 $this->addJoinConds( array( 'page' => array( 'LEFT JOIN', array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) );
253 $this->addFields( 'page_is_redirect' );
254
255 if ( $params['toponly'] ) {
256 $this->addWhere( 'rc_this_oldid = page_latest' );
257 }
258 }
259
260 if ( !is_null( $params['tag'] ) ) {
261 $this->addTables( 'change_tag' );
262 $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rc_id=ct_rc_id' ) ) ) );
263 $this->addWhereFld( 'ct_tag' , $params['tag'] );
264 global $wgOldChangeTagsIndex;
265 $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
266 }
267
268 $this->token = $params['token'];
269 $this->addOption( 'LIMIT', $params['limit'] + 1 );
270 $this->addOption( 'USE INDEX', $index );
271
272 $count = 0;
273 /* Perform the actual query. */
274 $res = $this->select( __METHOD__ );
275
276 $titles = array();
277
278 $result = $this->getResult();
279
280 /* Iterate through the rows, adding data extracted from them to our query result. */
281 foreach ( $res as $row ) {
282 if ( ++ $count > $params['limit'] ) {
283 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
284 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
285 break;
286 }
287
288 if ( is_null( $resultPageSet ) ) {
289 /* Extract the data from a single row. */
290 $vals = $this->extractRowInfo( $row );
291
292 /* Add that row's data to our final output. */
293 if ( !$vals ) {
294 continue;
295 }
296 $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
297 if ( !$fit ) {
298 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
299 break;
300 }
301 } else {
302 $titles[] = Title::makeTitle( $row->rc_namespace, $row->rc_title );
303 }
304 }
305
306 if ( is_null( $resultPageSet ) ) {
307 /* Format the result */
308 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' );
309 } else {
310 $resultPageSet->populateFromTitles( $titles );
311 }
312 }
313
314 /**
315 * Extracts from a single sql row the data needed to describe one recent change.
316 *
317 * @param $row The row from which to extract the data.
318 * @return array An array mapping strings (descriptors) to their respective string values.
319 * @access public
320 */
321 public function extractRowInfo( $row ) {
322 /* Determine the title of the page that has been changed. */
323 $title = Title::makeTitle( $row->rc_namespace, $row->rc_title );
324
325 /* Our output data. */
326 $vals = array();
327
328 $type = intval( $row->rc_type );
329
330 /* Determine what kind of change this was. */
331 switch ( $type ) {
332 case RC_EDIT:
333 $vals['type'] = 'edit';
334 break;
335 case RC_NEW:
336 $vals['type'] = 'new';
337 break;
338 case RC_MOVE:
339 $vals['type'] = 'move';
340 break;
341 case RC_LOG:
342 $vals['type'] = 'log';
343 break;
344 case RC_MOVE_OVER_REDIRECT:
345 $vals['type'] = 'move over redirect';
346 break;
347 default:
348 $vals['type'] = $type;
349 }
350
351 /* Create a new entry in the result for the title. */
352 if ( $this->fld_title ) {
353 ApiQueryBase::addTitleInfo( $vals, $title );
354 }
355
356 /* Add ids, such as rcid, pageid, revid, and oldid to the change's info. */
357 if ( $this->fld_ids ) {
358 $vals['rcid'] = intval( $row->rc_id );
359 $vals['pageid'] = intval( $row->rc_cur_id );
360 $vals['revid'] = intval( $row->rc_this_oldid );
361 $vals['old_revid'] = intval( $row->rc_last_oldid );
362 }
363
364 /* Add user data and 'anon' flag, if use is anonymous. */
365 if ( $this->fld_user || $this->fld_userid ) {
366
367 if ( $this->fld_user ) {
368 $vals['user'] = $row->rc_user_text;
369 }
370
371 if ( $this->fld_userid ) {
372 $vals['userid'] = $row->rc_user;
373 }
374
375 if ( !$row->rc_user ) {
376 $vals['anon'] = '';
377 }
378 }
379
380 /* Add flags, such as new, minor, bot. */
381 if ( $this->fld_flags ) {
382 if ( $row->rc_bot ) {
383 $vals['bot'] = '';
384 }
385 if ( $row->rc_type == RC_NEW ) {
386 $vals['new'] = '';
387 }
388 if ( $row->rc_minor ) {
389 $vals['minor'] = '';
390 }
391 }
392
393 /* Add sizes of each revision. (Only available on 1.10+) */
394 if ( $this->fld_sizes ) {
395 $vals['oldlen'] = intval( $row->rc_old_len );
396 $vals['newlen'] = intval( $row->rc_new_len );
397 }
398
399 /* Add the timestamp. */
400 if ( $this->fld_timestamp ) {
401 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rc_timestamp );
402 }
403
404 /* Add edit summary / log summary. */
405 if ( $this->fld_comment && isset( $row->rc_comment ) ) {
406 $vals['comment'] = $row->rc_comment;
407 }
408
409 if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
410 $vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title );
411 }
412
413 if ( $this->fld_redirect ) {
414 if ( $row->page_is_redirect ) {
415 $vals['redirect'] = '';
416 }
417 }
418
419 /* Add the patrolled flag */
420 if ( $this->fld_patrolled && $row->rc_patrolled == 1 ) {
421 $vals['patrolled'] = '';
422 }
423
424 if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
425 $vals['logid'] = intval( $row->rc_logid );
426 $vals['logtype'] = $row->rc_log_type;
427 $vals['logaction'] = $row->rc_log_action;
428 $logEntry = DatabaseLogEntry::newFromRow( (array)$row );
429 ApiQueryLogEvents::addLogParams(
430 $this->getResult(),
431 $vals,
432 $logEntry->getParameters(),
433 $logEntry->getType(),
434 $logEntry->getSubtype(),
435 $logEntry->getTimestamp()
436 );
437 }
438
439 if ( $this->fld_tags ) {
440 if ( $row->ts_tags ) {
441 $tags = explode( ',', $row->ts_tags );
442 $this->getResult()->setIndexedTagName( $tags, 'tag' );
443 $vals['tags'] = $tags;
444 } else {
445 $vals['tags'] = array();
446 }
447 }
448
449 if ( !is_null( $this->token ) ) {
450 $tokenFunctions = $this->getTokenFunctions();
451 foreach ( $this->token as $t ) {
452 $val = call_user_func( $tokenFunctions[$t], $row->rc_cur_id,
453 $title, RecentChange::newFromRow( $row ) );
454 if ( $val === false ) {
455 $this->setWarning( "Action '$t' is not allowed for the current user" );
456 } else {
457 $vals[$t . 'token'] = $val;
458 }
459 }
460 }
461
462 return $vals;
463 }
464
465 private function parseRCType( $type ) {
466 if ( is_array( $type ) ) {
467 $retval = array();
468 foreach ( $type as $t ) {
469 $retval[] = $this->parseRCType( $t );
470 }
471 return $retval;
472 }
473 switch( $type ) {
474 case 'edit':
475 return RC_EDIT;
476 case 'new':
477 return RC_NEW;
478 case 'log':
479 return RC_LOG;
480 }
481 }
482
483 public function getCacheMode( $params ) {
484 if ( isset( $params['show'] ) ) {
485 foreach ( $params['show'] as $show ) {
486 if ( $show === 'patrolled' || $show === '!patrolled' ) {
487 return 'private';
488 }
489 }
490 }
491 if ( isset( $params['token'] ) ) {
492 return 'private';
493 }
494 if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
495 // formatComment() calls wfMessage() among other things
496 return 'anon-public-user-private';
497 }
498 return 'public';
499 }
500
501 public function getAllowedParams() {
502 return array(
503 'start' => array(
504 ApiBase::PARAM_TYPE => 'timestamp'
505 ),
506 'end' => array(
507 ApiBase::PARAM_TYPE => 'timestamp'
508 ),
509 'dir' => array(
510 ApiBase::PARAM_DFLT => 'older',
511 ApiBase::PARAM_TYPE => array(
512 'newer',
513 'older'
514 )
515 ),
516 'namespace' => array(
517 ApiBase::PARAM_ISMULTI => true,
518 ApiBase::PARAM_TYPE => 'namespace'
519 ),
520 'user' => array(
521 ApiBase::PARAM_TYPE => 'user'
522 ),
523 'excludeuser' => array(
524 ApiBase::PARAM_TYPE => 'user'
525 ),
526 'tag' => null,
527 'prop' => array(
528 ApiBase::PARAM_ISMULTI => true,
529 ApiBase::PARAM_DFLT => 'title|timestamp|ids',
530 ApiBase::PARAM_TYPE => array(
531 'user',
532 'userid',
533 'comment',
534 'parsedcomment',
535 'flags',
536 'timestamp',
537 'title',
538 'ids',
539 'sizes',
540 'redirect',
541 'patrolled',
542 'loginfo',
543 'tags'
544 )
545 ),
546 'token' => array(
547 ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
548 ApiBase::PARAM_ISMULTI => true
549 ),
550 'show' => array(
551 ApiBase::PARAM_ISMULTI => true,
552 ApiBase::PARAM_TYPE => array(
553 'minor',
554 '!minor',
555 'bot',
556 '!bot',
557 'anon',
558 '!anon',
559 'redirect',
560 '!redirect',
561 'patrolled',
562 '!patrolled'
563 )
564 ),
565 'limit' => array(
566 ApiBase::PARAM_DFLT => 10,
567 ApiBase::PARAM_TYPE => 'limit',
568 ApiBase::PARAM_MIN => 1,
569 ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
570 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
571 ),
572 'type' => array(
573 ApiBase::PARAM_ISMULTI => true,
574 ApiBase::PARAM_TYPE => array(
575 'edit',
576 'new',
577 'log'
578 )
579 ),
580 'toponly' => false,
581 );
582 }
583
584 public function getParamDescription() {
585 $p = $this->getModulePrefix();
586 return array(
587 'start' => 'The timestamp to start enumerating from',
588 'end' => 'The timestamp to end enumerating',
589 'dir' => $this->getDirectionDescription( $p ),
590 'namespace' => 'Filter log entries to only this namespace(s)',
591 'user' => 'Only list changes by this user',
592 'excludeuser' => 'Don\'t list changes by this user',
593 'prop' => array(
594 'Include additional pieces of information',
595 ' user - Adds the user responsible for the edit and tags if they are an IP',
596 ' userid - Adds the user id responsible for the edit',
597 ' comment - Adds the comment for the edit',
598 ' parsedcomment - Adds the parsed comment for the edit',
599 ' flags - Adds flags for the edit',
600 ' timestamp - Adds timestamp of the edit',
601 ' title - Adds the page title of the edit',
602 ' ids - Adds the page ID, recent changes ID and the new and old revision ID',
603 ' sizes - Adds the new and old page length in bytes',
604 ' redirect - Tags edit if page is a redirect',
605 ' patrolled - Tags edits that have been patrolled',
606 ' loginfo - Adds log information (logid, logtype, etc) to log entries',
607 ' tags - Lists tags for the entry',
608 ),
609 'token' => 'Which tokens to obtain for each change',
610 'show' => array(
611 'Show only items that meet this criteria.',
612 "For example, to see only minor edits done by logged-in users, set {$p}show=minor|!anon"
613 ),
614 'type' => 'Which types of changes to show',
615 'limit' => 'How many total changes to return',
616 'tag' => 'Only list changes tagged with this tag',
617 'toponly' => 'Only list changes which are the latest revision',
618 );
619 }
620
621 public function getResultProperties() {
622 global $wgLogTypes;
623 $props = array(
624 '' => array(
625 'type' => array(
626 ApiBase::PROP_TYPE => array(
627 'edit',
628 'new',
629 'move',
630 'log',
631 'move over redirect'
632 )
633 )
634 ),
635 'title' => array(
636 'ns' => 'namespace',
637 'title' => 'string',
638 'new_ns' => array(
639 ApiBase::PROP_TYPE => 'namespace',
640 ApiBase::PROP_NULLABLE => true
641 ),
642 'new_title' => array(
643 ApiBase::PROP_TYPE => 'string',
644 ApiBase::PROP_NULLABLE => true
645 )
646 ),
647 'ids' => array(
648 'rcid' => 'integer',
649 'pageid' => 'integer',
650 'revid' => 'integer',
651 'old_revid' => 'integer'
652 ),
653 'user' => array(
654 'user' => 'string',
655 'anon' => 'boolean'
656 ),
657 'userid' => array(
658 'userid' => 'integer',
659 'anon' => 'boolean'
660 ),
661 'flags' => array(
662 'bot' => 'boolean',
663 'new' => 'boolean',
664 'minor' => 'boolean'
665 ),
666 'sizes' => array(
667 'oldlen' => 'integer',
668 'newlen' => 'integer'
669 ),
670 'timestamp' => array(
671 'timestamp' => 'timestamp'
672 ),
673 'comment' => array(
674 'comment' => array(
675 ApiBase::PROP_TYPE => 'string',
676 ApiBase::PROP_NULLABLE => true
677 )
678 ),
679 'parsedcomment' => array(
680 'parsedcomment' => array(
681 ApiBase::PROP_TYPE => 'string',
682 ApiBase::PROP_NULLABLE => true
683 )
684 ),
685 'redirect' => array(
686 'redirect' => 'boolean'
687 ),
688 'patrolled' => array(
689 'patrolled' => 'boolean'
690 ),
691 'loginfo' => array(
692 'logid' => array(
693 ApiBase::PROP_TYPE => 'integer',
694 ApiBase::PROP_NULLABLE => true
695 ),
696 'logtype' => array(
697 ApiBase::PROP_TYPE => $wgLogTypes,
698 ApiBase::PROP_NULLABLE => true
699 ),
700 'logaction' => array(
701 ApiBase::PROP_TYPE => 'string',
702 ApiBase::PROP_NULLABLE => true
703 )
704 )
705 );
706
707 self::addTokenProperties( $props, $this->getTokenFunctions() );
708
709 return $props;
710 }
711
712 public function getDescription() {
713 return 'Enumerate recent changes';
714 }
715
716 public function getPossibleErrors() {
717 return array_merge( parent::getPossibleErrors(), array(
718 array( 'show' ),
719 array( 'code' => 'permissiondenied', 'info' => 'You need the patrol right to request the patrolled flag' ),
720 array( 'code' => 'user-excludeuser', 'info' => 'user and excludeuser cannot be used together' ),
721 ) );
722 }
723
724 public function getExamples() {
725 return array(
726 'api.php?action=query&list=recentchanges'
727 );
728 }
729
730 public function getHelpUrls() {
731 return 'https://www.mediawiki.org/wiki/API:Recentchanges';
732 }
733
734 public function getVersion() {
735 return __CLASS__ . ': $Id$';
736 }
737 }