Per r69587 CR, mention which languages support variant conversion in the API help...
[lhc/web/wiklou.git] / includes / api / ApiQuery.php
1 <?php
2 /**
3 * API for MediaWiki 1.8+
4 *
5 * Created on Sep 7, 2006
6 *
7 * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
8 *
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.
13 *
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.
18 *
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
23 *
24 * @file
25 */
26
27 if ( !defined( 'MEDIAWIKI' ) ) {
28 // Eclipse helper - will be ignored in production
29 require_once( 'ApiBase.php' );
30 }
31
32 /**
33 * This is the main query class. It behaves similar to ApiMain: based on the
34 * parameters given, it will create a list of titles to work on (an ApiPageSet
35 * object), instantiate and execute various property/list/meta modules, and
36 * assemble all resulting data into a single ApiResult object.
37 *
38 * In generator mode, a generator will be executed first to populate a second
39 * ApiPageSet object, and that object will be used for all subsequent modules.
40 *
41 * @ingroup API
42 */
43 class ApiQuery extends ApiBase {
44
45 private $mPropModuleNames, $mListModuleNames, $mMetaModuleNames;
46 private $mPageSet;
47 private $params;
48
49 private $mQueryPropModules = array(
50 'info' => 'ApiQueryInfo',
51 'revisions' => 'ApiQueryRevisions',
52 'links' => 'ApiQueryLinks',
53 'iwlinks' => 'ApiQueryIWLinks',
54 'langlinks' => 'ApiQueryLangLinks',
55 'images' => 'ApiQueryImages',
56 'imageinfo' => 'ApiQueryImageInfo',
57 'templates' => 'ApiQueryLinks',
58 'categories' => 'ApiQueryCategories',
59 'extlinks' => 'ApiQueryExternalLinks',
60 'categoryinfo' => 'ApiQueryCategoryInfo',
61 'duplicatefiles' => 'ApiQueryDuplicateFiles',
62 'pageprops' => 'ApiQueryPageProps',
63 );
64
65 private $mQueryListModules = array(
66 'allimages' => 'ApiQueryAllimages',
67 'allpages' => 'ApiQueryAllpages',
68 'alllinks' => 'ApiQueryAllLinks',
69 'allcategories' => 'ApiQueryAllCategories',
70 'allusers' => 'ApiQueryAllUsers',
71 'backlinks' => 'ApiQueryBacklinks',
72 'blocks' => 'ApiQueryBlocks',
73 'categorymembers' => 'ApiQueryCategoryMembers',
74 'deletedrevs' => 'ApiQueryDeletedrevs',
75 'embeddedin' => 'ApiQueryBacklinks',
76 'filearchive' => 'ApiQueryFilearchive',
77 'imageusage' => 'ApiQueryBacklinks',
78 'iwbacklinks' => 'ApiQueryIWBacklinks',
79 'logevents' => 'ApiQueryLogEvents',
80 'recentchanges' => 'ApiQueryRecentChanges',
81 'search' => 'ApiQuerySearch',
82 'tags' => 'ApiQueryTags',
83 'usercontribs' => 'ApiQueryContributions',
84 'watchlist' => 'ApiQueryWatchlist',
85 'watchlistraw' => 'ApiQueryWatchlistRaw',
86 'exturlusage' => 'ApiQueryExtLinksUsage',
87 'users' => 'ApiQueryUsers',
88 'random' => 'ApiQueryRandom',
89 'protectedtitles' => 'ApiQueryProtectedTitles',
90 );
91
92 private $mQueryMetaModules = array(
93 'siteinfo' => 'ApiQuerySiteinfo',
94 'userinfo' => 'ApiQueryUserInfo',
95 'allmessages' => 'ApiQueryAllmessages',
96 );
97
98 private $mSlaveDB = null;
99 private $mNamedDB = array();
100
101 public function __construct( $main, $action ) {
102 parent::__construct( $main, $action );
103
104 // Allow custom modules to be added in LocalSettings.php
105 global $wgAPIPropModules, $wgAPIListModules, $wgAPIMetaModules;
106 self::appendUserModules( $this->mQueryPropModules, $wgAPIPropModules );
107 self::appendUserModules( $this->mQueryListModules, $wgAPIListModules );
108 self::appendUserModules( $this->mQueryMetaModules, $wgAPIMetaModules );
109
110 $this->mPropModuleNames = array_keys( $this->mQueryPropModules );
111 $this->mListModuleNames = array_keys( $this->mQueryListModules );
112 $this->mMetaModuleNames = array_keys( $this->mQueryMetaModules );
113
114 // Allow the entire list of modules at first,
115 // but during module instantiation check if it can be used as a generator.
116 $this->mAllowedGenerators = array_merge( $this->mListModuleNames, $this->mPropModuleNames );
117 }
118
119 /**
120 * Helper function to append any add-in modules to the list
121 * @param $modules array Module array
122 * @param $newModules array Module array to add to $modules
123 */
124 private static function appendUserModules( &$modules, $newModules ) {
125 if ( is_array( $newModules ) ) {
126 foreach ( $newModules as $moduleName => $moduleClass ) {
127 $modules[$moduleName] = $moduleClass;
128 }
129 }
130 }
131
132 /**
133 * Gets a default slave database connection object
134 * @return Database
135 */
136 public function getDB() {
137 if ( !isset( $this->mSlaveDB ) ) {
138 $this->profileDBIn();
139 $this->mSlaveDB = wfGetDB( DB_SLAVE, 'api' );
140 $this->profileDBOut();
141 }
142 return $this->mSlaveDB;
143 }
144
145 /**
146 * Get the query database connection with the given name.
147 * If no such connection has been requested before, it will be created.
148 * Subsequent calls with the same $name will return the same connection
149 * as the first, regardless of the values of $db and $groups
150 * @param $name string Name to assign to the database connection
151 * @param $db int One of the DB_* constants
152 * @param $groups array Query groups
153 * @return Database
154 */
155 public function getNamedDB( $name, $db, $groups ) {
156 if ( !array_key_exists( $name, $this->mNamedDB ) ) {
157 $this->profileDBIn();
158 $this->mNamedDB[$name] = wfGetDB( $db, $groups );
159 $this->profileDBOut();
160 }
161 return $this->mNamedDB[$name];
162 }
163
164 /**
165 * Gets the set of pages the user has requested (or generated)
166 * @return ApiPageSet
167 */
168 public function getPageSet() {
169 return $this->mPageSet;
170 }
171
172 /**
173 * Get the array mapping module names to class names
174 * @return array(modulename => classname)
175 */
176 function getModules() {
177 return array_merge( $this->mQueryPropModules, $this->mQueryListModules, $this->mQueryMetaModules );
178 }
179
180 /**
181 * Get whether the specified module is a prop, list or a meta query module
182 * @param $moduleName string Name of the module to find type for
183 * @return mixed string or null
184 */
185 function getModuleType( $moduleName ) {
186 if ( array_key_exists ( $moduleName, $this->mQueryPropModules ) ) {
187 return 'prop';
188 }
189
190 if ( array_key_exists ( $moduleName, $this->mQueryListModules ) ) {
191 return 'list';
192 }
193
194 if ( array_key_exists ( $moduleName, $this->mQueryMetaModules ) ) {
195 return 'meta';
196 }
197
198 return null;
199 }
200
201 public function getCustomPrinter() {
202 // If &exportnowrap is set, use the raw formatter
203 if ( $this->getParameter( 'export' ) &&
204 $this->getParameter( 'exportnowrap' ) )
205 {
206 return new ApiFormatRaw( $this->getMain(),
207 $this->getMain()->createPrinterByName( 'xml' ) );
208 } else {
209 return null;
210 }
211 }
212
213 /**
214 * Query execution happens in the following steps:
215 * #1 Create a PageSet object with any pages requested by the user
216 * #2 If using a generator, execute it to get a new ApiPageSet object
217 * #3 Instantiate all requested modules.
218 * This way the PageSet object will know what shared data is required,
219 * and minimize DB calls.
220 * #4 Output all normalization and redirect resolution information
221 * #5 Execute all requested modules
222 */
223 public function execute() {
224 $this->params = $this->extractRequestParams();
225 $this->redirects = $this->params['redirects'];
226 $this->convertTitles = $this->params['converttitles'];
227
228 // Create PageSet
229 $this->mPageSet = new ApiPageSet( $this, $this->redirects, $this->convertTitles );
230
231 // Instantiate requested modules
232 $modules = array();
233 $this->instantiateModules( $modules, 'prop', $this->mQueryPropModules );
234 $this->instantiateModules( $modules, 'list', $this->mQueryListModules );
235 $this->instantiateModules( $modules, 'meta', $this->mQueryMetaModules );
236
237 $cacheMode = 'public';
238
239 // If given, execute generator to substitute user supplied data with generated data.
240 if ( isset( $this->params['generator'] ) ) {
241 $generator = $this->newGenerator( $this->params['generator'] );
242 $params = $generator->extractRequestParams();
243 $cacheMode = $this->mergeCacheMode( $cacheMode,
244 $generator->getCacheMode( $params ) );
245 $this->executeGeneratorModule( $generator, $modules );
246 } else {
247 // Append custom fields and populate page/revision information
248 $this->addCustomFldsToPageSet( $modules, $this->mPageSet );
249 $this->mPageSet->execute();
250 }
251
252 // Record page information (title, namespace, if exists, etc)
253 $this->outputGeneralPageInfo();
254
255 // Execute all requested modules.
256 foreach ( $modules as $module ) {
257 $params = $module->extractRequestParams();
258 $cacheMode = $this->mergeCacheMode(
259 $cacheMode, $module->getCacheMode( $params ) );
260 $module->profileIn();
261 $module->execute();
262 wfRunHooks( 'APIQueryAfterExecute', array( &$module ) );
263 $module->profileOut();
264 }
265
266 // Set the cache mode
267 $this->getMain()->setCacheMode( $cacheMode );
268 }
269
270 /**
271 * Update a cache mode string, applying the cache mode of a new module to it.
272 * The cache mode may increase in the level of privacy, but public modules
273 * added to private data do not decrease the level of privacy.
274 */
275 protected function mergeCacheMode( $cacheMode, $modCacheMode ) {
276 if ( $modCacheMode === 'anon-public-user-private' ) {
277 if ( $cacheMode !== 'private' ) {
278 $cacheMode = 'anon-public-user-private';
279 }
280 } elseif ( $modCacheMode === 'public' ) {
281 // do nothing, if it's public already it will stay public
282 } else { // private
283 $cacheMode = 'private';
284 }
285 return $cacheMode;
286 }
287
288 /**
289 * Query modules may optimize data requests through the $this->getPageSet() object
290 * by adding extra fields from the page table.
291 * This function will gather all the extra request fields from the modules.
292 * @param $modules array of module objects
293 * @param $pageSet ApiPageSet
294 */
295 private function addCustomFldsToPageSet( $modules, $pageSet ) {
296 // Query all requested modules.
297 foreach ( $modules as $module ) {
298 $module->requestExtraData( $pageSet );
299 }
300 }
301
302 /**
303 * Create instances of all modules requested by the client
304 * @param $modules array to append instatiated modules to
305 * @param $param string Parameter name to read modules from
306 * @param $moduleList array(modulename => classname)
307 */
308 private function instantiateModules( &$modules, $param, $moduleList ) {
309 $list = @$this->params[$param];
310 if ( !is_null ( $list ) ) {
311 foreach ( $list as $moduleName ) {
312 $modules[] = new $moduleList[$moduleName] ( $this, $moduleName );
313 }
314 }
315 }
316
317 /**
318 * Appends an element for each page in the current pageSet with the
319 * most general information (id, title), plus any title normalizations
320 * and missing or invalid title/pageids/revids.
321 */
322 private function outputGeneralPageInfo() {
323 $pageSet = $this->getPageSet();
324 $result = $this->getResult();
325
326 // We don't check for a full result set here because we can't be adding
327 // more than 380K. The maximum revision size is in the megabyte range,
328 // and the maximum result size must be even higher than that.
329
330 // Title normalizations
331 $normValues = array();
332 foreach ( $pageSet->getNormalizedTitles() as $rawTitleStr => $titleStr ) {
333 $normValues[] = array(
334 'from' => $rawTitleStr,
335 'to' => $titleStr
336 );
337 }
338
339 if ( count( $normValues ) ) {
340 $result->setIndexedTagName( $normValues, 'n' );
341 $result->addValue( 'query', 'normalized', $normValues );
342 }
343
344 // Title conversions
345 $convValues = array();
346 foreach ( $pageSet->getConvertedTitles() as $rawTitleStr => $titleStr ) {
347 $convValues[] = array(
348 'from' => $rawTitleStr,
349 'to' => $titleStr
350 );
351 }
352
353 if ( count( $convValues ) ) {
354 $result->setIndexedTagName( $convValues, 'c' );
355 $result->addValue( 'query', 'converted', $convValues );
356 }
357
358 // Interwiki titles
359 $intrwValues = array();
360 foreach ( $pageSet->getInterwikiTitles() as $rawTitleStr => $interwikiStr ) {
361 $intrwValues[] = array(
362 'title' => $rawTitleStr,
363 'iw' => $interwikiStr
364 );
365 }
366
367 if ( count( $intrwValues ) ) {
368 $result->setIndexedTagName( $intrwValues, 'i' );
369 $result->addValue( 'query', 'interwiki', $intrwValues );
370 }
371
372 // Show redirect information
373 $redirValues = array();
374 foreach ( $pageSet->getRedirectTitles() as $titleStrFrom => $titleStrTo ) {
375 $redirValues[] = array(
376 'from' => strval( $titleStrFrom ),
377 'to' => $titleStrTo
378 );
379 }
380
381 if ( count( $redirValues ) ) {
382 $result->setIndexedTagName( $redirValues, 'r' );
383 $result->addValue( 'query', 'redirects', $redirValues );
384 }
385
386 //
387 // Missing revision elements
388 //
389 $missingRevIDs = $pageSet->getMissingRevisionIDs();
390 if ( count( $missingRevIDs ) ) {
391 $revids = array();
392 foreach ( $missingRevIDs as $revid ) {
393 $revids[$revid] = array(
394 'revid' => $revid
395 );
396 }
397 $result->setIndexedTagName( $revids, 'rev' );
398 $result->addValue( 'query', 'badrevids', $revids );
399 }
400
401 //
402 // Page elements
403 //
404 $pages = array();
405
406 // Report any missing titles
407 foreach ( $pageSet->getMissingTitles() as $fakeId => $title ) {
408 $vals = array();
409 ApiQueryBase::addTitleInfo( $vals, $title );
410 $vals['missing'] = '';
411 $pages[$fakeId] = $vals;
412 }
413 // Report any invalid titles
414 foreach ( $pageSet->getInvalidTitles() as $fakeId => $title ) {
415 $pages[$fakeId] = array( 'title' => $title, 'invalid' => '' );
416 }
417 // Report any missing page ids
418 foreach ( $pageSet->getMissingPageIDs() as $pageid ) {
419 $pages[$pageid] = array(
420 'pageid' => $pageid,
421 'missing' => ''
422 );
423 }
424 // Report special pages
425 foreach ( $pageSet->getSpecialTitles() as $fakeId => $title ) {
426 $vals = array();
427 ApiQueryBase::addTitleInfo( $vals, $title );
428 $vals['special'] = '';
429 if ( $title->getNamespace() == NS_SPECIAL &&
430 !SpecialPage::exists( $title->getText() ) ) {
431 $vals['missing'] = '';
432 } elseif ( $title->getNamespace() == NS_MEDIA &&
433 !wfFindFile( $title ) ) {
434 $vals['missing'] = '';
435 }
436 $pages[$fakeId] = $vals;
437 }
438
439 // Output general page information for found titles
440 foreach ( $pageSet->getGoodTitles() as $pageid => $title ) {
441 $vals = array();
442 $vals['pageid'] = $pageid;
443 ApiQueryBase::addTitleInfo( $vals, $title );
444 $pages[$pageid] = $vals;
445 }
446
447 if ( count( $pages ) ) {
448 if ( $this->params['indexpageids'] ) {
449 $pageIDs = array_keys( $pages );
450 // json treats all map keys as strings - converting to match
451 $pageIDs = array_map( 'strval', $pageIDs );
452 $result->setIndexedTagName( $pageIDs, 'id' );
453 $result->addValue( 'query', 'pageids', $pageIDs );
454 }
455
456 $result->setIndexedTagName( $pages, 'page' );
457 $result->addValue( 'query', 'pages', $pages );
458 }
459 if ( $this->params['export'] ) {
460 $exporter = new WikiExporter( $this->getDB() );
461 // WikiExporter writes to stdout, so catch its
462 // output with an ob
463 ob_start();
464 $exporter->openStream();
465 foreach ( @$pageSet->getGoodTitles() as $title ) {
466 if ( $title->userCanRead() ) {
467 $exporter->pageByTitle( $title );
468 }
469 }
470 $exporter->closeStream();
471 $exportxml = ob_get_contents();
472 ob_end_clean();
473
474 // Don't check the size of exported stuff
475 // It's not continuable, so it would cause more
476 // problems than it'd solve
477 $result->disableSizeCheck();
478 if ( $this->params['exportnowrap'] ) {
479 $result->reset();
480 // Raw formatter will handle this
481 $result->addValue( null, 'text', $exportxml );
482 $result->addValue( null, 'mime', 'text/xml' );
483 } else {
484 $r = array();
485 ApiResult::setContent( $r, $exportxml );
486 $result->addValue( 'query', 'export', $r );
487 }
488 $result->enableSizeCheck();
489 }
490 }
491
492 /**
493 * Create a generator object of the given type and return it
494 * @param $generatorName string Module name
495 */
496 public function newGenerator( $generatorName ) {
497 // Find class that implements requested generator
498 if ( isset( $this->mQueryListModules[$generatorName] ) ) {
499 $className = $this->mQueryListModules[$generatorName];
500 } elseif ( isset( $this->mQueryPropModules[$generatorName] ) ) {
501 $className = $this->mQueryPropModules[$generatorName];
502 } else {
503 ApiBase::dieDebug( __METHOD__, "Unknown generator=$generatorName" );
504 }
505 $generator = new $className ( $this, $generatorName );
506 if ( !$generator instanceof ApiQueryGeneratorBase ) {
507 $this->dieUsage( "Module $generatorName cannot be used as a generator", 'badgenerator' );
508 }
509 $generator->setGeneratorMode();
510 return $generator;
511 }
512
513 /**
514 * For generator mode, execute generator, and use its output as new
515 * ApiPageSet
516 * @param $generator string Module name
517 * @param $modules array of module objects
518 */
519 protected function executeGeneratorModule( $generator, $modules ) {
520 // Generator results
521 $resultPageSet = new ApiPageSet( $this, $this->redirects, $this->convertTitles );
522
523 // Add any additional fields modules may need
524 $generator->requestExtraData( $this->mPageSet );
525 $this->addCustomFldsToPageSet( $modules, $resultPageSet );
526
527 // Populate page information with the original user input
528 $this->mPageSet->execute();
529
530 // populate resultPageSet with the generator output
531 $generator->profileIn();
532 $generator->executeGenerator( $resultPageSet );
533 wfRunHooks( 'APIQueryGeneratorAfterExecute', array( &$generator, &$resultPageSet ) );
534 $resultPageSet->finishPageSetGeneration();
535 $generator->profileOut();
536
537 // Swap the resulting pageset back in
538 $this->mPageSet = $resultPageSet;
539 }
540
541 public function getAllowedParams() {
542 return array(
543 'prop' => array(
544 ApiBase::PARAM_ISMULTI => true,
545 ApiBase::PARAM_TYPE => $this->mPropModuleNames
546 ),
547 'list' => array(
548 ApiBase::PARAM_ISMULTI => true,
549 ApiBase::PARAM_TYPE => $this->mListModuleNames
550 ),
551 'meta' => array(
552 ApiBase::PARAM_ISMULTI => true,
553 ApiBase::PARAM_TYPE => $this->mMetaModuleNames
554 ),
555 'generator' => array(
556 ApiBase::PARAM_TYPE => $this->mAllowedGenerators
557 ),
558 'redirects' => false,
559 'converttitles' => false,
560 'indexpageids' => false,
561 'export' => false,
562 'exportnowrap' => false,
563 );
564 }
565
566 /**
567 * Override the parent to generate help messages for all available query modules.
568 * @return string
569 */
570 public function makeHelpMsg() {
571 $msg = '';
572
573 // Make sure the internal object is empty
574 // (just in case a sub-module decides to optimize during instantiation)
575 $this->mPageSet = null;
576 $this->mAllowedGenerators = array(); // Will be repopulated
577
578 $astriks = str_repeat( '--- ', 8 );
579 $astriks2 = str_repeat( '*** ', 10 );
580 $msg .= "\n$astriks Query: Prop $astriks\n\n";
581 $msg .= $this->makeHelpMsgHelper( $this->mQueryPropModules, 'prop' );
582 $msg .= "\n$astriks Query: List $astriks\n\n";
583 $msg .= $this->makeHelpMsgHelper( $this->mQueryListModules, 'list' );
584 $msg .= "\n$astriks Query: Meta $astriks\n\n";
585 $msg .= $this->makeHelpMsgHelper( $this->mQueryMetaModules, 'meta' );
586 $msg .= "\n\n$astriks2 Modules: continuation $astriks2\n\n";
587
588 // Perform the base call last because the $this->mAllowedGenerators
589 // will be updated inside makeHelpMsgHelper()
590 // Use parent to make default message for the query module
591 $msg = parent::makeHelpMsg() . $msg;
592
593 return $msg;
594 }
595
596 /**
597 * For all modules in $moduleList, generate help messages and join them together
598 * @param $moduleList array(modulename => classname)
599 * @param $paramName string Parameter name
600 * @return string
601 */
602 private function makeHelpMsgHelper( $moduleList, $paramName ) {
603 $moduleDescriptions = array();
604
605 foreach ( $moduleList as $moduleName => $moduleClass ) {
606 $module = new $moduleClass ( $this, $moduleName, null );
607
608 $msg = ApiMain::makeHelpMsgHeader( $module, $paramName );
609 $msg2 = $module->makeHelpMsg();
610 if ( $msg2 !== false ) {
611 $msg .= $msg2;
612 }
613 if ( $module instanceof ApiQueryGeneratorBase ) {
614 $this->mAllowedGenerators[] = $moduleName;
615 $msg .= "Generator:\n This module may be used as a generator\n";
616 }
617 $moduleDescriptions[] = $msg;
618 }
619
620 return implode( "\n", $moduleDescriptions );
621 }
622
623 /**
624 * Override to add extra parameters from PageSet
625 * @return string
626 */
627 public function makeHelpMsgParameters() {
628 $psModule = new ApiPageSet( $this );
629 return $psModule->makeHelpMsgParameters() . parent::makeHelpMsgParameters();
630 }
631
632 public function shouldCheckMaxlag() {
633 return true;
634 }
635
636 public function getParamDescription() {
637 return array(
638 'prop' => 'Which properties to get for the titles/revisions/pageids. Module help is available below',
639 'list' => 'Which lists to get. Module help is available below',
640 'meta' => 'Which metadata to get about the site. Module help is available below',
641 'generator' => array( 'Use the output of a list as the input for other prop/list/meta items',
642 'NOTE: generator parameter names must be prefixed with a \'g\', see examples' ),
643 'redirects' => 'Automatically resolve redirects',
644 'converttitles' => array( "Convert titles to other variants if necessary. Only works if the wiki's content language supports variant conversion.",
645 'Languages that support variant conversion are kk, ku, gan, tg, sr, zh' ),
646 'indexpageids' => 'Include an additional pageids section listing all returned page IDs',
647 'export' => 'Export the current revisions of all given or generated pages',
648 'exportnowrap' => 'Return the export XML without wrapping it in an XML result (same format as Special:Export). Can only be used with export',
649 );
650 }
651
652 public function getDescription() {
653 return array(
654 'Query API module allows applications to get needed pieces of data from the MediaWiki databases,',
655 'and is loosely based on the old query.php interface.',
656 'All data modifications will first have to use query to acquire a token to prevent abuse from malicious sites'
657 );
658 }
659
660 public function getPossibleErrors() {
661 return array_merge( parent::getPossibleErrors(), array(
662 array( 'code' => 'badgenerator', 'info' => 'Module $generatorName cannot be used as a generator' ),
663 ) );
664 }
665
666 protected function getExamples() {
667 return array(
668 'api.php?action=query&prop=revisions&meta=siteinfo&titles=Main%20Page&rvprop=user|comment',
669 'api.php?action=query&generator=allpages&gapprefix=API/&prop=revisions',
670 );
671 }
672
673 public function getVersion() {
674 $psModule = new ApiPageSet( $this );
675 $vers = array();
676 $vers[] = __CLASS__ . ': $Id$';
677 $vers[] = $psModule->getVersion();
678 return $vers;
679 }
680 }