5 * Created on Sep 7, 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 revisions of a given page, or show top revisions of multiple pages.
29 * Various pieces of information may be shown - flags, comments, and the actual wiki markup of the rev.
30 * In the enumeration mode, ranges of revisions may be requested and filtered.
34 class ApiQueryRevisions
extends ApiQueryBase
{
36 private $diffto, $difftotext, $expandTemplates, $generateXML, $section,
37 $token, $parseContent;
39 public function __construct( $query, $moduleName ) {
40 parent
::__construct( $query, $moduleName, 'rv' );
43 private $fld_ids = false, $fld_flags = false, $fld_timestamp = false, $fld_size = false,
44 $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
45 $fld_content = false, $fld_tags = false;
47 private $tokenFunctions;
49 protected function getTokenFunctions() {
50 // tokenname => function
51 // function prototype is func($pageid, $title, $rev)
52 // should return token or false
54 // Don't call the hooks twice
55 if ( isset( $this->tokenFunctions
) ) {
56 return $this->tokenFunctions
;
59 // If we're in JSON callback mode, no tokens can be obtained
60 if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
64 $this->tokenFunctions
= array(
65 'rollback' => array( 'ApiQueryRevisions', 'getRollbackToken' )
67 wfRunHooks( 'APIQueryRevisionsTokens', array( &$this->tokenFunctions
) );
68 return $this->tokenFunctions
;
74 * @param $rev Revision
77 public static function getRollbackToken( $pageid, $title, $rev ) {
79 if ( !$wgUser->isAllowed( 'rollback' ) ) {
82 return $wgUser->getEditToken(
83 array( $title->getPrefixedText(), $rev->getUserText() ) );
86 public function execute() {
87 $params = $this->extractRequestParams( false );
89 // If any of those parameters are used, work in 'enumeration' mode.
90 // Enum mode can only be used when exactly one page is provided.
91 // Enumerating revisions on multiple pages make it extremely
92 // difficult to manage continuations and require additional SQL indexes
93 $enumRevMode = ( !is_null( $params['user'] ) ||
!is_null( $params['excludeuser'] ) ||
94 !is_null( $params['limit'] ) ||
!is_null( $params['startid'] ) ||
95 !is_null( $params['endid'] ) ||
$params['dir'] === 'newer' ||
96 !is_null( $params['start'] ) ||
!is_null( $params['end'] ) );
99 $pageSet = $this->getPageSet();
100 $pageCount = $pageSet->getGoodTitleCount();
101 $revCount = $pageSet->getRevisionCount();
103 // Optimization -- nothing to do
104 if ( $revCount === 0 && $pageCount === 0 ) {
108 if ( $revCount > 0 && $enumRevMode ) {
109 $this->dieUsage( 'The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).', 'revids' );
112 if ( $pageCount > 1 && $enumRevMode ) {
113 $this->dieUsage( 'titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.', 'multpages' );
116 if ( !is_null( $params['difftotext'] ) ) {
117 $this->difftotext
= $params['difftotext'];
118 } elseif ( !is_null( $params['diffto'] ) ) {
119 if ( $params['diffto'] == 'cur' ) {
120 $params['diffto'] = 0;
122 if ( ( !ctype_digit( $params['diffto'] ) ||
$params['diffto'] < 0 )
123 && $params['diffto'] != 'prev' && $params['diffto'] != 'next' ) {
124 $this->dieUsage( 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"', 'diffto' );
126 // Check whether the revision exists and is readable,
127 // DifferenceEngine returns a rather ambiguous empty
128 // string if that's not the case
129 if ( $params['diffto'] != 0 ) {
130 $difftoRev = Revision
::newFromID( $params['diffto'] );
132 $this->dieUsageMsg( array( 'nosuchrevid', $params['diffto'] ) );
134 if ( $difftoRev->isDeleted( Revision
::DELETED_TEXT
) ) {
135 $this->setWarning( "Couldn't diff to r{$difftoRev->getID()}: content is hidden" );
136 $params['diffto'] = null;
139 $this->diffto
= $params['diffto'];
142 $db = $this->getDB();
143 $this->addTables( 'page' );
144 $this->addFields( Revision
::selectFields() );
145 $this->addWhere( 'page_id = rev_page' );
147 $prop = array_flip( $params['prop'] );
150 $this->fld_ids
= isset ( $prop['ids'] );
151 // $this->addFieldsIf('rev_text_id', $this->fld_ids); // should this be exposed?
152 $this->fld_flags
= isset ( $prop['flags'] );
153 $this->fld_timestamp
= isset ( $prop['timestamp'] );
154 $this->fld_comment
= isset ( $prop['comment'] );
155 $this->fld_parsedcomment
= isset ( $prop['parsedcomment'] );
156 $this->fld_size
= isset ( $prop['size'] );
157 $this->fld_sha1
= isset ( $prop['sha1'] );
158 $this->fld_userid
= isset( $prop['userid'] );
159 $this->fld_user
= isset ( $prop['user'] );
160 $this->token
= $params['token'];
162 // Possible indexes used
165 $userMax = ( $this->fld_content ? ApiBase
::LIMIT_SML1
: ApiBase
::LIMIT_BIG1
);
166 $botMax = ( $this->fld_content ? ApiBase
::LIMIT_SML2
: ApiBase
::LIMIT_BIG2
);
167 $limit = $params['limit'];
168 if ( $limit == 'max' ) {
169 $limit = $this->getMain()->canApiHighLimits() ?
$botMax : $userMax;
170 $this->getResult()->setParsedLimit( $this->getModuleName(), $limit );
173 if ( !is_null( $this->token
) ||
$pageCount > 0 ) {
174 $this->addFields( Revision
::selectPageFields() );
177 if ( isset( $prop['tags'] ) ) {
178 $this->fld_tags
= true;
179 $this->addTables( 'tag_summary' );
180 $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rev_id=ts_rev_id' ) ) ) );
181 $this->addFields( 'ts_tags' );
184 if ( !is_null( $params['tag'] ) ) {
185 $this->addTables( 'change_tag' );
186 $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rev_id=ct_rev_id' ) ) ) );
187 $this->addWhereFld( 'ct_tag' , $params['tag'] );
188 global $wgOldChangeTagsIndex;
189 $index['change_tag'] = $wgOldChangeTagsIndex ?
'ct_tag' : 'change_tag_tag_id';
192 if ( isset( $prop['content'] ) ||
!is_null( $this->difftotext
) ) {
193 // For each page we will request, the user must have read rights for that page
194 foreach ( $pageSet->getGoodTitles() as $title ) {
195 if ( !$title->userCan( 'read' ) ) {
197 'The current user is not allowed to read ' . $title->getPrefixedText(),
202 $this->addTables( 'text' );
203 $this->addWhere( 'rev_text_id=old_id' );
204 $this->addFields( 'old_id' );
205 $this->addFields( Revision
::selectTextFields() );
207 $this->fld_content
= isset( $prop['content'] );
209 $this->expandTemplates
= $params['expandtemplates'];
210 $this->generateXML
= $params['generatexml'];
211 $this->parseContent
= $params['parse'];
212 if ( $this->parseContent
) {
213 // Must manually initialize unset limit
214 if ( is_null( $limit ) ) {
217 // We are only going to parse 1 revision per request
218 $this->validateLimit( 'limit', $limit, 1, 1, 1 );
220 if ( isset( $params['section'] ) ) {
221 $this->section
= $params['section'];
223 $this->section
= false;
227 // add user name, if needed
228 if ( $this->fld_user
) {
229 $this->addTables( 'user' );
230 $this->addJoinConds( array( 'user' => Revision
::userJoinCond() ) );
231 $this->addFields( Revision
::selectUserFields() );
234 // Bug 24166 - API error when using rvprop=tags
235 $this->addTables( 'revision' );
237 if ( $enumRevMode ) {
238 // This is mostly to prevent parameter errors (and optimize SQL?)
239 if ( !is_null( $params['startid'] ) && !is_null( $params['start'] ) ) {
240 $this->dieUsage( 'start and startid cannot be used together', 'badparams' );
243 if ( !is_null( $params['endid'] ) && !is_null( $params['end'] ) ) {
244 $this->dieUsage( 'end and endid cannot be used together', 'badparams' );
247 if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) {
248 $this->dieUsage( 'user and excludeuser cannot be used together', 'badparams' );
251 // This code makes an assumption that sorting by rev_id and rev_timestamp produces
252 // the same result. This way users may request revisions starting at a given time,
253 // but to page through results use the rev_id returned after each page.
254 // Switching to rev_id removes the potential problem of having more than
255 // one row with the same timestamp for the same page.
256 // The order needs to be the same as start parameter to avoid SQL filesort.
257 if ( is_null( $params['startid'] ) && is_null( $params['endid'] ) ) {
258 $this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
259 $params['start'], $params['end'] );
261 $this->addWhereRange( 'rev_id', $params['dir'],
262 $params['startid'], $params['endid'] );
263 // One of start and end can be set
264 // If neither is set, this does nothing
265 $this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
266 $params['start'], $params['end'], false );
269 // must manually initialize unset limit
270 if ( is_null( $limit ) ) {
273 $this->validateLimit( 'limit', $limit, 1, $userMax, $botMax );
275 // There is only one ID, use it
276 $ids = array_keys( $pageSet->getGoodTitles() );
277 $this->addWhereFld( 'rev_page', reset( $ids ) );
279 if ( !is_null( $params['user'] ) ) {
280 $this->addWhereFld( 'rev_user_text', $params['user'] );
281 } elseif ( !is_null( $params['excludeuser'] ) ) {
282 $this->addWhere( 'rev_user_text != ' .
283 $db->addQuotes( $params['excludeuser'] ) );
285 if ( !is_null( $params['user'] ) ||
!is_null( $params['excludeuser'] ) ) {
286 // Paranoia: avoid brute force searches (bug 17342)
287 $this->addWhere( $db->bitAnd( 'rev_deleted', Revision
::DELETED_USER
) . ' = 0' );
289 } elseif ( $revCount > 0 ) {
290 $max = $this->getMain()->canApiHighLimits() ?
$botMax : $userMax;
291 $revs = $pageSet->getRevisionIDs();
292 if ( self
::truncateArray( $revs, $max ) ) {
293 $this->setWarning( "Too many values supplied for parameter 'revids': the limit is $max" );
296 // Get all revision IDs
297 $this->addWhereFld( 'rev_id', array_keys( $revs ) );
299 if ( !is_null( $params['continue'] ) ) {
300 $this->addWhere( 'rev_id >= ' . intval( $params['continue'] ) );
302 $this->addOption( 'ORDER BY', 'rev_id' );
304 // assumption testing -- we should never get more then $revCount rows.
306 } elseif ( $pageCount > 0 ) {
307 $max = $this->getMain()->canApiHighLimits() ?
$botMax : $userMax;
308 $titles = $pageSet->getGoodTitles();
309 if ( self
::truncateArray( $titles, $max ) ) {
310 $this->setWarning( "Too many values supplied for parameter 'titles': the limit is $max" );
313 // When working in multi-page non-enumeration mode,
314 // limit to the latest revision only
315 $this->addWhere( 'page_id=rev_page' );
316 $this->addWhere( 'page_latest=rev_id' );
319 $this->addWhereFld( 'page_id', array_keys( $titles ) );
320 // Every time someone relies on equality propagation, god kills a kitten :)
321 $this->addWhereFld( 'rev_page', array_keys( $titles ) );
323 if ( !is_null( $params['continue'] ) ) {
324 $cont = explode( '|', $params['continue'] );
325 if ( count( $cont ) != 2 ) {
326 $this->dieUsage( 'Invalid continue param. You should pass the original ' .
327 'value returned by the previous query', '_badcontinue' );
329 $pageid = intval( $cont[0] );
330 $revid = intval( $cont[1] );
332 "rev_page > $pageid OR " .
333 "(rev_page = $pageid AND " .
337 $this->addOption( 'ORDER BY', array(
342 // assumption testing -- we should never get more then $pageCount rows.
345 ApiBase
::dieDebug( __METHOD__
, 'param validation?' );
348 $this->addOption( 'LIMIT', $limit +
1 );
349 $this->addOption( 'USE INDEX', $index );
352 $res = $this->select( __METHOD__
);
354 foreach ( $res as $row ) {
355 if ( ++
$count > $limit ) {
356 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
357 if ( !$enumRevMode ) {
358 ApiBase
::dieDebug( __METHOD__
, 'Got more rows then expected' ); // bug report
360 $this->setContinueEnumParameter( 'startid', intval( $row->rev_id
) );
364 $fit = $this->addPageSubItem( $row->rev_page
, $this->extractRowInfo( $row ), 'rev' );
366 if ( $enumRevMode ) {
367 $this->setContinueEnumParameter( 'startid', intval( $row->rev_id
) );
368 } elseif ( $revCount > 0 ) {
369 $this->setContinueEnumParameter( 'continue', intval( $row->rev_id
) );
371 $this->setContinueEnumParameter( 'continue', intval( $row->rev_page
) .
372 '|' . intval( $row->rev_id
) );
379 private function extractRowInfo( $row ) {
380 $revision = new Revision( $row );
381 $title = $revision->getTitle();
384 if ( $this->fld_ids
) {
385 $vals['revid'] = intval( $revision->getId() );
386 // $vals['oldid'] = intval( $row->rev_text_id ); // todo: should this be exposed?
387 if ( !is_null( $revision->getParentId() ) ) {
388 $vals['parentid'] = intval( $revision->getParentId() );
392 if ( $this->fld_flags
&& $revision->isMinor() ) {
396 if ( $this->fld_user ||
$this->fld_userid
) {
397 if ( $revision->isDeleted( Revision
::DELETED_USER
) ) {
398 $vals['userhidden'] = '';
400 if ( $this->fld_user
) {
401 $vals['user'] = $revision->getUserText();
403 $userid = $revision->getUser();
408 if ( $this->fld_userid
) {
409 $vals['userid'] = $userid;
414 if ( $this->fld_timestamp
) {
415 $vals['timestamp'] = wfTimestamp( TS_ISO_8601
, $revision->getTimestamp() );
418 if ( $this->fld_size
) {
419 if ( !is_null( $revision->getSize() ) ) {
420 $vals['size'] = intval( $revision->getSize() );
426 if ( $this->fld_sha1
) {
427 if ( $revision->getSha1() != '' ) {
428 $vals['sha1'] = wfBaseConvert( $revision->getSha1(), 36, 16, 40 );
434 if ( $this->fld_comment ||
$this->fld_parsedcomment
) {
435 if ( $revision->isDeleted( Revision
::DELETED_COMMENT
) ) {
436 $vals['commenthidden'] = '';
438 $comment = $revision->getComment();
440 if ( $this->fld_comment
) {
441 $vals['comment'] = $comment;
444 if ( $this->fld_parsedcomment
) {
445 $vals['parsedcomment'] = Linker
::formatComment( $comment, $title );
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;
456 $vals['tags'] = array();
460 if ( !is_null( $this->token
) ) {
461 $tokenFunctions = $this->getTokenFunctions();
462 foreach ( $this->token
as $t ) {
463 $val = call_user_func( $tokenFunctions[$t], $title->getArticleID(), $title, $revision );
464 if ( $val === false ) {
465 $this->setWarning( "Action '$t' is not allowed for the current user" );
467 $vals[$t . 'token'] = $val;
474 if ( $this->fld_content ||
!is_null( $this->difftotext
) ) {
475 $text = $revision->getText();
476 // Expand templates after getting section content because
477 // template-added sections don't count and Parser::preprocess()
478 // will have less input
479 if ( $this->section
!== false ) {
480 $text = $wgParser->getSection( $text, $this->section
, false );
481 if ( $text === false ) {
482 $this->dieUsage( "There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection' );
486 if ( $this->fld_content
&& !$revision->isDeleted( Revision
::DELETED_TEXT
) ) {
487 if ( $this->generateXML
) {
488 $wgParser->startExternalParse( $title, ParserOptions
::newFromContext( $this->getContext() ), OT_PREPROCESS
);
489 $dom = $wgParser->preprocessToDom( $text );
490 if ( is_callable( array( $dom, 'saveXML' ) ) ) {
491 $xml = $dom->saveXML();
493 $xml = $dom->__toString();
495 $vals['parsetree'] = $xml;
498 if ( $this->expandTemplates
&& !$this->parseContent
) {
499 $text = $wgParser->preprocess( $text, $title, ParserOptions
::newFromContext( $this->getContext() ) );
501 if ( $this->parseContent
) {
502 $text = $wgParser->parse( $text, $title, ParserOptions
::newFromContext( $this->getContext() ) )->getText();
504 ApiResult
::setContent( $vals, $text );
505 } elseif ( $this->fld_content
) {
506 $vals['texthidden'] = '';
509 if ( !is_null( $this->diffto
) ||
!is_null( $this->difftotext
) ) {
510 global $wgAPIMaxUncachedDiffs;
511 static $n = 0; // Number of uncached diffs we've had
512 if ( $n < $wgAPIMaxUncachedDiffs ) {
513 $vals['diff'] = array();
514 $context = new DerivativeContext( $this->getContext() );
515 $context->setTitle( $title );
516 if ( !is_null( $this->difftotext
) ) {
517 $engine = new DifferenceEngine( $context );
518 $engine->setText( $text, $this->difftotext
);
520 $engine = new DifferenceEngine( $context, $revision->getID(), $this->diffto
);
521 $vals['diff']['from'] = $engine->getOldid();
522 $vals['diff']['to'] = $engine->getNewid();
524 $difftext = $engine->getDiffBody();
525 ApiResult
::setContent( $vals['diff'], $difftext );
526 if ( !$engine->wasCacheHit() ) {
530 $vals['diff']['notcached'] = '';
536 public function getCacheMode( $params ) {
537 if ( isset( $params['token'] ) ) {
540 if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
541 // formatComment() calls wfMsg() among other things
542 return 'anon-public-user-private';
547 public function getAllowedParams() {
550 ApiBase
::PARAM_ISMULTI
=> true,
551 ApiBase
::PARAM_DFLT
=> 'ids|timestamp|flags|comment|user',
552 ApiBase
::PARAM_TYPE
=> array(
567 ApiBase
::PARAM_TYPE
=> 'limit',
568 ApiBase
::PARAM_MIN
=> 1,
569 ApiBase
::PARAM_MAX
=> ApiBase
::LIMIT_BIG1
,
570 ApiBase
::PARAM_MAX2
=> ApiBase
::LIMIT_BIG2
573 ApiBase
::PARAM_TYPE
=> 'integer'
576 ApiBase
::PARAM_TYPE
=> 'integer'
579 ApiBase
::PARAM_TYPE
=> 'timestamp'
582 ApiBase
::PARAM_TYPE
=> 'timestamp'
585 ApiBase
::PARAM_DFLT
=> 'older',
586 ApiBase
::PARAM_TYPE
=> array(
592 ApiBase
::PARAM_TYPE
=> 'user'
594 'excludeuser' => array(
595 ApiBase
::PARAM_TYPE
=> 'user'
598 'expandtemplates' => false,
599 'generatexml' => false,
603 ApiBase
::PARAM_TYPE
=> array_keys( $this->getTokenFunctions() ),
604 ApiBase
::PARAM_ISMULTI
=> true
608 'difftotext' => null,
612 public function getParamDescription() {
613 $p = $this->getModulePrefix();
616 'Which properties to get for each revision:',
617 ' ids - The ID of the revision',
618 ' flags - Revision flags (minor)',
619 ' timestamp - The timestamp of the revision',
620 ' user - User that made the revision',
621 ' userid - User id of revision creator',
622 ' size - Length (bytes) of the revision',
623 ' sha1 - SHA-1 (base 16) of the revision',
624 ' comment - Comment by the user for revision',
625 ' parsedcomment - Parsed comment by the user for the revision',
626 ' content - Text of the revision',
627 ' tags - Tags for the revision',
629 'limit' => 'Limit how many revisions will be returned (enum)',
630 'startid' => 'From which revision id to start enumeration (enum)',
631 'endid' => 'Stop revision enumeration on this revid (enum)',
632 'start' => 'From which revision timestamp to start enumeration (enum)',
633 'end' => 'Enumerate up to this timestamp (enum)',
634 'dir' => $this->getDirectionDescription( $p, ' (enum)' ),
635 'user' => 'Only include revisions made by user (enum)',
636 'excludeuser' => 'Exclude revisions made by user (enum)',
637 'expandtemplates' => 'Expand templates in revision content',
638 'generatexml' => 'Generate XML parse tree for revision content',
639 'parse' => 'Parse revision content. For performance reasons if this option is used, rvlimit is enforced to 1.',
640 'section' => 'Only retrieve the content of this section number',
641 'token' => 'Which tokens to obtain for each revision',
642 'continue' => 'When more results are available, use this to continue',
643 'diffto' => array( 'Revision ID to diff each revision to.',
644 'Use "prev", "next" and "cur" for the previous, next and current revision respectively' ),
645 'difftotext' => array( 'Text to diff each revision to. Only diffs a limited number of revisions.',
646 "Overrides {$p}diffto. If {$p}section is set, only that section will be diffed against this text" ),
647 'tag' => 'Only list revisions tagged with this tag',
651 public function getResultProperties() {
655 'revid' => 'integer',
657 ApiBase
::PROP_TYPE
=> 'integer',
658 ApiBase
::PROP_NULLABLE
=> true
665 'userhidden' => 'boolean',
670 'userhidden' => 'boolean',
671 'userid' => 'integer',
674 'timestamp' => array(
675 'timestamp' => 'timestamp'
684 'commenthidden' => 'boolean',
686 ApiBase
::PROP_TYPE
=> 'string',
687 ApiBase
::PROP_NULLABLE
=> true
690 'parsedcomment' => array(
691 'commenthidden' => 'boolean',
692 'parsedcomment' => array(
693 ApiBase
::PROP_TYPE
=> 'string',
694 ApiBase
::PROP_NULLABLE
=> true
699 ApiBase
::PROP_TYPE
=> 'string',
700 ApiBase
::PROP_NULLABLE
=> true
702 'texthidden' => 'boolean'
706 self
::addTokenProperties( $props, $this->getTokenFunctions() );
711 public function getDescription() {
713 'Get revision information',
714 'May be used in several ways:',
715 ' 1) Get data about a set of pages (last revision), by setting titles or pageids parameter',
716 ' 2) Get revisions for one given page, by using titles/pageids with start/end/limit params',
717 ' 3) Get data about a set of revisions by setting their IDs with revids parameter',
718 'All parameters marked as (enum) may only be used with a single page (#2)'
722 public function getPossibleErrors() {
723 return array_merge( parent
::getPossibleErrors(), array(
724 array( 'nosuchrevid', 'diffto' ),
725 array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).' ),
726 array( 'code' => 'multpages', 'info' => 'titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.' ),
727 array( 'code' => 'diffto', 'info' => 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"' ),
728 array( 'code' => 'badparams', 'info' => 'start and startid cannot be used together' ),
729 array( 'code' => 'badparams', 'info' => 'end and endid cannot be used together' ),
730 array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ),
731 array( 'code' => 'nosuchsection', 'info' => 'There is no section section in rID' ),
735 public function getExamples() {
737 'Get data with content for the last revision of titles "API" and "Main Page"',
738 ' api.php?action=query&prop=revisions&titles=API|Main%20Page&rvprop=timestamp|user|comment|content',
739 'Get last 5 revisions of the "Main Page"',
740 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment',
741 'Get first 5 revisions of the "Main Page"',
742 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer',
743 'Get first 5 revisions of the "Main Page" made after 2006-05-01',
744 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer&rvstart=20060501000000',
745 'Get first 5 revisions of the "Main Page" that were not made made by anonymous user "127.0.0.1"',
746 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvexcludeuser=127.0.0.1',
747 'Get first 5 revisions of the "Main Page" that were made by the user "MediaWiki default"',
748 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvuser=MediaWiki%20default',
752 public function getHelpUrls() {
753 return 'https://www.mediawiki.org/wiki/API:Properties#revisions_.2F_rv';
756 public function getVersion() {
757 return __CLASS__
. ': $Id$';