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 $user = $this->getUser();
195 foreach ( $pageSet->getGoodTitles() as $title ) {
196 if ( !$title->userCan( 'read', $user ) ) {
198 'The current user is not allowed to read ' . $title->getPrefixedText(),
203 $this->addTables( 'text' );
204 $this->addWhere( 'rev_text_id=old_id' );
205 $this->addFields( 'old_id' );
206 $this->addFields( Revision
::selectTextFields() );
208 $this->fld_content
= isset( $prop['content'] );
210 $this->expandTemplates
= $params['expandtemplates'];
211 $this->generateXML
= $params['generatexml'];
212 $this->parseContent
= $params['parse'];
213 if ( $this->parseContent
) {
214 // Must manually initialize unset limit
215 if ( is_null( $limit ) ) {
218 // We are only going to parse 1 revision per request
219 $this->validateLimit( 'limit', $limit, 1, 1, 1 );
221 if ( isset( $params['section'] ) ) {
222 $this->section
= $params['section'];
224 $this->section
= false;
228 // add user name, if needed
229 if ( $this->fld_user
) {
230 $this->addTables( 'user' );
231 $this->addJoinConds( array( 'user' => Revision
::userJoinCond() ) );
232 $this->addFields( Revision
::selectUserFields() );
235 // Bug 24166 - API error when using rvprop=tags
236 $this->addTables( 'revision' );
238 if ( $enumRevMode ) {
239 // This is mostly to prevent parameter errors (and optimize SQL?)
240 if ( !is_null( $params['startid'] ) && !is_null( $params['start'] ) ) {
241 $this->dieUsage( 'start and startid cannot be used together', 'badparams' );
244 if ( !is_null( $params['endid'] ) && !is_null( $params['end'] ) ) {
245 $this->dieUsage( 'end and endid cannot be used together', 'badparams' );
248 if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) {
249 $this->dieUsage( 'user and excludeuser cannot be used together', 'badparams' );
252 // Continuing effectively uses startid. But we can't use rvstartid
253 // directly, because there is no way to tell the client to ''not''
254 // send rvstart if it sent it in the original query. So instead we
255 // send the continuation startid as rvcontinue, and ignore both
256 // rvstart and rvstartid when that is supplied.
257 if ( !is_null( $params['continue'] ) ) {
258 $params['startid'] = $params['continue'];
259 unset( $params['start'] );
262 // This code makes an assumption that sorting by rev_id and rev_timestamp produces
263 // the same result. This way users may request revisions starting at a given time,
264 // but to page through results use the rev_id returned after each page.
265 // Switching to rev_id removes the potential problem of having more than
266 // one row with the same timestamp for the same page.
267 // The order needs to be the same as start parameter to avoid SQL filesort.
268 if ( is_null( $params['startid'] ) && is_null( $params['endid'] ) ) {
269 $this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
270 $params['start'], $params['end'] );
272 $this->addWhereRange( 'rev_id', $params['dir'],
273 $params['startid'], $params['endid'] );
274 // One of start and end can be set
275 // If neither is set, this does nothing
276 $this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
277 $params['start'], $params['end'], false );
280 // must manually initialize unset limit
281 if ( is_null( $limit ) ) {
284 $this->validateLimit( 'limit', $limit, 1, $userMax, $botMax );
286 // There is only one ID, use it
287 $ids = array_keys( $pageSet->getGoodTitles() );
288 $this->addWhereFld( 'rev_page', reset( $ids ) );
290 if ( !is_null( $params['user'] ) ) {
291 $this->addWhereFld( 'rev_user_text', $params['user'] );
292 } elseif ( !is_null( $params['excludeuser'] ) ) {
293 $this->addWhere( 'rev_user_text != ' .
294 $db->addQuotes( $params['excludeuser'] ) );
296 if ( !is_null( $params['user'] ) ||
!is_null( $params['excludeuser'] ) ) {
297 // Paranoia: avoid brute force searches (bug 17342)
298 $this->addWhere( $db->bitAnd( 'rev_deleted', Revision
::DELETED_USER
) . ' = 0' );
300 } elseif ( $revCount > 0 ) {
301 $max = $this->getMain()->canApiHighLimits() ?
$botMax : $userMax;
302 $revs = $pageSet->getRevisionIDs();
303 if ( self
::truncateArray( $revs, $max ) ) {
304 $this->setWarning( "Too many values supplied for parameter 'revids': the limit is $max" );
307 // Get all revision IDs
308 $this->addWhereFld( 'rev_id', array_keys( $revs ) );
310 if ( !is_null( $params['continue'] ) ) {
311 $this->addWhere( 'rev_id >= ' . intval( $params['continue'] ) );
313 $this->addOption( 'ORDER BY', 'rev_id' );
315 // assumption testing -- we should never get more then $revCount rows.
317 } elseif ( $pageCount > 0 ) {
318 $max = $this->getMain()->canApiHighLimits() ?
$botMax : $userMax;
319 $titles = $pageSet->getGoodTitles();
320 if ( self
::truncateArray( $titles, $max ) ) {
321 $this->setWarning( "Too many values supplied for parameter 'titles': the limit is $max" );
324 // When working in multi-page non-enumeration mode,
325 // limit to the latest revision only
326 $this->addWhere( 'page_id=rev_page' );
327 $this->addWhere( 'page_latest=rev_id' );
330 $this->addWhereFld( 'page_id', array_keys( $titles ) );
331 // Every time someone relies on equality propagation, god kills a kitten :)
332 $this->addWhereFld( 'rev_page', array_keys( $titles ) );
334 if ( !is_null( $params['continue'] ) ) {
335 $cont = explode( '|', $params['continue'] );
336 if ( count( $cont ) != 2 ) {
337 $this->dieUsage( 'Invalid continue param. You should pass the original ' .
338 'value returned by the previous query', '_badcontinue' );
340 $pageid = intval( $cont[0] );
341 $revid = intval( $cont[1] );
343 "rev_page > $pageid OR " .
344 "(rev_page = $pageid AND " .
348 $this->addOption( 'ORDER BY', array(
353 // assumption testing -- we should never get more then $pageCount rows.
356 ApiBase
::dieDebug( __METHOD__
, 'param validation?' );
359 $this->addOption( 'LIMIT', $limit +
1 );
360 $this->addOption( 'USE INDEX', $index );
363 $res = $this->select( __METHOD__
);
365 foreach ( $res as $row ) {
366 if ( ++
$count > $limit ) {
367 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
368 if ( !$enumRevMode ) {
369 ApiBase
::dieDebug( __METHOD__
, 'Got more rows then expected' ); // bug report
371 $this->setContinueEnumParameter( 'continue', intval( $row->rev_id
) );
375 $fit = $this->addPageSubItem( $row->rev_page
, $this->extractRowInfo( $row ), 'rev' );
377 if ( $enumRevMode ) {
378 $this->setContinueEnumParameter( 'continue', intval( $row->rev_id
) );
379 } elseif ( $revCount > 0 ) {
380 $this->setContinueEnumParameter( 'continue', intval( $row->rev_id
) );
382 $this->setContinueEnumParameter( 'continue', intval( $row->rev_page
) .
383 '|' . intval( $row->rev_id
) );
390 private function extractRowInfo( $row ) {
391 $revision = new Revision( $row );
392 $title = $revision->getTitle();
395 if ( $this->fld_ids
) {
396 $vals['revid'] = intval( $revision->getId() );
397 // $vals['oldid'] = intval( $row->rev_text_id ); // todo: should this be exposed?
398 if ( !is_null( $revision->getParentId() ) ) {
399 $vals['parentid'] = intval( $revision->getParentId() );
403 if ( $this->fld_flags
&& $revision->isMinor() ) {
407 if ( $this->fld_user ||
$this->fld_userid
) {
408 if ( $revision->isDeleted( Revision
::DELETED_USER
) ) {
409 $vals['userhidden'] = '';
411 if ( $this->fld_user
) {
412 $vals['user'] = $revision->getUserText();
414 $userid = $revision->getUser();
419 if ( $this->fld_userid
) {
420 $vals['userid'] = $userid;
425 if ( $this->fld_timestamp
) {
426 $vals['timestamp'] = wfTimestamp( TS_ISO_8601
, $revision->getTimestamp() );
429 if ( $this->fld_size
) {
430 if ( !is_null( $revision->getSize() ) ) {
431 $vals['size'] = intval( $revision->getSize() );
437 if ( $this->fld_sha1
) {
438 if ( $revision->getSha1() != '' ) {
439 $vals['sha1'] = wfBaseConvert( $revision->getSha1(), 36, 16, 40 );
445 if ( $this->fld_comment ||
$this->fld_parsedcomment
) {
446 if ( $revision->isDeleted( Revision
::DELETED_COMMENT
) ) {
447 $vals['commenthidden'] = '';
449 $comment = $revision->getComment();
451 if ( $this->fld_comment
) {
452 $vals['comment'] = $comment;
455 if ( $this->fld_parsedcomment
) {
456 $vals['parsedcomment'] = Linker
::formatComment( $comment, $title );
461 if ( $this->fld_tags
) {
462 if ( $row->ts_tags
) {
463 $tags = explode( ',', $row->ts_tags
);
464 $this->getResult()->setIndexedTagName( $tags, 'tag' );
465 $vals['tags'] = $tags;
467 $vals['tags'] = array();
471 if ( !is_null( $this->token
) ) {
472 $tokenFunctions = $this->getTokenFunctions();
473 foreach ( $this->token
as $t ) {
474 $val = call_user_func( $tokenFunctions[$t], $title->getArticleID(), $title, $revision );
475 if ( $val === false ) {
476 $this->setWarning( "Action '$t' is not allowed for the current user" );
478 $vals[$t . 'token'] = $val;
485 if ( $this->fld_content ||
!is_null( $this->difftotext
) ) {
486 $text = $revision->getText();
487 // Expand templates after getting section content because
488 // template-added sections don't count and Parser::preprocess()
489 // will have less input
490 if ( $this->section
!== false ) {
491 $text = $wgParser->getSection( $text, $this->section
, false );
492 if ( $text === false ) {
493 $this->dieUsage( "There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection' );
497 if ( $this->fld_content
&& !$revision->isDeleted( Revision
::DELETED_TEXT
) ) {
498 if ( $this->generateXML
) {
499 $wgParser->startExternalParse( $title, ParserOptions
::newFromContext( $this->getContext() ), OT_PREPROCESS
);
500 $dom = $wgParser->preprocessToDom( $text );
501 if ( is_callable( array( $dom, 'saveXML' ) ) ) {
502 $xml = $dom->saveXML();
504 $xml = $dom->__toString();
506 $vals['parsetree'] = $xml;
509 if ( $this->expandTemplates
&& !$this->parseContent
) {
510 $text = $wgParser->preprocess( $text, $title, ParserOptions
::newFromContext( $this->getContext() ) );
512 if ( $this->parseContent
) {
513 $text = $wgParser->parse( $text, $title, ParserOptions
::newFromContext( $this->getContext() ) )->getText();
515 ApiResult
::setContent( $vals, $text );
516 } elseif ( $this->fld_content
) {
517 $vals['texthidden'] = '';
520 if ( !is_null( $this->diffto
) ||
!is_null( $this->difftotext
) ) {
521 global $wgAPIMaxUncachedDiffs;
522 static $n = 0; // Number of uncached diffs we've had
523 if ( $n < $wgAPIMaxUncachedDiffs ) {
524 $vals['diff'] = array();
525 $context = new DerivativeContext( $this->getContext() );
526 $context->setTitle( $title );
527 if ( !is_null( $this->difftotext
) ) {
528 $engine = new DifferenceEngine( $context );
529 $engine->setText( $text, $this->difftotext
);
531 $engine = new DifferenceEngine( $context, $revision->getID(), $this->diffto
);
532 $vals['diff']['from'] = $engine->getOldid();
533 $vals['diff']['to'] = $engine->getNewid();
535 $difftext = $engine->getDiffBody();
536 ApiResult
::setContent( $vals['diff'], $difftext );
537 if ( !$engine->wasCacheHit() ) {
541 $vals['diff']['notcached'] = '';
547 public function getCacheMode( $params ) {
548 if ( isset( $params['token'] ) ) {
551 if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
552 // formatComment() calls wfMessage() among other things
553 return 'anon-public-user-private';
558 public function getAllowedParams() {
561 ApiBase
::PARAM_ISMULTI
=> true,
562 ApiBase
::PARAM_DFLT
=> 'ids|timestamp|flags|comment|user',
563 ApiBase
::PARAM_TYPE
=> array(
578 ApiBase
::PARAM_TYPE
=> 'limit',
579 ApiBase
::PARAM_MIN
=> 1,
580 ApiBase
::PARAM_MAX
=> ApiBase
::LIMIT_BIG1
,
581 ApiBase
::PARAM_MAX2
=> ApiBase
::LIMIT_BIG2
584 ApiBase
::PARAM_TYPE
=> 'integer'
587 ApiBase
::PARAM_TYPE
=> 'integer'
590 ApiBase
::PARAM_TYPE
=> 'timestamp'
593 ApiBase
::PARAM_TYPE
=> 'timestamp'
596 ApiBase
::PARAM_DFLT
=> 'older',
597 ApiBase
::PARAM_TYPE
=> array(
603 ApiBase
::PARAM_TYPE
=> 'user'
605 'excludeuser' => array(
606 ApiBase
::PARAM_TYPE
=> 'user'
609 'expandtemplates' => false,
610 'generatexml' => false,
614 ApiBase
::PARAM_TYPE
=> array_keys( $this->getTokenFunctions() ),
615 ApiBase
::PARAM_ISMULTI
=> true
619 'difftotext' => null,
623 public function getParamDescription() {
624 $p = $this->getModulePrefix();
627 'Which properties to get for each revision:',
628 ' ids - The ID of the revision',
629 ' flags - Revision flags (minor)',
630 ' timestamp - The timestamp of the revision',
631 ' user - User that made the revision',
632 ' userid - User id of revision creator',
633 ' size - Length (bytes) of the revision',
634 ' sha1 - SHA-1 (base 16) of the revision',
635 ' comment - Comment by the user for revision',
636 ' parsedcomment - Parsed comment by the user for the revision',
637 ' content - Text of the revision',
638 ' tags - Tags for the revision',
640 'limit' => 'Limit how many revisions will be returned (enum)',
641 'startid' => 'From which revision id to start enumeration (enum)',
642 'endid' => 'Stop revision enumeration on this revid (enum)',
643 'start' => 'From which revision timestamp to start enumeration (enum)',
644 'end' => 'Enumerate up to this timestamp (enum)',
645 'dir' => $this->getDirectionDescription( $p, ' (enum)' ),
646 'user' => 'Only include revisions made by user (enum)',
647 'excludeuser' => 'Exclude revisions made by user (enum)',
648 'expandtemplates' => 'Expand templates in revision content',
649 'generatexml' => 'Generate XML parse tree for revision content',
650 'parse' => 'Parse revision content. For performance reasons if this option is used, rvlimit is enforced to 1.',
651 'section' => 'Only retrieve the content of this section number',
652 'token' => 'Which tokens to obtain for each revision',
653 'continue' => 'When more results are available, use this to continue',
654 'diffto' => array( 'Revision ID to diff each revision to.',
655 'Use "prev", "next" and "cur" for the previous, next and current revision respectively' ),
656 'difftotext' => array( 'Text to diff each revision to. Only diffs a limited number of revisions.',
657 "Overrides {$p}diffto. If {$p}section is set, only that section will be diffed against this text" ),
658 'tag' => 'Only list revisions tagged with this tag',
662 public function getResultProperties() {
666 'revid' => 'integer',
668 ApiBase
::PROP_TYPE
=> 'integer',
669 ApiBase
::PROP_NULLABLE
=> true
676 'userhidden' => 'boolean',
681 'userhidden' => 'boolean',
682 'userid' => 'integer',
685 'timestamp' => array(
686 'timestamp' => 'timestamp'
695 'commenthidden' => 'boolean',
697 ApiBase
::PROP_TYPE
=> 'string',
698 ApiBase
::PROP_NULLABLE
=> true
701 'parsedcomment' => array(
702 'commenthidden' => 'boolean',
703 'parsedcomment' => array(
704 ApiBase
::PROP_TYPE
=> 'string',
705 ApiBase
::PROP_NULLABLE
=> true
710 ApiBase
::PROP_TYPE
=> 'string',
711 ApiBase
::PROP_NULLABLE
=> true
713 'texthidden' => 'boolean'
717 self
::addTokenProperties( $props, $this->getTokenFunctions() );
722 public function getDescription() {
724 'Get revision information',
725 'May be used in several ways:',
726 ' 1) Get data about a set of pages (last revision), by setting titles or pageids parameter',
727 ' 2) Get revisions for one given page, by using titles/pageids with start/end/limit params',
728 ' 3) Get data about a set of revisions by setting their IDs with revids parameter',
729 'All parameters marked as (enum) may only be used with a single page (#2)'
733 public function getPossibleErrors() {
734 return array_merge( parent
::getPossibleErrors(), array(
735 array( 'nosuchrevid', 'diffto' ),
736 array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).' ),
737 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.' ),
738 array( 'code' => 'diffto', 'info' => 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"' ),
739 array( 'code' => 'badparams', 'info' => 'start and startid cannot be used together' ),
740 array( 'code' => 'badparams', 'info' => 'end and endid cannot be used together' ),
741 array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ),
742 array( 'code' => 'nosuchsection', 'info' => 'There is no section section in rID' ),
746 public function getExamples() {
748 'Get data with content for the last revision of titles "API" and "Main Page"',
749 ' api.php?action=query&prop=revisions&titles=API|Main%20Page&rvprop=timestamp|user|comment|content',
750 'Get last 5 revisions of the "Main Page"',
751 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment',
752 'Get first 5 revisions of the "Main Page"',
753 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer',
754 'Get first 5 revisions of the "Main Page" made after 2006-05-01',
755 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer&rvstart=20060501000000',
756 'Get first 5 revisions of the "Main Page" that were not made made by anonymous user "127.0.0.1"',
757 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvexcludeuser=127.0.0.1',
758 'Get first 5 revisions of the "Main Page" that were made by the user "MediaWiki default"',
759 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvuser=MediaWiki%20default',
763 public function getHelpUrls() {
764 return 'https://www.mediawiki.org/wiki/API:Properties#revisions_.2F_rv';
767 public function getVersion() {
768 return __CLASS__
. ': $Id$';