Correct the address of the FSF in some of the GPL headers
[lhc/web/wiklou.git] / includes / api / ApiQueryRevisions.php
1 <?php
2
3 /**
4 * Created on Sep 7, 2006
5 *
6 * API for MediaWiki 1.8+
7 *
8 * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * http://www.gnu.org/copyleft/gpl.html
24 */
25
26 if ( !defined( 'MEDIAWIKI' ) ) {
27 // Eclipse helper - will be ignored in production
28 require_once( 'ApiQueryBase.php' );
29 }
30
31 /**
32 * A query action to enumerate revisions of a given page, or show top revisions of multiple pages.
33 * Various pieces of information may be shown - flags, comments, and the actual wiki markup of the rev.
34 * In the enumeration mode, ranges of revisions may be requested and filtered.
35 *
36 * @ingroup API
37 */
38 class ApiQueryRevisions extends ApiQueryBase {
39
40 public function __construct( $query, $moduleName ) {
41 parent::__construct( $query, $moduleName, 'rv' );
42 }
43
44 private $fld_ids = false, $fld_flags = false, $fld_timestamp = false, $fld_size = false,
45 $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_content = false, $fld_tags = false;
46
47 protected function getTokenFunctions() {
48 // tokenname => function
49 // function prototype is func($pageid, $title, $rev)
50 // should return token or false
51
52 // Don't call the hooks twice
53 if ( isset( $this->tokenFunctions ) ) {
54 return $this->tokenFunctions;
55 }
56
57 // If we're in JSON callback mode, no tokens can be obtained
58 if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
59 return array();
60 }
61
62 $this->tokenFunctions = array(
63 'rollback' => array( 'ApiQueryRevisions', 'getRollbackToken' )
64 );
65 wfRunHooks( 'APIQueryRevisionsTokens', array( &$this->tokenFunctions ) );
66 return $this->tokenFunctions;
67 }
68
69 public static function getRollbackToken( $pageid, $title, $rev ) {
70 global $wgUser;
71 if ( !$wgUser->isAllowed( 'rollback' ) ) {
72 return false;
73 }
74 return $wgUser->editToken( array( $title->getPrefixedText(),
75 $rev->getUserText() ) );
76 }
77
78 public function execute() {
79 $params = $this->extractRequestParams( false );
80
81 // If any of those parameters are used, work in 'enumeration' mode.
82 // Enum mode can only be used when exactly one page is provided.
83 // Enumerating revisions on multiple pages make it extremely
84 // difficult to manage continuations and require additional SQL indexes
85 $enumRevMode = ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ||
86 !is_null( $params['limit'] ) || !is_null( $params['startid'] ) ||
87 !is_null( $params['endid'] ) || $params['dir'] === 'newer' ||
88 !is_null( $params['start'] ) || !is_null( $params['end'] ) );
89
90
91 $pageSet = $this->getPageSet();
92 $pageCount = $pageSet->getGoodTitleCount();
93 $revCount = $pageSet->getRevisionCount();
94
95 // Optimization -- nothing to do
96 if ( $revCount === 0 && $pageCount === 0 ) {
97 return;
98 }
99
100 if ( $revCount > 0 && $enumRevMode ) {
101 $this->dieUsage( 'The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).', 'revids' );
102 }
103
104 if ( $pageCount > 1 && $enumRevMode ) {
105 $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' );
106 }
107
108 $this->diffto = $this->difftotext = null;
109 if ( !is_null( $params['difftotext'] ) ) {
110 $this->difftotext = $params['difftotext'];
111 } elseif ( !is_null( $params['diffto'] ) ) {
112 if ( $params['diffto'] == 'cur' ) {
113 $params['diffto'] = 0;
114 }
115 if ( ( !ctype_digit( $params['diffto'] ) || $params['diffto'] < 0 )
116 && $params['diffto'] != 'prev' && $params['diffto'] != 'next' )
117 {
118 $this->dieUsage( 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"', 'diffto' );
119 }
120 // Check whether the revision exists and is readable,
121 // DifferenceEngine returns a rather ambiguous empty
122 // string if that's not the case
123 if ( $params['diffto'] != 0 ) {
124 $difftoRev = Revision::newFromID( $params['diffto'] );
125 if ( !$difftoRev ) {
126 $this->dieUsageMsg( array( 'nosuchrevid', $params['diffto'] ) );
127 }
128 if ( !$difftoRev->userCan( Revision::DELETED_TEXT ) ) {
129 $this->setWarning( "Couldn't diff to r{$difftoRev->getID()}: content is hidden" );
130 $params['diffto'] = null;
131 }
132 }
133 $this->diffto = $params['diffto'];
134 }
135
136 $db = $this->getDB();
137 $this->addTables( array( 'page', 'revision' ) );
138 $this->addFields( Revision::selectFields() );
139 $this->addWhere( 'page_id = rev_page' );
140
141 $prop = array_flip( $params['prop'] );
142
143 // Optional fields
144 $this->fld_ids = isset ( $prop['ids'] );
145 // $this->addFieldsIf('rev_text_id', $this->fld_ids); // should this be exposed?
146 $this->fld_flags = isset ( $prop['flags'] );
147 $this->fld_timestamp = isset ( $prop['timestamp'] );
148 $this->fld_comment = isset ( $prop['comment'] );
149 $this->fld_parsedcomment = isset ( $prop['parsedcomment'] );
150 $this->fld_size = isset ( $prop['size'] );
151 $this->fld_user = isset ( $prop['user'] );
152 $this->token = $params['token'];
153
154 // Possible indexes used
155 $index = array();
156
157 if ( !is_null( $this->token ) || $pageCount > 0 ) {
158 $this->addFields( Revision::selectPageFields() );
159 }
160
161 if ( isset( $prop['tags'] ) ) {
162 $this->fld_tags = true;
163 $this->addTables( 'tag_summary' );
164 $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rev_id=ts_rev_id' ) ) ) );
165 $this->addFields( 'ts_tags' );
166 }
167
168 if ( !is_null( $params['tag'] ) ) {
169 $this->addTables( 'change_tag' );
170 $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rev_id=ct_rev_id' ) ) ) );
171 $this->addWhereFld( 'ct_tag' , $params['tag'] );
172 global $wgOldChangeTagsIndex;
173 $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
174 }
175
176 if ( isset( $prop['content'] ) || !is_null( $this->difftotext ) ) {
177 // For each page we will request, the user must have read rights for that page
178 foreach ( $pageSet->getGoodTitles() as $title ) {
179 if ( !$title->userCanRead() ) {
180 $this->dieUsage(
181 'The current user is not allowed to read ' . $title->getPrefixedText(),
182 'accessdenied' );
183 }
184 }
185
186 $this->addTables( 'text' );
187 $this->addWhere( 'rev_text_id=old_id' );
188 $this->addFields( 'old_id' );
189 $this->addFields( Revision::selectTextFields() );
190
191 $this->fld_content = isset( $prop['content'] );
192
193 $this->expandTemplates = $params['expandtemplates'];
194 $this->generateXML = $params['generatexml'];
195 if ( isset( $params['section'] ) ) {
196 $this->section = $params['section'];
197 } else {
198 $this->section = false;
199 }
200 }
201
202 $userMax = ( $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1 );
203 $botMax = ( $this->fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2 );
204 $limit = $params['limit'];
205 if ( $limit == 'max' ) {
206 $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
207 $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit );
208 }
209
210 if ( $enumRevMode ) {
211 // This is mostly to prevent parameter errors (and optimize SQL?)
212 if ( !is_null( $params['startid'] ) && !is_null( $params['start'] ) ) {
213 $this->dieUsage( 'start and startid cannot be used together', 'badparams' );
214 }
215
216 if ( !is_null( $params['endid'] ) && !is_null( $params['end'] ) ) {
217 $this->dieUsage( 'end and endid cannot be used together', 'badparams' );
218 }
219
220 if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) {
221 $this->dieUsage( 'user and excludeuser cannot be used together', 'badparams' );
222 }
223
224 // This code makes an assumption that sorting by rev_id and rev_timestamp produces
225 // the same result. This way users may request revisions starting at a given time,
226 // but to page through results use the rev_id returned after each page.
227 // Switching to rev_id removes the potential problem of having more than
228 // one row with the same timestamp for the same page.
229 // The order needs to be the same as start parameter to avoid SQL filesort.
230 if ( is_null( $params['startid'] ) && is_null( $params['endid'] ) ) {
231 $this->addWhereRange( 'rev_timestamp', $params['dir'],
232 $params['start'], $params['end'] );
233 } else {
234 $this->addWhereRange( 'rev_id', $params['dir'],
235 $params['startid'], $params['endid'] );
236 // One of start and end can be set
237 // If neither is set, this does nothing
238 $this->addWhereRange( 'rev_timestamp', $params['dir'],
239 $params['start'], $params['end'], false );
240 }
241
242 // must manually initialize unset limit
243 if ( is_null( $limit ) ) {
244 $limit = 10;
245 }
246 $this->validateLimit( 'limit', $limit, 1, $userMax, $botMax );
247
248 // There is only one ID, use it
249 $ids = array_keys( $pageSet->getGoodTitles() );
250 $this->addWhereFld( 'rev_page', reset( $ids ) );
251
252 if ( !is_null( $params['user'] ) ) {
253 $this->addWhereFld( 'rev_user_text', $params['user'] );
254 } elseif ( !is_null( $params['excludeuser'] ) ) {
255 $this->addWhere( 'rev_user_text != ' .
256 $db->addQuotes( $params['excludeuser'] ) );
257 }
258 if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
259 // Paranoia: avoid brute force searches (bug 17342)
260 $this->addWhere( $db->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' );
261 }
262 } elseif ( $revCount > 0 ) {
263 $max = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
264 $revs = $pageSet->getRevisionIDs();
265 if ( self::truncateArray( $revs, $max ) ) {
266 $this->setWarning( "Too many values supplied for parameter 'revids': the limit is $max" );
267 }
268
269 // Get all revision IDs
270 $this->addWhereFld( 'rev_id', array_keys( $revs ) );
271
272 if ( !is_null( $params['continue'] ) ) {
273 $this->addWhere( "rev_id >= '" . intval( $params['continue'] ) . "'" );
274 }
275 $this->addOption( 'ORDER BY', 'rev_id' );
276
277 // assumption testing -- we should never get more then $revCount rows.
278 $limit = $revCount;
279 } elseif ( $pageCount > 0 ) {
280 $max = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
281 $titles = $pageSet->getGoodTitles();
282 if ( self::truncateArray( $titles, $max ) ) {
283 $this->setWarning( "Too many values supplied for parameter 'titles': the limit is $max" );
284 }
285
286 // When working in multi-page non-enumeration mode,
287 // limit to the latest revision only
288 $this->addWhere( 'page_id=rev_page' );
289 $this->addWhere( 'page_latest=rev_id' );
290
291 // Get all page IDs
292 $this->addWhereFld( 'page_id', array_keys( $titles ) );
293 // Every time someone relies on equality propagation, god kills a kitten :)
294 $this->addWhereFld( 'rev_page', array_keys( $titles ) );
295
296 if ( !is_null( $params['continue'] ) ) {
297 $cont = explode( '|', $params['continue'] );
298 if ( count( $cont ) != 2 ) {
299 $this->dieUsage( 'Invalid continue param. You should pass the original ' .
300 'value returned by the previous query', '_badcontinue' );
301 }
302 $pageid = intval( $cont[0] );
303 $revid = intval( $cont[1] );
304 $this->addWhere(
305 "rev_page > '$pageid' OR " .
306 "(rev_page = '$pageid' AND " .
307 "rev_id >= '$revid')"
308 );
309 }
310 $this->addOption( 'ORDER BY', 'rev_page, rev_id' );
311
312 // assumption testing -- we should never get more then $pageCount rows.
313 $limit = $pageCount;
314 } else {
315 ApiBase::dieDebug( __METHOD__, 'param validation?' );
316 }
317
318 $this->addOption( 'LIMIT', $limit + 1 );
319 $this->addOption( 'USE INDEX', $index );
320
321 $data = array();
322 $count = 0;
323 $res = $this->select( __METHOD__ );
324
325 foreach ( $res as $row ) {
326 if ( ++ $count > $limit ) {
327 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
328 if ( !$enumRevMode ) {
329 ApiBase::dieDebug( __METHOD__, 'Got more rows then expected' ); // bug report
330 }
331 $this->setContinueEnumParameter( 'startid', intval( $row->rev_id ) );
332 break;
333 }
334
335 $fit = $this->addPageSubItem( $row->rev_page, $this->extractRowInfo( $row ), 'rev' );
336 if ( !$fit ) {
337 if ( $enumRevMode ) {
338 $this->setContinueEnumParameter( 'startid', intval( $row->rev_id ) );
339 } elseif ( $revCount > 0 ) {
340 $this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) );
341 } else {
342 $this->setContinueEnumParameter( 'continue', intval( $row->rev_page ) .
343 '|' . intval( $row->rev_id ) );
344 }
345 break;
346 }
347 }
348 }
349
350 private function extractRowInfo( $row ) {
351 $revision = new Revision( $row );
352 $title = $revision->getTitle();
353 $vals = array();
354
355 if ( $this->fld_ids ) {
356 $vals['revid'] = intval( $revision->getId() );
357 // $vals['oldid'] = intval( $row->rev_text_id ); // todo: should this be exposed?
358 if ( !is_null( $revision->getParentId() ) ) {
359 $vals['parentid'] = intval( $revision->getParentId() );
360 }
361 }
362
363 if ( $this->fld_flags && $revision->isMinor() ) {
364 $vals['minor'] = '';
365 }
366
367 if ( $this->fld_user ) {
368 if ( $revision->isDeleted( Revision::DELETED_USER ) ) {
369 $vals['userhidden'] = '';
370 } else {
371 $vals['user'] = $revision->getUserText();
372 if ( !$revision->getUser() ) {
373 $vals['anon'] = '';
374 }
375 }
376 }
377
378 if ( $this->fld_timestamp ) {
379 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $revision->getTimestamp() );
380 }
381
382 if ( $this->fld_size && !is_null( $revision->getSize() ) ) {
383 $vals['size'] = intval( $revision->getSize() );
384 }
385
386 if ( $this->fld_comment || $this->fld_parsedcomment ) {
387 if ( $revision->isDeleted( Revision::DELETED_COMMENT ) ) {
388 $vals['commenthidden'] = '';
389 } else {
390 $comment = $revision->getComment();
391
392 if ( $this->fld_comment ) {
393 $vals['comment'] = $comment;
394 }
395
396 if ( $this->fld_parsedcomment ) {
397 global $wgUser;
398 $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $comment, $title );
399 }
400 }
401 }
402
403 if ( $this->fld_tags ) {
404 if ( $row->ts_tags ) {
405 $tags = explode( ',', $row->ts_tags );
406 $this->getResult()->setIndexedTagName( $tags, 'tag' );
407 $vals['tags'] = $tags;
408 } else {
409 $vals['tags'] = array();
410 }
411 }
412
413 if ( !is_null( $this->token ) ) {
414 $tokenFunctions = $this->getTokenFunctions();
415 foreach ( $this->token as $t ) {
416 $val = call_user_func( $tokenFunctions[$t], $title->getArticleID(), $title, $revision );
417 if ( $val === false ) {
418 $this->setWarning( "Action '$t' is not allowed for the current user" );
419 } else {
420 $vals[$t . 'token'] = $val;
421 }
422 }
423 }
424
425 $text = null;
426 if ( $this->fld_content || !is_null( $this->difftotext ) ) {
427 $text = $revision->getText();
428 // Expand templates after getting section content because
429 // template-added sections don't count and Parser::preprocess()
430 // will have less input
431 if ( $this->section !== false ) {
432 global $wgParser;
433
434 $text = $wgParser->getSection( $text, $this->section, false );
435 if ( $text === false ) {
436 $this->dieUsage( "There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection' );
437 }
438 }
439 }
440 if ( $this->fld_content && !$revision->isDeleted( Revision::DELETED_TEXT ) ) {
441 if ( $this->generateXML ) {
442 global $wgParser;
443 $wgParser->startExternalParse( $title, new ParserOptions(), OT_PREPROCESS );
444 $dom = $wgParser->preprocessToDom( $text );
445 if ( is_callable( array( $dom, 'saveXML' ) ) ) {
446 $xml = $dom->saveXML();
447 } else {
448 $xml = $dom->__toString();
449 }
450 $vals['parsetree'] = $xml;
451
452 }
453 if ( $this->expandTemplates ) {
454 $text = $wgParser->preprocess( $text, $title, new ParserOptions() );
455 }
456 ApiResult::setContent( $vals, $text );
457 } elseif ( $this->fld_content ) {
458 $vals['texthidden'] = '';
459 }
460
461 if ( !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) {
462 global $wgAPIMaxUncachedDiffs;
463 static $n = 0; // Number of uncached diffs we've had
464 if ( $n < $wgAPIMaxUncachedDiffs ) {
465 $vals['diff'] = array();
466 if ( !is_null( $this->difftotext ) ) {
467 $engine = new DifferenceEngine( $title );
468 $engine->setText( $text, $this->difftotext );
469 } else {
470 $engine = new DifferenceEngine( $title, $revision->getID(), $this->diffto );
471 $vals['diff']['from'] = $engine->getOldid();
472 $vals['diff']['to'] = $engine->getNewid();
473 }
474 $difftext = $engine->getDiffBody();
475 ApiResult::setContent( $vals['diff'], $difftext );
476 if ( !$engine->wasCacheHit() ) {
477 $n++;
478 }
479 } else {
480 $vals['diff']['notcached'] = '';
481 }
482 }
483 return $vals;
484 }
485
486 public function getAllowedParams() {
487 return array(
488 'prop' => array(
489 ApiBase::PARAM_ISMULTI => true,
490 ApiBase::PARAM_DFLT => 'ids|timestamp|flags|comment|user',
491 ApiBase::PARAM_TYPE => array(
492 'ids',
493 'flags',
494 'timestamp',
495 'user',
496 'size',
497 'comment',
498 'parsedcomment',
499 'content',
500 'tags'
501 )
502 ),
503 'limit' => array(
504 ApiBase::PARAM_TYPE => 'limit',
505 ApiBase::PARAM_MIN => 1,
506 ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
507 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
508 ),
509 'startid' => array(
510 ApiBase::PARAM_TYPE => 'integer'
511 ),
512 'endid' => array(
513 ApiBase::PARAM_TYPE => 'integer'
514 ),
515 'start' => array(
516 ApiBase::PARAM_TYPE => 'timestamp'
517 ),
518 'end' => array(
519 ApiBase::PARAM_TYPE => 'timestamp'
520 ),
521 'dir' => array(
522 ApiBase::PARAM_DFLT => 'older',
523 ApiBase::PARAM_TYPE => array(
524 'newer',
525 'older'
526 )
527 ),
528 'user' => array(
529 ApiBase::PARAM_TYPE => 'user'
530 ),
531 'excludeuser' => array(
532 ApiBase::PARAM_TYPE => 'user'
533 ),
534 'tag' => null,
535 'expandtemplates' => false,
536 'generatexml' => false,
537 'section' => null,
538 'token' => array(
539 ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
540 ApiBase::PARAM_ISMULTI => true
541 ),
542 'continue' => null,
543 'diffto' => null,
544 'difftotext' => null,
545 );
546 }
547
548 public function getParamDescription() {
549 $p = $this->getModulePrefix();
550 return array(
551 'prop' => 'Which properties to get for each revision',
552 'limit' => 'Limit how many revisions will be returned (enum)',
553 'startid' => 'From which revision id to start enumeration (enum)',
554 'endid' => 'Stop revision enumeration on this revid (enum)',
555 'start' => 'From which revision timestamp to start enumeration (enum)',
556 'end' => 'Enumerate up to this timestamp (enum)',
557 'dir' => 'Direction of enumeration - towards "newer" or "older" revisions (enum)',
558 'user' => 'Only include revisions made by user',
559 'excludeuser' => 'Exclude revisions made by user',
560 'expandtemplates' => 'Expand templates in revision content',
561 'generatexml' => 'Generate XML parse tree for revision content',
562 'section' => 'Only retrieve the content of this section number',
563 'token' => 'Which tokens to obtain for each revision',
564 'continue' => 'When more results are available, use this to continue',
565 'diffto' => array( 'Revision ID to diff each revision to.',
566 'Use "prev", "next" and "cur" for the previous, next and current revision respectively' ),
567 'difftotext' => array( 'Text to diff each revision to. Only diffs a limited number of revisions.',
568 "Overrides {$p}diffto. If {$p}section is set, only that section will be diffed against this text" ),
569 'tag' => 'Only list revisions tagged with this tag',
570 );
571 }
572
573 public function getDescription() {
574 return array(
575 'Get revision information',
576 'This module may be used in several ways:',
577 ' 1) Get data about a set of pages (last revision), by setting titles or pageids parameter',
578 ' 2) Get revisions for one given page, by using titles/pageids with start/end/limit params',
579 ' 3) Get data about a set of revisions by setting their IDs with revids parameter',
580 'All parameters marked as (enum) may only be used with a single page (#2)'
581 );
582 }
583
584 public function getPossibleErrors() {
585 return array_merge( parent::getPossibleErrors(), array(
586 array( 'nosuchrevid', 'diffto' ),
587 array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).' ),
588 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.' ),
589 array( 'code' => 'diffto', 'info' => 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"' ),
590 array( 'code' => 'badparams', 'info' => 'start and startid cannot be used together' ),
591 array( 'code' => 'badparams', 'info' => 'end and endid cannot be used together' ),
592 array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ),
593 array( 'code' => 'nosuchsection', 'info' => 'There is no section section in rID' ),
594 ) );
595 }
596
597 protected function getExamples() {
598 return array(
599 'Get data with content for the last revision of titles "API" and "Main Page":',
600 ' api.php?action=query&prop=revisions&titles=API|Main%20Page&rvprop=timestamp|user|comment|content',
601 'Get last 5 revisions of the "Main Page":',
602 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment',
603 'Get first 5 revisions of the "Main Page":',
604 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer',
605 'Get first 5 revisions of the "Main Page" made after 2006-05-01:',
606 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer&rvstart=20060501000000',
607 'Get first 5 revisions of the "Main Page" that were not made made by anonymous user "127.0.0.1"',
608 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvexcludeuser=127.0.0.1',
609 'Get first 5 revisions of the "Main Page" that were made by the user "MediaWiki default"',
610 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvuser=MediaWiki%20default',
611 );
612 }
613
614 public function getVersion() {
615 return __CLASS__ . ': $Id$';
616 }
617 }