Merge "Whitelist the <wbr> element."
[mediawiki.git] / includes / api / ApiQuery.php
blobaafd5827ed880a0c3697d1c10aa28fdbf04a207f
1 <?php
2 /**
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
24 * @file
27 /**
28 * This is the main query class. It behaves similar to ApiMain: based on the
29 * parameters given, it will create a list of titles to work on (an ApiPageSet
30 * object), instantiate and execute various property/list/meta modules, and
31 * assemble all resulting data into a single ApiResult object.
33 * In generator mode, a generator will be executed first to populate a second
34 * ApiPageSet object, and that object will be used for all subsequent modules.
36 * @ingroup API
38 class ApiQuery extends ApiBase {
40 /**
41 * List of Api Query prop modules
42 * @var array
44 private static $QueryPropModules = array(
45 'categories' => 'ApiQueryCategories',
46 'categoryinfo' => 'ApiQueryCategoryInfo',
47 'duplicatefiles' => 'ApiQueryDuplicateFiles',
48 'extlinks' => 'ApiQueryExternalLinks',
49 'images' => 'ApiQueryImages',
50 'imageinfo' => 'ApiQueryImageInfo',
51 'info' => 'ApiQueryInfo',
52 'links' => 'ApiQueryLinks',
53 'iwlinks' => 'ApiQueryIWLinks',
54 'langlinks' => 'ApiQueryLangLinks',
55 'pageprops' => 'ApiQueryPageProps',
56 'revisions' => 'ApiQueryRevisions',
57 'stashimageinfo' => 'ApiQueryStashImageInfo',
58 'templates' => 'ApiQueryLinks',
61 /**
62 * List of Api Query list modules
63 * @var array
65 private static $QueryListModules = array(
66 'allcategories' => 'ApiQueryAllCategories',
67 'allimages' => 'ApiQueryAllImages',
68 'alllinks' => 'ApiQueryAllLinks',
69 'allpages' => 'ApiQueryAllPages',
70 'alltransclusions' => 'ApiQueryAllLinks',
71 'allusers' => 'ApiQueryAllUsers',
72 'backlinks' => 'ApiQueryBacklinks',
73 'blocks' => 'ApiQueryBlocks',
74 'categorymembers' => 'ApiQueryCategoryMembers',
75 'deletedrevs' => 'ApiQueryDeletedrevs',
76 'embeddedin' => 'ApiQueryBacklinks',
77 'exturlusage' => 'ApiQueryExtLinksUsage',
78 'filearchive' => 'ApiQueryFilearchive',
79 'imageusage' => 'ApiQueryBacklinks',
80 'iwbacklinks' => 'ApiQueryIWBacklinks',
81 'langbacklinks' => 'ApiQueryLangBacklinks',
82 'logevents' => 'ApiQueryLogEvents',
83 'pageswithprop' => 'ApiQueryPagesWithProp',
84 'pagepropnames' => 'ApiQueryPagePropNames',
85 'protectedtitles' => 'ApiQueryProtectedTitles',
86 'querypage' => 'ApiQueryQueryPage',
87 'random' => 'ApiQueryRandom',
88 'recentchanges' => 'ApiQueryRecentChanges',
89 'search' => 'ApiQuerySearch',
90 'tags' => 'ApiQueryTags',
91 'usercontribs' => 'ApiQueryContributions',
92 'users' => 'ApiQueryUsers',
93 'watchlist' => 'ApiQueryWatchlist',
94 'watchlistraw' => 'ApiQueryWatchlistRaw',
97 /**
98 * List of Api Query meta modules
99 * @var array
101 private static $QueryMetaModules = array(
102 'allmessages' => 'ApiQueryAllMessages',
103 'siteinfo' => 'ApiQuerySiteinfo',
104 'userinfo' => 'ApiQueryUserInfo',
108 * @var ApiPageSet
110 private $mPageSet;
112 private $mParams;
113 private $mNamedDB = array();
114 private $mModuleMgr;
115 private $mGeneratorContinue;
116 private $mUseLegacyContinue;
119 * @param $main ApiMain
120 * @param $action string
122 public function __construct( $main, $action ) {
123 parent::__construct( $main, $action );
125 $this->mModuleMgr = new ApiModuleManager( $this );
127 // Allow custom modules to be added in LocalSettings.php
128 global $wgAPIPropModules, $wgAPIListModules, $wgAPIMetaModules;
129 $this->mModuleMgr->addModules( self::$QueryPropModules, 'prop' );
130 $this->mModuleMgr->addModules( $wgAPIPropModules, 'prop' );
131 $this->mModuleMgr->addModules( self::$QueryListModules, 'list' );
132 $this->mModuleMgr->addModules( $wgAPIListModules, 'list' );
133 $this->mModuleMgr->addModules( self::$QueryMetaModules, 'meta' );
134 $this->mModuleMgr->addModules( $wgAPIMetaModules, 'meta' );
136 // Create PageSet that will process titles/pageids/revids/generator
137 $this->mPageSet = new ApiPageSet( $this );
141 * Overrides to return this instance's module manager.
142 * @return ApiModuleManager
144 public function getModuleManager() {
145 return $this->mModuleMgr;
149 * Get the query database connection with the given name.
150 * If no such connection has been requested before, it will be created.
151 * Subsequent calls with the same $name will return the same connection
152 * as the first, regardless of the values of $db and $groups
153 * @param string $name Name to assign to the database connection
154 * @param int $db One of the DB_* constants
155 * @param array $groups Query groups
156 * @return DatabaseBase
158 public function getNamedDB( $name, $db, $groups ) {
159 if ( !array_key_exists( $name, $this->mNamedDB ) ) {
160 $this->profileDBIn();
161 $this->mNamedDB[$name] = wfGetDB( $db, $groups );
162 $this->profileDBOut();
164 return $this->mNamedDB[$name];
168 * Gets the set of pages the user has requested (or generated)
169 * @return ApiPageSet
171 public function getPageSet() {
172 return $this->mPageSet;
176 * Get the array mapping module names to class names
177 * @deprecated since 1.21, use getModuleManager()'s methods instead
178 * @return array array(modulename => classname)
180 public function getModules() {
181 wfDeprecated( __METHOD__, '1.21' );
182 return $this->getModuleManager()->getNamesWithClasses();
186 * Get the generators array mapping module names to class names
187 * @deprecated since 1.21, list of generators is maintained by ApiPageSet
188 * @return array array(modulename => classname)
190 public function getGenerators() {
191 wfDeprecated( __METHOD__, '1.21' );
192 $gens = array();
193 foreach ( $this->mModuleMgr->getNamesWithClasses() as $name => $class ) {
194 if ( is_subclass_of( $class, 'ApiQueryGeneratorBase' ) ) {
195 $gens[$name] = $class;
198 return $gens;
202 * Get whether the specified module is a prop, list or a meta query module
203 * @deprecated since 1.21, use getModuleManager()->getModuleGroup()
204 * @param string $moduleName Name of the module to find type for
205 * @return mixed string or null
207 function getModuleType( $moduleName ) {
208 return $this->getModuleManager()->getModuleGroup( $moduleName );
212 * @return ApiFormatRaw|null
214 public function getCustomPrinter() {
215 // If &exportnowrap is set, use the raw formatter
216 if ( $this->getParameter( 'export' ) &&
217 $this->getParameter( 'exportnowrap' ) )
219 return new ApiFormatRaw( $this->getMain(),
220 $this->getMain()->createPrinterByName( 'xml' ) );
221 } else {
222 return null;
227 * Query execution happens in the following steps:
228 * #1 Create a PageSet object with any pages requested by the user
229 * #2 If using a generator, execute it to get a new ApiPageSet object
230 * #3 Instantiate all requested modules.
231 * This way the PageSet object will know what shared data is required,
232 * and minimize DB calls.
233 * #4 Output all normalization and redirect resolution information
234 * #5 Execute all requested modules
236 public function execute() {
237 $this->mParams = $this->extractRequestParams();
239 // $pagesetParams is a array of parameter names used by the pageset generator
240 // or null if pageset has already finished and is no longer needed
241 // $completeModules is a set of complete modules with the name as key
242 $this->initContinue( $pagesetParams, $completeModules );
244 // Instantiate requested modules
245 $allModules = array();
246 $this->instantiateModules( $allModules, 'prop' );
247 $propModules = $allModules; // Keep a copy
248 $this->instantiateModules( $allModules, 'list' );
249 $this->instantiateModules( $allModules, 'meta' );
251 // Filter modules based on continue parameter
252 $modules = $this->initModules( $allModules, $completeModules, $pagesetParams !== null );
254 // Execute pageset if in legacy mode or if pageset is not done
255 if ( $completeModules === null || $pagesetParams !== null ) {
256 // Populate page/revision information
257 $this->mPageSet->execute();
258 // Record page information (title, namespace, if exists, etc)
259 $this->outputGeneralPageInfo();
260 } else {
261 $this->mPageSet->executeDryRun();
264 $cacheMode = $this->mPageSet->getCacheMode();
266 // Execute all unfinished modules
267 /** @var $module ApiQueryBase */
268 foreach ( $modules as $module ) {
269 $params = $module->extractRequestParams();
270 $cacheMode = $this->mergeCacheMode(
271 $cacheMode, $module->getCacheMode( $params ) );
272 $module->profileIn();
273 $module->execute();
274 wfRunHooks( 'APIQueryAfterExecute', array( &$module ) );
275 $module->profileOut();
278 // Set the cache mode
279 $this->getMain()->setCacheMode( $cacheMode );
281 if ( $completeModules === null ) {
282 return; // Legacy continue, we are done
285 // Reformat query-continue result section
286 $result = $this->getResult();
287 $qc = $result->getData();
288 if ( isset( $qc['query-continue'] ) ) {
289 $qc = $qc['query-continue'];
290 $result->unsetValue( null, 'query-continue' );
291 } elseif ( $this->mGeneratorContinue !== null ) {
292 $qc = array();
293 } else {
294 // no more "continue"s, we are done!
295 return;
298 // we are done with all the modules that do not have result in query-continue
299 $completeModules = array_merge( $completeModules, array_diff_key( $modules, $qc ) );
300 if ( $pagesetParams !== null ) {
301 // The pageset is still in use, check if all props have finished
302 $incompleteProps = array_intersect_key( $propModules, $qc );
303 if ( count( $incompleteProps ) > 0 ) {
304 // Properties are not done, continue with the same pageset state - copy current parameters
305 $main = $this->getMain();
306 $contValues = array();
307 foreach ( $pagesetParams as $param ) {
308 // The param name is already prefix-encoded
309 $contValues[$param] = $main->getVal( $param );
311 } elseif ( $this->mGeneratorContinue !== null ) {
312 // Move to the next set of pages produced by pageset, properties need to be restarted
313 $contValues = $this->mGeneratorContinue;
314 $pagesetParams = array_keys( $contValues );
315 $completeModules = array_diff_key( $completeModules, $propModules );
316 } else {
317 // Done with the pageset, finish up with the the lists and meta modules
318 $pagesetParams = null;
322 $continue = '||' . implode( '|', array_keys( $completeModules ) );
323 if ( $pagesetParams !== null ) {
324 // list of all pageset parameters to use in the next request
325 $continue = implode( '|', $pagesetParams ) . $continue;
326 } else {
327 // we are done with the pageset
328 $contValues = array();
329 $continue = '-' . $continue;
331 $contValues['continue'] = $continue;
332 foreach ( $qc as $qcModule ) {
333 foreach ( $qcModule as $qcKey => $qcValue ) {
334 $contValues[$qcKey] = $qcValue;
337 $this->getResult()->addValue( null, 'continue', $contValues );
341 * Parse 'continue' parameter into the list of complete modules and a list of generator parameters
342 * @param array|null $pagesetParams returns list of generator params or null if pageset is done
343 * @param array|null $completeModules returns list of finished modules (as keys), or null if legacy
345 private function initContinue( &$pagesetParams, &$completeModules ) {
346 $pagesetParams = array();
347 $continue = $this->mParams['continue'];
348 if ( $continue !== null ) {
349 $this->mUseLegacyContinue = false;
350 if ( $continue !== '' ) {
351 // Format: ' pagesetParam1 | pagesetParam2 || module1 | module2 | module3 | ...
352 // If pageset is done, use '-'
353 $continue = explode( '||', $continue );
354 $this->dieContinueUsageIf( count( $continue ) !== 2 );
355 if ( $continue[0] === '-' ) {
356 $pagesetParams = null; // No need to execute pageset
357 } elseif ( $continue[0] !== '' ) {
358 // list of pageset params that might need to be repeated
359 $pagesetParams = explode( '|', $continue[0] );
361 $continue = $continue[1];
363 if ( $continue !== '' ) {
364 $completeModules = array_flip( explode( '|', $continue ) );
365 } else {
366 $completeModules = array();
368 } else {
369 $this->mUseLegacyContinue = true;
370 $completeModules = null;
375 * Validate sub-modules, filter out completed ones, and do requestExtraData()
376 * @param array $allModules An dict of name=>instance of all modules requested by the client
377 * @param array|null $completeModules list of finished modules, or null if legacy continue
378 * @param bool $usePageset True if pageset will be executed
379 * @return array of modules to be processed during this execution
381 private function initModules( $allModules, $completeModules, $usePageset ) {
382 $modules = $allModules;
383 $tmp = $completeModules;
384 $wasPosted = $this->getRequest()->wasPosted();
386 /** @var $module ApiQueryBase */
387 foreach ( $allModules as $moduleName => $module ) {
388 if ( !$wasPosted && $module->mustBePosted() ) {
389 $this->dieUsageMsgOrDebug( array( 'mustbeposted', $moduleName ) );
391 if ( $completeModules !== null && array_key_exists( $moduleName, $completeModules ) ) {
392 // If this module is done, mark all its params as used
393 $module->extractRequestParams();
394 // Make sure this module is not used during execution
395 unset( $modules[$moduleName] );
396 unset( $tmp[$moduleName] );
397 } elseif ( $completeModules === null || $usePageset ) {
398 // Query modules may optimize data requests through the $this->getPageSet()
399 // object by adding extra fields from the page table.
400 // This function will gather all the extra request fields from the modules.
401 $module->requestExtraData( $this->mPageSet );
402 } else {
403 // Error - this prop module must have finished before generator is done
404 $this->dieContinueUsageIf( $this->mModuleMgr->getModuleGroup( $moduleName ) === 'prop' );
407 $this->dieContinueUsageIf( $completeModules !== null && count( $tmp ) !== 0 );
408 return $modules;
412 * Update a cache mode string, applying the cache mode of a new module to it.
413 * The cache mode may increase in the level of privacy, but public modules
414 * added to private data do not decrease the level of privacy.
416 * @param $cacheMode string
417 * @param $modCacheMode string
418 * @return string
420 protected function mergeCacheMode( $cacheMode, $modCacheMode ) {
421 if ( $modCacheMode === 'anon-public-user-private' ) {
422 if ( $cacheMode !== 'private' ) {
423 $cacheMode = 'anon-public-user-private';
425 } elseif ( $modCacheMode === 'public' ) {
426 // do nothing, if it's public already it will stay public
427 } else { // private
428 $cacheMode = 'private';
430 return $cacheMode;
434 * Create instances of all modules requested by the client
435 * @param array $modules to append instantiated modules to
436 * @param string $param Parameter name to read modules from
438 private function instantiateModules( &$modules, $param ) {
439 if ( isset( $this->mParams[$param] ) ) {
440 foreach ( $this->mParams[$param] as $moduleName ) {
441 $instance = $this->mModuleMgr->getModule( $moduleName, $param );
442 if ( $instance === null ) {
443 ApiBase::dieDebug( __METHOD__, 'Error instantiating module' );
445 // Ignore duplicates. TODO 2.0: die()?
446 if ( !array_key_exists( $moduleName, $modules ) ) {
447 $modules[$moduleName] = $instance;
454 * Appends an element for each page in the current pageSet with the
455 * most general information (id, title), plus any title normalizations
456 * and missing or invalid title/pageids/revids.
458 private function outputGeneralPageInfo() {
459 $pageSet = $this->getPageSet();
460 $result = $this->getResult();
462 // We don't check for a full result set here because we can't be adding
463 // more than 380K. The maximum revision size is in the megabyte range,
464 // and the maximum result size must be even higher than that.
466 $values = $pageSet->getNormalizedTitlesAsResult( $result );
467 if ( $values ) {
468 $result->addValue( 'query', 'normalized', $values );
470 $values = $pageSet->getConvertedTitlesAsResult( $result );
471 if ( $values ) {
472 $result->addValue( 'query', 'converted', $values );
474 $values = $pageSet->getInterwikiTitlesAsResult( $result, $this->mParams['iwurl'] );
475 if ( $values ) {
476 $result->addValue( 'query', 'interwiki', $values );
478 $values = $pageSet->getRedirectTitlesAsResult( $result );
479 if ( $values ) {
480 $result->addValue( 'query', 'redirects', $values );
482 $values = $pageSet->getMissingRevisionIDsAsResult( $result );
483 if ( $values ) {
484 $result->addValue( 'query', 'badrevids', $values );
487 // Page elements
488 $pages = array();
490 // Report any missing titles
491 foreach ( $pageSet->getMissingTitles() as $fakeId => $title ) {
492 $vals = array();
493 ApiQueryBase::addTitleInfo( $vals, $title );
494 $vals['missing'] = '';
495 $pages[$fakeId] = $vals;
497 // Report any invalid titles
498 foreach ( $pageSet->getInvalidTitles() as $fakeId => $title ) {
499 $pages[$fakeId] = array( 'title' => $title, 'invalid' => '' );
501 // Report any missing page ids
502 foreach ( $pageSet->getMissingPageIDs() as $pageid ) {
503 $pages[$pageid] = array(
504 'pageid' => $pageid,
505 'missing' => ''
508 // Report special pages
509 /** @var $title Title */
510 foreach ( $pageSet->getSpecialTitles() as $fakeId => $title ) {
511 $vals = array();
512 ApiQueryBase::addTitleInfo( $vals, $title );
513 $vals['special'] = '';
514 if ( $title->isSpecialPage() &&
515 !SpecialPageFactory::exists( $title->getDBkey() ) ) {
516 $vals['missing'] = '';
517 } elseif ( $title->getNamespace() == NS_MEDIA &&
518 !wfFindFile( $title ) ) {
519 $vals['missing'] = '';
521 $pages[$fakeId] = $vals;
524 // Output general page information for found titles
525 foreach ( $pageSet->getGoodTitles() as $pageid => $title ) {
526 $vals = array();
527 $vals['pageid'] = $pageid;
528 ApiQueryBase::addTitleInfo( $vals, $title );
529 $pages[$pageid] = $vals;
532 if ( count( $pages ) ) {
533 if ( $this->mParams['indexpageids'] ) {
534 $pageIDs = array_keys( $pages );
535 // json treats all map keys as strings - converting to match
536 $pageIDs = array_map( 'strval', $pageIDs );
537 $result->setIndexedTagName( $pageIDs, 'id' );
538 $result->addValue( 'query', 'pageids', $pageIDs );
541 $result->setIndexedTagName( $pages, 'page' );
542 $result->addValue( 'query', 'pages', $pages );
544 if ( $this->mParams['export'] ) {
545 $this->doExport( $pageSet, $result );
550 * This method is called by the generator base when generator in the smart-continue
551 * mode tries to set 'query-continue' value. ApiQuery stores those values separately
552 * until the post-processing when it is known if the generation should continue or repeat.
553 * @param ApiQueryGeneratorBase $module generator module
554 * @param string $paramName
555 * @param mixed $paramValue
556 * @return bool true if processed, false if this is a legacy continue
558 public function setGeneratorContinue( $module, $paramName, $paramValue ) {
559 if ( $this->mUseLegacyContinue ) {
560 return false;
562 $paramName = $module->encodeParamName( $paramName );
563 if ( $this->mGeneratorContinue === null ) {
564 $this->mGeneratorContinue = array();
566 $this->mGeneratorContinue[$paramName] = $paramValue;
567 return true;
571 * @param $pageSet ApiPageSet Pages to be exported
572 * @param $result ApiResult Result to output to
574 private function doExport( $pageSet, $result ) {
575 $exportTitles = array();
576 $titles = $pageSet->getGoodTitles();
577 if ( count( $titles ) ) {
578 $user = $this->getUser();
579 /** @var $title Title */
580 foreach ( $titles as $title ) {
581 if ( $title->userCan( 'read', $user ) ) {
582 $exportTitles[] = $title;
587 $exporter = new WikiExporter( $this->getDB() );
588 // WikiExporter writes to stdout, so catch its
589 // output with an ob
590 ob_start();
591 $exporter->openStream();
592 foreach ( $exportTitles as $title ) {
593 $exporter->pageByTitle( $title );
595 $exporter->closeStream();
596 $exportxml = ob_get_contents();
597 ob_end_clean();
599 // Don't check the size of exported stuff
600 // It's not continuable, so it would cause more
601 // problems than it'd solve
602 $result->disableSizeCheck();
603 if ( $this->mParams['exportnowrap'] ) {
604 $result->reset();
605 // Raw formatter will handle this
606 $result->addValue( null, 'text', $exportxml );
607 $result->addValue( null, 'mime', 'text/xml' );
608 } else {
609 $r = array();
610 ApiResult::setContent( $r, $exportxml );
611 $result->addValue( 'query', 'export', $r );
613 $result->enableSizeCheck();
616 public function getAllowedParams( $flags = 0 ) {
617 $result = array(
618 'prop' => array(
619 ApiBase::PARAM_ISMULTI => true,
620 ApiBase::PARAM_TYPE => $this->mModuleMgr->getNames( 'prop' )
622 'list' => array(
623 ApiBase::PARAM_ISMULTI => true,
624 ApiBase::PARAM_TYPE => $this->mModuleMgr->getNames( 'list' )
626 'meta' => array(
627 ApiBase::PARAM_ISMULTI => true,
628 ApiBase::PARAM_TYPE => $this->mModuleMgr->getNames( 'meta' )
630 'indexpageids' => false,
631 'export' => false,
632 'exportnowrap' => false,
633 'iwurl' => false,
634 'continue' => null,
636 if ( $flags ) {
637 $result += $this->getPageSet()->getFinalParams( $flags );
639 return $result;
643 * Override the parent to generate help messages for all available query modules.
644 * @return string
646 public function makeHelpMsg() {
648 // Use parent to make default message for the query module
649 $msg = parent::makeHelpMsg();
651 $querySeparator = str_repeat( '--- ', 12 );
652 $moduleSeparator = str_repeat( '*** ', 14 );
653 $msg .= "\n$querySeparator Query: Prop $querySeparator\n\n";
654 $msg .= $this->makeHelpMsgHelper( 'prop' );
655 $msg .= "\n$querySeparator Query: List $querySeparator\n\n";
656 $msg .= $this->makeHelpMsgHelper( 'list' );
657 $msg .= "\n$querySeparator Query: Meta $querySeparator\n\n";
658 $msg .= $this->makeHelpMsgHelper( 'meta' );
659 $msg .= "\n\n$moduleSeparator Modules: continuation $moduleSeparator\n\n";
661 return $msg;
665 * For all modules of a given group, generate help messages and join them together
666 * @param string $group Module group
667 * @return string
669 private function makeHelpMsgHelper( $group ) {
670 $moduleDescriptions = array();
672 $moduleNames = $this->mModuleMgr->getNames( $group );
673 sort( $moduleNames );
674 foreach ( $moduleNames as $name ) {
676 * @var $module ApiQueryBase
678 $module = $this->mModuleMgr->getModule( $name );
680 $msg = ApiMain::makeHelpMsgHeader( $module, $group );
681 $msg2 = $module->makeHelpMsg();
682 if ( $msg2 !== false ) {
683 $msg .= $msg2;
685 if ( $module instanceof ApiQueryGeneratorBase ) {
686 $msg .= "Generator:\n This module may be used as a generator\n";
688 $moduleDescriptions[] = $msg;
691 return implode( "\n", $moduleDescriptions );
694 public function shouldCheckMaxlag() {
695 return true;
698 public function getParamDescription() {
699 return $this->getPageSet()->getFinalParamDescription() + array(
700 'prop' => 'Which properties to get for the titles/revisions/pageids. Module help is available below',
701 'list' => 'Which lists to get. Module help is available below',
702 'meta' => 'Which metadata to get about the site. Module help is available below',
703 'indexpageids' => 'Include an additional pageids section listing all returned page IDs',
704 'export' => 'Export the current revisions of all given or generated pages',
705 'exportnowrap' => 'Return the export XML without wrapping it in an XML result (same format as Special:Export). Can only be used with export',
706 'iwurl' => 'Whether to get the full URL if the title is an interwiki link',
707 'continue' => array(
708 'When present, formats query-continue as key-value pairs that should simply be merged into the original request.',
709 'This parameter must be set to an empty string in the initial query.',
710 'This parameter is recommended for all new development, and will be made default in the next API version.' ),
714 public function getDescription() {
715 return array(
716 'Query API module allows applications to get needed pieces of data from the MediaWiki databases,',
717 'and is loosely based on the old query.php interface.',
718 'All data modifications will first have to use query to acquire a token to prevent abuse from malicious sites'
722 public function getPossibleErrors() {
723 return array_merge(
724 parent::getPossibleErrors(),
725 $this->getPageSet()->getFinalPossibleErrors()
729 public function getExamples() {
730 return array(
731 'api.php?action=query&prop=revisions&meta=siteinfo&titles=Main%20Page&rvprop=user|comment&continue=',
732 'api.php?action=query&generator=allpages&gapprefix=API/&prop=revisions&continue=',
736 public function getHelpUrls() {
737 return array(
738 'https://www.mediawiki.org/wiki/API:Query',
739 'https://www.mediawiki.org/wiki/API:Meta',
740 'https://www.mediawiki.org/wiki/API:Properties',
741 'https://www.mediawiki.org/wiki/API:Lists',