5 * Created on Oct 19, 2006
7 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
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.
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.
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
28 * A query action to enumerate the recent changes that were done to the wiki.
29 * Various filters are supported.
33 class ApiQueryRecentChanges
extends ApiQueryGeneratorBase
{
35 public function __construct( $query, $moduleName ) {
36 parent
::__construct( $query, $moduleName, 'rc' );
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 = array();
44 private $tokenFunctions;
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)
52 protected function getTokenFunctions() {
53 // Don't call the hooks twice
54 if ( isset( $this->tokenFunctions
) ) {
55 return $this->tokenFunctions
;
58 // If we're in JSON callback mode, no tokens can be obtained
59 if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
63 $this->tokenFunctions
= array(
64 'patrol' => array( 'ApiQueryRecentChanges', 'getPatrolToken' )
66 wfRunHooks( 'APIQueryRecentChangesTokens', array( &$this->tokenFunctions
) );
68 return $this->tokenFunctions
;
74 * @param RecentChange|null $rc
77 public static function getPatrolToken( $pageid, $title, $rc = null ) {
80 $validTokenUser = false;
83 if ( ( $wgUser->useRCPatrol() && $rc->getAttribute( 'rc_type' ) == RC_EDIT
) ||
84 ( $wgUser->useNPPatrol() && $rc->getAttribute( 'rc_type' ) == RC_NEW
)
86 $validTokenUser = true;
88 } elseif ( $wgUser->useRCPatrol() ||
$wgUser->useNPPatrol() ) {
89 $validTokenUser = true;
92 if ( $validTokenUser ) {
93 // The patrol token is always the same, let's exploit that
94 static $cachedPatrolToken = null;
96 if ( is_null( $cachedPatrolToken ) ) {
97 $cachedPatrolToken = $wgUser->getEditToken( 'patrol' );
100 return $cachedPatrolToken;
107 * Sets internal state to include the desired properties in the output.
108 * @param array $prop associative array of properties, only keys are used here
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 $this->fld_sha1
= isset( $prop['sha1'] );
127 public function execute() {
131 public function executeGenerator( $resultPageSet ) {
132 $this->run( $resultPageSet );
136 * Generates and outputs the result of this query based upon the provided parameters.
138 * @param ApiPageSet $resultPageSet
140 public function run( $resultPageSet = null ) {
141 $user = $this->getUser();
142 /* Get the parameters of the request. */
143 $params = $this->extractRequestParams();
145 /* Build our basic query. Namely, something along the lines of:
146 * SELECT * FROM recentchanges WHERE rc_timestamp > $start
147 * AND rc_timestamp < $end AND rc_namespace = $namespace
149 $this->addTables( 'recentchanges' );
150 $index = array( 'recentchanges' => 'rc_timestamp' ); // May change
151 $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
153 if ( !is_null( $params['continue'] ) ) {
154 $cont = explode( '|', $params['continue'] );
155 $this->dieContinueUsageIf( count( $cont ) != 2 );
156 $db = $this->getDB();
157 $timestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
158 $id = intval( $cont[1] );
159 $this->dieContinueUsageIf( $id != $cont[1] );
160 $op = $params['dir'] === 'older' ?
'<' : '>';
162 "rc_timestamp $op $timestamp OR " .
163 "(rc_timestamp = $timestamp AND " .
168 $order = $params['dir'] === 'older' ?
'DESC' : 'ASC';
169 $this->addOption( 'ORDER BY', array(
170 "rc_timestamp $order",
174 $this->addWhereFld( 'rc_namespace', $params['namespace'] );
176 if ( !is_null( $params['type'] ) ) {
177 $this->addWhereFld( 'rc_type', $this->parseRCType( $params['type'] ) );
180 if ( !is_null( $params['show'] ) ) {
181 $show = array_flip( $params['show'] );
183 /* Check for conflicting parameters. */
184 if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
185 ||
( isset( $show['bot'] ) && isset( $show['!bot'] ) )
186 ||
( isset( $show['anon'] ) && isset( $show['!anon'] ) )
187 ||
( isset( $show['redirect'] ) && isset( $show['!redirect'] ) )
188 ||
( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
189 ||
( isset( $show['patrolled'] ) && isset( $show['unpatrolled'] ) )
190 ||
( isset( $show['!patrolled'] ) && isset( $show['unpatrolled'] ) )
192 $this->dieUsageMsg( 'show' );
196 if ( isset( $show['patrolled'] )
197 ||
isset( $show['!patrolled'] )
198 ||
isset( $show['unpatrolled'] )
200 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
202 'You need the patrol right to request the patrolled flag',
208 /* Add additional conditions to query depending upon parameters. */
209 $this->addWhereIf( 'rc_minor = 0', isset( $show['!minor'] ) );
210 $this->addWhereIf( 'rc_minor != 0', isset( $show['minor'] ) );
211 $this->addWhereIf( 'rc_bot = 0', isset( $show['!bot'] ) );
212 $this->addWhereIf( 'rc_bot != 0', isset( $show['bot'] ) );
213 $this->addWhereIf( 'rc_user = 0', isset( $show['anon'] ) );
214 $this->addWhereIf( 'rc_user != 0', isset( $show['!anon'] ) );
215 $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
216 $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
217 $this->addWhereIf( 'page_is_redirect = 1', isset( $show['redirect'] ) );
219 if ( isset( $show['unpatrolled'] ) ) {
220 // See ChangesList:isUnpatrolled
221 if ( $user->useRCPatrol() ) {
222 $this->addWhere( 'rc_patrolled = 0' );
223 } elseif ( $user->useNPPatrol() ) {
224 $this->addWhere( 'rc_patrolled = 0' );
225 $this->addWhereFld( 'rc_type', RC_NEW
);
229 // Don't throw log entries out the window here
231 'page_is_redirect = 0 OR page_is_redirect IS NULL',
232 isset( $show['!redirect'] )
236 if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) {
237 $this->dieUsage( 'user and excludeuser cannot be used together', 'user-excludeuser' );
240 if ( !is_null( $params['user'] ) ) {
241 $this->addWhereFld( 'rc_user_text', $params['user'] );
242 $index['recentchanges'] = 'rc_user_text';
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'] ) );
252 /* Add the fields we're concerned with to our query. */
253 $this->addFields( array(
263 $showRedirects = false;
264 /* Determine what properties we need to display. */
265 if ( !is_null( $params['prop'] ) ) {
266 $prop = array_flip( $params['prop'] );
268 /* Set up internal members based upon params. */
269 $this->initProperties( $prop );
271 if ( $this->fld_patrolled
&& !$user->useRCPatrol() && !$user->useNPPatrol() ) {
273 'You need the patrol right to request the patrolled flag',
278 /* Add fields to our query if they are specified as a needed parameter. */
279 $this->addFieldsIf( array( 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids
);
280 $this->addFieldsIf( 'rc_comment', $this->fld_comment ||
$this->fld_parsedcomment
);
281 $this->addFieldsIf( 'rc_user', $this->fld_user ||
$this->fld_userid
);
282 $this->addFieldsIf( 'rc_user_text', $this->fld_user
);
283 $this->addFieldsIf( array( 'rc_minor', 'rc_type', 'rc_bot' ), $this->fld_flags
);
284 $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes
);
285 $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled
);
287 array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ),
290 $showRedirects = $this->fld_redirect ||
isset( $show['redirect'] )
291 ||
isset( $show['!redirect'] );
294 if ( $this->fld_tags
) {
295 $this->addTables( 'tag_summary' );
296 $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rc_id=ts_rc_id' ) ) ) );
297 $this->addFields( 'ts_tags' );
300 if ( $this->fld_sha1
) {
301 $this->addTables( 'revision' );
302 $this->addJoinConds( array( 'revision' => array( 'LEFT JOIN',
303 array( 'rc_this_oldid=rev_id' ) ) ) );
304 $this->addFields( array( 'rev_sha1', 'rev_deleted' ) );
307 if ( $params['toponly'] ||
$showRedirects ) {
308 $this->addTables( 'page' );
309 $this->addJoinConds( array( 'page' => array( 'LEFT JOIN',
310 array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) );
311 $this->addFields( 'page_is_redirect' );
313 if ( $params['toponly'] ) {
314 $this->addWhere( 'rc_this_oldid = page_latest' );
318 if ( !is_null( $params['tag'] ) ) {
319 $this->addTables( 'change_tag' );
320 $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rc_id=ct_rc_id' ) ) ) );
321 $this->addWhereFld( 'ct_tag', $params['tag'] );
324 // Paranoia: avoid brute force searches (bug 17342)
325 if ( !is_null( $params['user'] ) ||
!is_null( $params['excludeuser'] ) ) {
326 if ( !$user->isAllowed( 'deletedhistory' ) ) {
327 $bitmask = Revision
::DELETED_USER
;
328 } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
329 $bitmask = Revision
::DELETED_USER | Revision
::DELETED_RESTRICTED
;
334 $this->addWhere( $this->getDB()->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask" );
337 if ( $this->getRequest()->getCheck( 'namespace' ) ) {
338 // LogPage::DELETED_ACTION hides the affected page, too.
339 if ( !$user->isAllowed( 'deletedhistory' ) ) {
340 $bitmask = LogPage
::DELETED_ACTION
;
341 } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
342 $bitmask = LogPage
::DELETED_ACTION | LogPage
::DELETED_RESTRICTED
;
347 $this->addWhere( $this->getDB()->makeList( array(
348 'rc_type != ' . RC_LOG
,
349 $this->getDB()->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
354 $this->token
= $params['token'];
355 $this->addOption( 'LIMIT', $params['limit'] +
1 );
356 $this->addOption( 'USE INDEX', $index );
359 /* Perform the actual query. */
360 $res = $this->select( __METHOD__
);
364 $result = $this->getResult();
366 /* Iterate through the rows, adding data extracted from them to our query result. */
367 foreach ( $res as $row ) {
368 if ( ++
$count > $params['limit'] ) {
369 // We've reached the one extra which shows that there are
370 // additional pages to be had. Stop here...
371 $this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" );
375 if ( is_null( $resultPageSet ) ) {
376 /* Extract the data from a single row. */
377 $vals = $this->extractRowInfo( $row );
379 /* Add that row's data to our final output. */
383 $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
385 $this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" );
389 $titles[] = Title
::makeTitle( $row->rc_namespace
, $row->rc_title
);
393 if ( is_null( $resultPageSet ) ) {
394 /* Format the result */
395 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' );
397 $resultPageSet->populateFromTitles( $titles );
402 * Extracts from a single sql row the data needed to describe one recent change.
404 * @param mixed $row The row from which to extract the data.
405 * @return array An array mapping strings (descriptors) to their respective string values.
408 public function extractRowInfo( $row ) {
409 /* Determine the title of the page that has been changed. */
410 $title = Title
::makeTitle( $row->rc_namespace
, $row->rc_title
);
411 $user = $this->getUser();
413 /* Our output data. */
416 $type = intval( $row->rc_type
);
418 /* Determine what kind of change this was. */
421 $vals['type'] = 'edit';
424 $vals['type'] = 'new';
427 $vals['type'] = 'move';
430 $vals['type'] = 'log';
433 $vals['type'] = 'external';
435 case RC_MOVE_OVER_REDIRECT
:
436 $vals['type'] = 'move over redirect';
439 $vals['type'] = $type;
444 /* Create a new entry in the result for the title. */
445 if ( $this->fld_title ||
$this->fld_ids
) {
446 if ( $type === RC_LOG
&& ( $row->rc_deleted
& LogPage
::DELETED_ACTION
) ) {
447 $vals['actionhidden'] = '';
450 if ( $type !== RC_LOG ||
451 LogEventsList
::userCanBitfield( $row->rc_deleted
, LogPage
::DELETED_ACTION
, $user )
453 if ( $this->fld_title
) {
454 ApiQueryBase
::addTitleInfo( $vals, $title );
456 if ( $this->fld_ids
) {
457 $vals['pageid'] = intval( $row->rc_cur_id
);
458 $vals['revid'] = intval( $row->rc_this_oldid
);
459 $vals['old_revid'] = intval( $row->rc_last_oldid
);
464 if ( $this->fld_ids
) {
465 $vals['rcid'] = intval( $row->rc_id
);
468 /* Add user data and 'anon' flag, if user is anonymous. */
469 if ( $this->fld_user ||
$this->fld_userid
) {
470 if ( $row->rc_deleted
& Revision
::DELETED_USER
) {
471 $vals['userhidden'] = '';
474 if ( Revision
::userCanBitfield( $row->rc_deleted
, Revision
::DELETED_USER
, $user ) ) {
475 if ( $this->fld_user
) {
476 $vals['user'] = $row->rc_user_text
;
479 if ( $this->fld_userid
) {
480 $vals['userid'] = $row->rc_user
;
483 if ( !$row->rc_user
) {
489 /* Add flags, such as new, minor, bot. */
490 if ( $this->fld_flags
) {
491 if ( $row->rc_bot
) {
494 if ( $row->rc_type
== RC_NEW
) {
497 if ( $row->rc_minor
) {
502 /* Add sizes of each revision. (Only available on 1.10+) */
503 if ( $this->fld_sizes
) {
504 $vals['oldlen'] = intval( $row->rc_old_len
);
505 $vals['newlen'] = intval( $row->rc_new_len
);
508 /* Add the timestamp. */
509 if ( $this->fld_timestamp
) {
510 $vals['timestamp'] = wfTimestamp( TS_ISO_8601
, $row->rc_timestamp
);
513 /* Add edit summary / log summary. */
514 if ( $this->fld_comment ||
$this->fld_parsedcomment
) {
515 if ( $row->rc_deleted
& Revision
::DELETED_COMMENT
) {
516 $vals['commenthidden'] = '';
519 if ( Revision
::userCanBitfield( $row->rc_deleted
, Revision
::DELETED_COMMENT
, $user ) ) {
520 if ( $this->fld_comment
&& isset( $row->rc_comment
) ) {
521 $vals['comment'] = $row->rc_comment
;
524 if ( $this->fld_parsedcomment
&& isset( $row->rc_comment
) ) {
525 $vals['parsedcomment'] = Linker
::formatComment( $row->rc_comment
, $title );
530 if ( $this->fld_redirect
) {
531 if ( $row->page_is_redirect
) {
532 $vals['redirect'] = '';
536 /* Add the patrolled flag */
537 if ( $this->fld_patrolled
&& $row->rc_patrolled
== 1 ) {
538 $vals['patrolled'] = '';
541 if ( $this->fld_patrolled
&& ChangesList
::isUnpatrolled( $row, $user ) ) {
542 $vals['unpatrolled'] = '';
545 if ( $this->fld_loginfo
&& $row->rc_type
== RC_LOG
) {
546 if ( $row->rc_deleted
& LogPage
::DELETED_ACTION
) {
547 $vals['actionhidden'] = '';
550 if ( LogEventsList
::userCanBitfield( $row->rc_deleted
, LogPage
::DELETED_ACTION
, $user ) ) {
551 $vals['logid'] = intval( $row->rc_logid
);
552 $vals['logtype'] = $row->rc_log_type
;
553 $vals['logaction'] = $row->rc_log_action
;
554 $logEntry = DatabaseLogEntry
::newFromRow( (array)$row );
555 ApiQueryLogEvents
::addLogParams(
558 $logEntry->getParameters(),
559 $logEntry->getType(),
560 $logEntry->getSubtype(),
561 $logEntry->getTimestamp()
566 if ( $this->fld_tags
) {
567 if ( $row->ts_tags
) {
568 $tags = explode( ',', $row->ts_tags
);
569 $this->getResult()->setIndexedTagName( $tags, 'tag' );
570 $vals['tags'] = $tags;
572 $vals['tags'] = array();
576 if ( $this->fld_sha1
&& $row->rev_sha1
!== null ) {
577 if ( $row->rev_deleted
& Revision
::DELETED_TEXT
) {
578 $vals['sha1hidden'] = '';
581 if ( Revision
::userCanBitfield( $row->rev_deleted
, Revision
::DELETED_TEXT
, $user ) ) {
582 if ( $row->rev_sha1
!== '' ) {
583 $vals['sha1'] = wfBaseConvert( $row->rev_sha1
, 36, 16, 40 );
590 if ( !is_null( $this->token
) ) {
591 $tokenFunctions = $this->getTokenFunctions();
592 foreach ( $this->token
as $t ) {
593 $val = call_user_func( $tokenFunctions[$t], $row->rc_cur_id
,
594 $title, RecentChange
::newFromRow( $row ) );
595 if ( $val === false ) {
596 $this->setWarning( "Action '$t' is not allowed for the current user" );
598 $vals[$t . 'token'] = $val;
603 if ( $anyHidden && ( $row->rc_deleted
& Revision
::DELETED_RESTRICTED
) ) {
604 $vals['suppressed'] = '';
610 private function parseRCType( $type ) {
611 if ( is_array( $type ) ) {
613 foreach ( $type as $t ) {
614 $retval[] = $this->parseRCType( $t );
630 ApiBase
::dieDebug( __METHOD__
, "Unknown type '$type'" );
634 public function getCacheMode( $params ) {
635 if ( isset( $params['show'] ) ) {
636 foreach ( $params['show'] as $show ) {
637 if ( $show === 'patrolled' ||
$show === '!patrolled' ) {
642 if ( isset( $params['token'] ) ) {
645 if ( $this->userCanSeeRevDel() ) {
648 if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
649 // formatComment() calls wfMessage() among other things
650 return 'anon-public-user-private';
656 public function getAllowedParams() {
659 ApiBase
::PARAM_TYPE
=> 'timestamp'
662 ApiBase
::PARAM_TYPE
=> 'timestamp'
665 ApiBase
::PARAM_DFLT
=> 'older',
666 ApiBase
::PARAM_TYPE
=> array(
671 'namespace' => array(
672 ApiBase
::PARAM_ISMULTI
=> true,
673 ApiBase
::PARAM_TYPE
=> 'namespace'
676 ApiBase
::PARAM_TYPE
=> 'user'
678 'excludeuser' => array(
679 ApiBase
::PARAM_TYPE
=> 'user'
683 ApiBase
::PARAM_ISMULTI
=> true,
684 ApiBase
::PARAM_DFLT
=> 'title|timestamp|ids',
685 ApiBase
::PARAM_TYPE
=> array(
703 ApiBase
::PARAM_TYPE
=> array_keys( $this->getTokenFunctions() ),
704 ApiBase
::PARAM_ISMULTI
=> true
707 ApiBase
::PARAM_ISMULTI
=> true,
708 ApiBase
::PARAM_TYPE
=> array(
723 ApiBase
::PARAM_DFLT
=> 10,
724 ApiBase
::PARAM_TYPE
=> 'limit',
725 ApiBase
::PARAM_MIN
=> 1,
726 ApiBase
::PARAM_MAX
=> ApiBase
::LIMIT_BIG1
,
727 ApiBase
::PARAM_MAX2
=> ApiBase
::LIMIT_BIG2
730 ApiBase
::PARAM_ISMULTI
=> true,
731 ApiBase
::PARAM_TYPE
=> array(
743 public function getParamDescription() {
744 $p = $this->getModulePrefix();
747 'start' => 'The timestamp to start enumerating from',
748 'end' => 'The timestamp to end enumerating',
749 'dir' => $this->getDirectionDescription( $p ),
750 'namespace' => 'Filter log entries to only this namespace(s)',
751 'user' => 'Only list changes by this user',
752 'excludeuser' => 'Don\'t list changes by this user',
754 'Include additional pieces of information',
755 ' user - Adds the user responsible for the edit and tags if they are an IP',
756 ' userid - Adds the user id responsible for the edit',
757 ' comment - Adds the comment for the edit',
758 ' parsedcomment - Adds the parsed comment for the edit',
759 ' flags - Adds flags for the edit',
760 ' timestamp - Adds timestamp of the edit',
761 ' title - Adds the page title of the edit',
762 ' ids - Adds the page ID, recent changes ID and the new and old revision ID',
763 ' sizes - Adds the new and old page length in bytes',
764 ' redirect - Tags edit if page is a redirect',
765 ' patrolled - Tags patrollable edits as being patrolled or unpatrolled',
766 ' loginfo - Adds log information (logid, logtype, etc) to log entries',
767 ' tags - Lists tags for the entry',
768 ' sha1 - Adds the content checksum for entries associated with a revision',
770 'token' => 'Which tokens to obtain for each change',
772 'Show only items that meet this criteria.',
773 "For example, to see only minor edits done by logged-in users, set {$p}show=minor|!anon"
775 'type' => 'Which types of changes to show',
776 'limit' => 'How many total changes to return',
777 'tag' => 'Only list changes tagged with this tag',
778 'toponly' => 'Only list changes which are the latest revision',
779 'continue' => 'When more results are available, use this to continue',
783 public function getResultProperties() {
788 ApiBase
::PROP_TYPE
=> array(
801 ApiBase
::PROP_TYPE
=> 'namespace',
802 ApiBase
::PROP_NULLABLE
=> true
804 'new_title' => array(
805 ApiBase
::PROP_TYPE
=> 'string',
806 ApiBase
::PROP_NULLABLE
=> true
811 'pageid' => 'integer',
812 'revid' => 'integer',
813 'old_revid' => 'integer'
820 'userid' => 'integer',
829 'oldlen' => 'integer',
830 'newlen' => 'integer'
832 'timestamp' => array(
833 'timestamp' => 'timestamp'
837 ApiBase
::PROP_TYPE
=> 'string',
838 ApiBase
::PROP_NULLABLE
=> true
841 'parsedcomment' => array(
842 'parsedcomment' => array(
843 ApiBase
::PROP_TYPE
=> 'string',
844 ApiBase
::PROP_NULLABLE
=> true
848 'redirect' => 'boolean'
850 'patrolled' => array(
851 'patrolled' => 'boolean',
852 'unpatrolled' => 'boolean'
856 ApiBase
::PROP_TYPE
=> 'integer',
857 ApiBase
::PROP_NULLABLE
=> true
860 ApiBase
::PROP_TYPE
=> $wgLogTypes,
861 ApiBase
::PROP_NULLABLE
=> true
863 'logaction' => array(
864 ApiBase
::PROP_TYPE
=> 'string',
865 ApiBase
::PROP_NULLABLE
=> true
870 ApiBase
::PROP_TYPE
=> 'string',
871 ApiBase
::PROP_NULLABLE
=> true
873 'sha1hidden' => array(
874 ApiBase
::PROP_TYPE
=> 'boolean',
875 ApiBase
::PROP_NULLABLE
=> true
880 self
::addTokenProperties( $props, $this->getTokenFunctions() );
885 public function getDescription() {
886 return 'Enumerate recent changes.';
889 public function getPossibleErrors() {
890 return array_merge( parent
::getPossibleErrors(), array(
893 'code' => 'permissiondenied',
894 'info' => 'You need the patrol right to request the patrolled flag'
896 array( 'code' => 'user-excludeuser', 'info' => 'user and excludeuser cannot be used together' ),
900 public function getExamples() {
902 'api.php?action=query&list=recentchanges'
906 public function getHelpUrls() {
907 return 'https://www.mediawiki.org/wiki/API:Recentchanges';