Remove blank comment line
[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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 {
214 $this->dieUsage( 'start and startid cannot be used together', 'badparams' );
215 }
216
217 if ( !is_null( $params['endid'] ) && !is_null( $params['end'] ) ) {
218 $this->dieUsage( 'end and endid cannot be used together', 'badparams' );
219 }
220
221 if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) )
222 {
223 $this->dieUsage( 'user and excludeuser cannot be used together', 'badparams' );
224 }
225
226 // This code makes an assumption that sorting by rev_id and rev_timestamp produces
227 // the same result. This way users may request revisions starting at a given time,
228 // but to page through results use the rev_id returned after each page.
229 // Switching to rev_id removes the potential problem of having more than
230 // one row with the same timestamp for the same page.
231 // The order needs to be the same as start parameter to avoid SQL filesort.
232 if ( is_null( $params['startid'] ) && is_null( $params['endid'] ) ) {
233 $this->addWhereRange( 'rev_timestamp', $params['dir'],
234 $params['start'], $params['end'] );
235 } else {
236 $this->addWhereRange( 'rev_id', $params['dir'],
237 $params['startid'], $params['endid'] );
238 // One of start and end can be set
239 // If neither is set, this does nothing
240 $this->addWhereRange( 'rev_timestamp', $params['dir'],
241 $params['start'], $params['end'], false );
242 }
243
244 // must manually initialize unset limit
245 if ( is_null( $limit ) ) {
246 $limit = 10;
247 }
248 $this->validateLimit( 'limit', $limit, 1, $userMax, $botMax );
249
250 // There is only one ID, use it
251 $ids = array_keys( $pageSet->getGoodTitles() );
252 $this->addWhereFld( 'rev_page', reset( $ids ) );
253
254 if ( !is_null( $params['user'] ) ) {
255 $this->addWhereFld( 'rev_user_text', $params['user'] );
256 } elseif ( !is_null( $params['excludeuser'] ) ) {
257 $this->addWhere( 'rev_user_text != ' .
258 $db->addQuotes( $params['excludeuser'] ) );
259 }
260 if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
261 // Paranoia: avoid brute force searches (bug 17342)
262 $this->addWhere( $db->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' );
263 }
264 } elseif ( $revCount > 0 ) {
265 $max = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
266 $revs = $pageSet->getRevisionIDs();
267 if ( self::truncateArray( $revs, $max ) ) {
268 $this->setWarning( "Too many values supplied for parameter 'revids': the limit is $max" );
269 }
270
271 // Get all revision IDs
272 $this->addWhereFld( 'rev_id', array_keys( $revs ) );
273
274 if ( !is_null( $params['continue'] ) ) {
275 $this->addWhere( "rev_id >= '" . intval( $params['continue'] ) . "'" );
276 }
277 $this->addOption( 'ORDER BY', 'rev_id' );
278
279 // assumption testing -- we should never get more then $revCount rows.
280 $limit = $revCount;
281 } elseif ( $pageCount > 0 ) {
282 $max = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
283 $titles = $pageSet->getGoodTitles();
284 if ( self::truncateArray( $titles, $max ) ) {
285 $this->setWarning( "Too many values supplied for parameter 'titles': the limit is $max" );
286 }
287
288 // When working in multi-page non-enumeration mode,
289 // limit to the latest revision only
290 $this->addWhere( 'page_id=rev_page' );
291 $this->addWhere( 'page_latest=rev_id' );
292
293 // Get all page IDs
294 $this->addWhereFld( 'page_id', array_keys( $titles ) );
295 // Every time someone relies on equality propagation, god kills a kitten :)
296 $this->addWhereFld( 'rev_page', array_keys( $titles ) );
297
298 if ( !is_null( $params['continue'] ) ) {
299 $cont = explode( '|', $params['continue'] );
300 if ( count( $cont ) != 2 ) {
301 $this->dieUsage( 'Invalid continue param. You should pass the original ' .
302 'value returned by the previous query', '_badcontinue' );
303 }
304 $pageid = intval( $cont[0] );
305 $revid = intval( $cont[1] );
306 $this->addWhere(
307 "rev_page > '$pageid' OR " .
308 "(rev_page = '$pageid' AND " .
309 "rev_id >= '$revid')"
310 );
311 }
312 $this->addOption( 'ORDER BY', 'rev_page, rev_id' );
313
314 // assumption testing -- we should never get more then $pageCount rows.
315 $limit = $pageCount;
316 } else {
317 ApiBase::dieDebug( __METHOD__, 'param validation?' );
318 }
319
320 $this->addOption( 'LIMIT', $limit + 1 );
321 $this->addOption( 'USE INDEX', $index );
322
323 $data = array();
324 $count = 0;
325 $res = $this->select( __METHOD__ );
326
327 while ( $row = $db->fetchObject( $res ) ) {
328 if ( ++ $count > $limit ) {
329 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
330 if ( !$enumRevMode ) {
331 ApiBase::dieDebug( __METHOD__, 'Got more rows then expected' ); // bug report
332 }
333 $this->setContinueEnumParameter( 'startid', intval( $row->rev_id ) );
334 break;
335 }
336
337 $fit = $this->addPageSubItem( $row->rev_page, $this->extractRowInfo( $row ), 'rev' );
338 if ( !$fit ) {
339 if ( $enumRevMode ) {
340 $this->setContinueEnumParameter( 'startid', intval( $row->rev_id ) );
341 } elseif ( $revCount > 0 ) {
342 $this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) );
343 } else {
344 $this->setContinueEnumParameter( 'continue', intval( $row->rev_page ) .
345 '|' . intval( $row->rev_id ) );
346 }
347 break;
348 }
349 }
350 $db->freeResult( $res );
351 }
352
353 private function extractRowInfo( $row ) {
354 $revision = new Revision( $row );
355 $title = $revision->getTitle();
356 $vals = array();
357
358 if ( $this->fld_ids ) {
359 $vals['revid'] = intval( $revision->getId() );
360 // $vals['oldid'] = intval( $row->rev_text_id ); // todo: should this be exposed?
361 if ( !is_null( $revision->getParentId() ) ) {
362 $vals['parentid'] = intval( $revision->getParentId() );
363 }
364 }
365
366 if ( $this->fld_flags && $revision->isMinor() ) {
367 $vals['minor'] = '';
368 }
369
370 if ( $this->fld_user ) {
371 if ( $revision->isDeleted( Revision::DELETED_USER ) ) {
372 $vals['userhidden'] = '';
373 } else {
374 $vals['user'] = $revision->getUserText();
375 if ( !$revision->getUser() ) {
376 $vals['anon'] = '';
377 }
378 }
379 }
380
381 if ( $this->fld_timestamp ) {
382 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $revision->getTimestamp() );
383 }
384
385 if ( $this->fld_size && !is_null( $revision->getSize() ) ) {
386 $vals['size'] = intval( $revision->getSize() );
387 }
388
389 if ( $this->fld_comment || $this->fld_parsedcomment ) {
390 if ( $revision->isDeleted( Revision::DELETED_COMMENT ) ) {
391 $vals['commenthidden'] = '';
392 } else {
393 $comment = $revision->getComment();
394
395 if ( $this->fld_comment ) {
396 $vals['comment'] = $comment;
397 }
398
399 if ( $this->fld_parsedcomment ) {
400 global $wgUser;
401 $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $comment, $title );
402 }
403 }
404 }
405
406 if ( $this->fld_tags ) {
407 if ( $row->ts_tags ) {
408 $tags = explode( ',', $row->ts_tags );
409 $this->getResult()->setIndexedTagName( $tags, 'tag' );
410 $vals['tags'] = $tags;
411 } else {
412 $vals['tags'] = array();
413 }
414 }
415
416 if ( !is_null( $this->token ) ) {
417 $tokenFunctions = $this->getTokenFunctions();
418 foreach ( $this->token as $t ) {
419 $val = call_user_func( $tokenFunctions[$t], $title->getArticleID(), $title, $revision );
420 if ( $val === false ) {
421 $this->setWarning( "Action '$t' is not allowed for the current user" );
422 } else {
423 $vals[$t . 'token'] = $val;
424 }
425 }
426 }
427
428 $text = null;
429 if ( $this->fld_content || !is_null( $this->difftotext ) ) {
430 global $wgParser;
431 $text = $revision->getText();
432 // Expand templates after getting section content because
433 // template-added sections don't count and Parser::preprocess()
434 // will have less input
435 if ( $this->section !== false ) {
436 $text = $wgParser->getSection( $text, $this->section, false );
437 if ( $text === false ) {
438 $this->dieUsage( "There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection' );
439 }
440 }
441 }
442 if ( $this->fld_content && !$revision->isDeleted( Revision::DELETED_TEXT ) ) {
443 if ( $this->generateXML ) {
444 $wgParser->startExternalParse( $title, new ParserOptions(), OT_PREPROCESS );
445 $dom = $wgParser->preprocessToDom( $text );
446 if ( is_callable( array( $dom, 'saveXML' ) ) ) {
447 $xml = $dom->saveXML();
448 } else {
449 $xml = $dom->__toString();
450 }
451 $vals['parsetree'] = $xml;
452
453 }
454 if ( $this->expandTemplates ) {
455 $text = $wgParser->preprocess( $text, $title, new ParserOptions() );
456 }
457 ApiResult::setContent( $vals, $text );
458 } elseif ( $this->fld_content ) {
459 $vals['texthidden'] = '';
460 }
461
462 if ( !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) {
463 global $wgAPIMaxUncachedDiffs;
464 static $n = 0; // Number of uncached diffs we've had
465 if ( $n < $wgAPIMaxUncachedDiffs ) {
466 $vals['diff'] = array();
467 if ( !is_null( $this->difftotext ) ) {
468 $engine = new DifferenceEngine( $title );
469 $engine->setText( $text, $this->difftotext );
470 } else {
471 $engine = new DifferenceEngine( $title, $revision->getID(), $this->diffto );
472 $vals['diff']['from'] = $engine->getOldid();
473 $vals['diff']['to'] = $engine->getNewid();
474 }
475 $difftext = $engine->getDiffBody();
476 ApiResult::setContent( $vals['diff'], $difftext );
477 if ( !$engine->wasCacheHit() ) {
478 $n++;
479 }
480 } else {
481 $vals['diff']['notcached'] = '';
482 }
483 }
484 return $vals;
485 }
486
487 public function getAllowedParams() {
488 return array(
489 'prop' => array(
490 ApiBase::PARAM_ISMULTI => true,
491 ApiBase::PARAM_DFLT => 'ids|timestamp|flags|comment|user',
492 ApiBase::PARAM_TYPE => array(
493 'ids',
494 'flags',
495 'timestamp',
496 'user',
497 'size',
498 'comment',
499 'parsedcomment',
500 'content',
501 'tags'
502 )
503 ),
504 'limit' => array(
505 ApiBase::PARAM_TYPE => 'limit',
506 ApiBase::PARAM_MIN => 1,
507 ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
508 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
509 ),
510 'startid' => array(
511 ApiBase::PARAM_TYPE => 'integer'
512 ),
513 'endid' => array(
514 ApiBase::PARAM_TYPE => 'integer'
515 ),
516 'start' => array(
517 ApiBase::PARAM_TYPE => 'timestamp'
518 ),
519 'end' => array(
520 ApiBase::PARAM_TYPE => 'timestamp'
521 ),
522 'dir' => array(
523 ApiBase::PARAM_DFLT => 'older',
524 ApiBase::PARAM_TYPE => array(
525 'newer',
526 'older'
527 )
528 ),
529 'user' => array(
530 ApiBase::PARAM_TYPE => 'user'
531 ),
532 'excludeuser' => array(
533 ApiBase::PARAM_TYPE => 'user'
534 ),
535 'tag' => null,
536 'expandtemplates' => false,
537 'generatexml' => false,
538 'section' => null,
539 'token' => array(
540 ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
541 ApiBase::PARAM_ISMULTI => true
542 ),
543 'continue' => null,
544 'diffto' => null,
545 'difftotext' => null,
546 );
547 }
548
549 public function getParamDescription() {
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',
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 diffto. If rvsection 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 }