MediaWiki  master
ApiQuery.php
Go to the documentation of this file.
1 <?php
25 
37 class ApiQuery extends ApiBase {
38 
42  private const QUERY_PROP_MODULES = [
43  'categories' => [
44  'class' => ApiQueryCategories::class,
45  ],
46  'categoryinfo' => [
47  'class' => ApiQueryCategoryInfo::class,
48  ],
49  'contributors' => [
50  'class' => ApiQueryContributors::class,
51  'services' => [
52  'RevisionStore',
53  'ActorMigration',
54  'UserGroupManager',
55  'GroupPermissionsLookup',
56  ]
57  ],
58  'deletedrevisions' => [
59  'class' => ApiQueryDeletedRevisions::class,
60  'services' => [
61  'RevisionStore',
62  'ContentHandlerFactory',
63  'ParserFactory',
64  'SlotRoleRegistry',
65  'ChangeTagDefStore',
66  'LinkBatchFactory',
67  'ContentTransformer',
68  ]
69  ],
70  'duplicatefiles' => [
71  'class' => ApiQueryDuplicateFiles::class,
72  'services' => [
73  'RepoGroup',
74  ]
75  ],
76  'extlinks' => [
77  'class' => ApiQueryExternalLinks::class,
78  ],
79  'fileusage' => [
80  'class' => ApiQueryBacklinksprop::class,
81  ],
82  'images' => [
83  'class' => ApiQueryImages::class,
84  ],
85  'imageinfo' => [
86  'class' => ApiQueryImageInfo::class,
87  'services' => [
88  // Same as for stashimageinfo
89  'RepoGroup',
90  'ContentLanguage',
91  'BadFileLookup',
92  ]
93  ],
94  'info' => [
95  'class' => ApiQueryInfo::class,
96  'services' => [
97  'ContentLanguage',
98  'LinkBatchFactory',
99  'NamespaceInfo',
100  'TitleFactory',
101  'TitleFormatter',
102  'WatchedItemStore',
103  'LanguageConverterFactory',
104  ],
105  ],
106  'links' => [
107  'class' => ApiQueryLinks::class,
108  'services' => [
109  'LinkBatchFactory',
110  ]
111  ],
112  'linkshere' => [
113  'class' => ApiQueryBacklinksprop::class,
114  ],
115  'iwlinks' => [
116  'class' => ApiQueryIWLinks::class,
117  ],
118  'langlinks' => [
119  'class' => ApiQueryLangLinks::class,
120  'services' => [
121  'LanguageNameUtils',
122  'ContentLanguage',
123  ]
124  ],
125  'pageprops' => [
126  'class' => ApiQueryPageProps::class,
127  'services' => [
128  'PageProps',
129  ]
130  ],
131  'redirects' => [
132  'class' => ApiQueryBacklinksprop::class,
133  ],
134  'revisions' => [
135  'class' => ApiQueryRevisions::class,
136  'services' => [
137  'RevisionStore',
138  'ContentHandlerFactory',
139  'ParserFactory',
140  'SlotRoleRegistry',
141  'ChangeTagDefStore',
142  'ActorMigration',
143  'ContentTransformer',
144  ]
145  ],
146  'stashimageinfo' => [
147  'class' => ApiQueryStashImageInfo::class,
148  'services' => [
149  // Same as for imageinfo
150  'RepoGroup',
151  'ContentLanguage',
152  'BadFileLookup',
153  ]
154  ],
155  'templates' => [
156  'class' => ApiQueryLinks::class,
157  'services' => [
158  'LinkBatchFactory',
159  ]
160  ],
161  'transcludedin' => [
162  'class' => ApiQueryBacklinksprop::class,
163  ],
164  ];
165 
169  private const QUERY_LIST_MODULES = [
170  'allcategories' => [
171  'class' => ApiQueryAllCategories::class,
172  ],
173  'alldeletedrevisions' => [
174  'class' => ApiQueryAllDeletedRevisions::class,
175  'services' => [
176  'RevisionStore',
177  'ContentHandlerFactory',
178  'ParserFactory',
179  'SlotRoleRegistry',
180  'ChangeTagDefStore',
181  'NamespaceInfo',
182  'ContentTransformer',
183  ]
184  ],
185  'allfileusages' => [
186  'class' => ApiQueryAllLinks::class,
187  'services' => [
188  // Same as for alllinks, allredirects, alltransclusions
189  'NamespaceInfo',
190  'GenderCache',
191  ]
192  ],
193  'allimages' => [
194  'class' => ApiQueryAllImages::class,
195  'services' => [
196  'RepoGroup',
197  'GroupPermissionsLookup',
198  ]
199  ],
200  'alllinks' => [
201  'class' => ApiQueryAllLinks::class,
202  'services' => [
203  // Same as for allfileusages, allredirects, alltransclusions
204  'NamespaceInfo',
205  'GenderCache',
206  ]
207  ],
208  'allpages' => [
209  'class' => ApiQueryAllPages::class,
210  'services' => [
211  'NamespaceInfo',
212  'GenderCache',
213  ]
214  ],
215  'allredirects' => [
216  'class' => ApiQueryAllLinks::class,
217  'services' => [
218  // Same as for allfileusages, alllinks, alltransclusions
219  'NamespaceInfo',
220  'GenderCache',
221  ]
222  ],
223  'allrevisions' => [
224  'class' => ApiQueryAllRevisions::class,
225  'services' => [
226  'RevisionStore',
227  'ContentHandlerFactory',
228  'ParserFactory',
229  'SlotRoleRegistry',
230  'ActorMigration',
231  'NamespaceInfo',
232  'ContentTransformer',
233  ]
234  ],
235  'mystashedfiles' => [
236  'class' => ApiQueryMyStashedFiles::class,
237  ],
238  'alltransclusions' => [
239  'class' => ApiQueryAllLinks::class,
240  'services' => [
241  // Same as for allfileusages, alllinks, allredirects
242  'NamespaceInfo',
243  'GenderCache',
244  ]
245  ],
246  'allusers' => [
247  'class' => ApiQueryAllUsers::class,
248  'services' => [
249  'UserFactory',
250  'UserGroupManager',
251  'GroupPermissionsLookup',
252  ]
253  ],
254  'backlinks' => [
255  'class' => ApiQueryBacklinks::class,
256  ],
257  'blocks' => [
258  'class' => ApiQueryBlocks::class,
259  'services' => [
260  'BlockActionInfo',
261  'BlockRestrictionStore',
262  'CommentStore',
263  'UserNameUtils',
264  ],
265  ],
266  'categorymembers' => [
267  'class' => ApiQueryCategoryMembers::class,
268  'services' => [
269  'CollationFactory',
270  ]
271  ],
272  'deletedrevs' => [
273  'class' => ApiQueryDeletedrevs::class,
274  'services' => [
275  'CommentStore',
276  'RevisionStore',
277  'ChangeTagDefStore',
278  'LinkBatchFactory',
279  ],
280  ],
281  'embeddedin' => [
282  'class' => ApiQueryBacklinks::class,
283  ],
284  'exturlusage' => [
285  'class' => ApiQueryExtLinksUsage::class,
286  ],
287  'filearchive' => [
288  'class' => ApiQueryFilearchive::class,
289  'services' => [
290  'CommentStore',
291  ],
292  ],
293  'imageusage' => [
294  'class' => ApiQueryBacklinks::class,
295  ],
296  'iwbacklinks' => [
297  'class' => ApiQueryIWBacklinks::class,
298  ],
299  'langbacklinks' => [
300  'class' => ApiQueryLangBacklinks::class,
301  ],
302  'logevents' => [
303  'class' => ApiQueryLogEvents::class,
304  'services' => [
305  'CommentStore',
306  'ChangeTagDefStore',
307  ],
308  ],
309  'pageswithprop' => [
310  'class' => ApiQueryPagesWithProp::class,
311  ],
312  'pagepropnames' => [
313  'class' => ApiQueryPagePropNames::class,
314  ],
315  'prefixsearch' => [
316  'class' => ApiQueryPrefixSearch::class,
317  'services' => [
318  'SearchEngineConfig',
319  'SearchEngineFactory',
320  ],
321  ],
322  'protectedtitles' => [
323  'class' => ApiQueryProtectedTitles::class,
324  'services' => [
325  'CommentStore',
326  ],
327  ],
328  'querypage' => [
329  'class' => ApiQueryQueryPage::class,
330  'services' => [
331  'SpecialPageFactory',
332  ]
333  ],
334  'random' => [
335  'class' => ApiQueryRandom::class,
336  ],
337  'recentchanges' => [
338  'class' => ApiQueryRecentChanges::class,
339  'services' => [
340  'CommentStore',
341  'ChangeTagDefStore',
342  'SlotRoleStore',
343  'SlotRoleRegistry',
344  ],
345  ],
346  'search' => [
347  'class' => ApiQuerySearch::class,
348  'services' => [
349  'SearchEngineConfig',
350  'SearchEngineFactory',
351  ],
352  ],
353  'tags' => [
354  'class' => ApiQueryTags::class,
355  ],
356  'usercontribs' => [
357  'class' => ApiQueryUserContribs::class,
358  'services' => [
359  'CommentStore',
360  'UserIdentityLookup',
361  'UserNameUtils',
362  'RevisionStore',
363  'ChangeTagDefStore',
364  'ActorMigration',
365  ],
366  ],
367  'users' => [
368  'class' => ApiQueryUsers::class,
369  'services' => [
370  'UserNameUtils',
371  'UserFactory',
372  'UserGroupManager',
373  'UserOptionsLookup',
374  'AuthManager',
375  ],
376  ],
377  'watchlist' => [
378  'class' => ApiQueryWatchlist::class,
379  'services' => [
380  'CommentStore',
381  'WatchedItemQueryService',
382  'ContentLanguage',
383  'NamespaceInfo',
384  'GenderCache',
385  ],
386  ],
387  'watchlistraw' => [
388  'class' => ApiQueryWatchlistRaw::class,
389  'services' => [
390  'WatchedItemQueryService',
391  'ContentLanguage',
392  'NamespaceInfo',
393  'GenderCache',
394  ]
395  ],
396  ];
397 
401  private const QUERY_META_MODULES = [
402  'allmessages' => [
403  'class' => ApiQueryAllMessages::class,
404  'services' => [
405  'ContentLanguage',
406  'LanguageFactory',
407  'LanguageNameUtils',
408  'LocalisationCache',
409  'MessageCache',
410  ]
411  ],
412  'authmanagerinfo' => [
413  'class' => ApiQueryAuthManagerInfo::class,
414  'services' => [
415  'AuthManager',
416  ]
417  ],
418  'siteinfo' => [
419  'class' => ApiQuerySiteinfo::class,
420  'services' => [
421  'UserOptionsLookup',
422  'UserGroupManager',
423  'LanguageConverterFactory',
424  'LanguageFactory',
425  'LanguageNameUtils',
426  'ContentLanguage',
427  'NamespaceInfo',
428  'InterwikiLookup',
429  'Parser',
430  'MagicWordFactory',
431  'SpecialPageFactory',
432  'SkinFactory',
433  'DBLoadBalancer',
434  'ReadOnlyMode',
435  ]
436  ],
437  'userinfo' => [
438  'class' => ApiQueryUserInfo::class,
439  'services' => [
440  'TalkPageNotificationManager',
441  'WatchedItemStore',
442  'UserEditTracker',
443  'UserOptionsLookup',
444  'UserGroupManager',
445  ]
446  ],
447  'filerepoinfo' => [
448  'class' => ApiQueryFileRepoInfo::class,
449  'services' => [
450  'RepoGroup',
451  ]
452  ],
453  'tokens' => [
454  'class' => ApiQueryTokens::class,
455  ],
456  'languageinfo' => [
457  'class' => ApiQueryLanguageinfo::class,
458  'services' => [
459  'LanguageFactory',
460  'LanguageNameUtils',
461  'LanguageFallback',
462  'LanguageConverterFactory',
463  ],
464  ],
465  ];
466 
470  private $mPageSet;
471 
472  private $mParams;
473  private $mNamedDB = [];
474  private $mModuleMgr;
475 
480  public function __construct( ApiMain $main, $action ) {
481  parent::__construct( $main, $action );
482 
483  $this->mModuleMgr = new ApiModuleManager(
484  $this,
485  MediaWikiServices::getInstance()->getObjectFactory()
486  );
487 
488  // Allow custom modules to be added in LocalSettings.php
489  $config = $this->getConfig();
490  $this->mModuleMgr->addModules( self::QUERY_PROP_MODULES, 'prop' );
491  $this->mModuleMgr->addModules( $config->get( 'APIPropModules' ), 'prop' );
492  $this->mModuleMgr->addModules( self::QUERY_LIST_MODULES, 'list' );
493  $this->mModuleMgr->addModules( $config->get( 'APIListModules' ), 'list' );
494  $this->mModuleMgr->addModules( self::QUERY_META_MODULES, 'meta' );
495  $this->mModuleMgr->addModules( $config->get( 'APIMetaModules' ), 'meta' );
496 
497  $this->getHookRunner()->onApiQuery__moduleManager( $this->mModuleMgr );
498 
499  // Create PageSet that will process titles/pageids/revids/generator
500  $this->mPageSet = new ApiPageSet( $this );
501  }
502 
507  public function getModuleManager() {
508  return $this->mModuleMgr;
509  }
510 
521  public function getNamedDB( $name, $db, $groups ) {
522  if ( !array_key_exists( $name, $this->mNamedDB ) ) {
523  $this->mNamedDB[$name] = wfGetDB( $db, $groups );
524  }
525 
526  return $this->mNamedDB[$name];
527  }
528 
533  public function getPageSet() {
534  return $this->mPageSet;
535  }
536 
540  public function getCustomPrinter() {
541  // If &exportnowrap is set, use the raw formatter
542  if ( $this->getParameter( 'export' ) &&
543  $this->getParameter( 'exportnowrap' )
544  ) {
545  return new ApiFormatRaw( $this->getMain(),
546  $this->getMain()->createPrinterByName( 'xml' ) );
547  } else {
548  return null;
549  }
550  }
551 
562  public function execute() {
563  $this->mParams = $this->extractRequestParams();
564 
565  // Instantiate requested modules
566  $allModules = [];
567  $this->instantiateModules( $allModules, 'prop' );
568  $propModules = array_keys( $allModules );
569  $this->instantiateModules( $allModules, 'list' );
570  $this->instantiateModules( $allModules, 'meta' );
571 
572  // Filter modules based on continue parameter
573  $continuationManager = new ApiContinuationManager( $this, $allModules, $propModules );
574  $this->setContinuationManager( $continuationManager );
576  $modules = $continuationManager->getRunModules();
577  '@phan-var ApiQueryBase[] $modules';
578 
579  if ( !$continuationManager->isGeneratorDone() ) {
580  // Query modules may optimize data requests through the $this->getPageSet()
581  // object by adding extra fields from the page table.
582  foreach ( $modules as $module ) {
583  $module->requestExtraData( $this->mPageSet );
584  }
585  // Populate page/revision information
586  $this->mPageSet->execute();
587  // Record page information (title, namespace, if exists, etc)
588  $this->outputGeneralPageInfo();
589  } else {
590  $this->mPageSet->executeDryRun();
591  }
592 
593  $cacheMode = $this->mPageSet->getCacheMode();
594 
595  // Execute all unfinished modules
596  foreach ( $modules as $module ) {
597  $params = $module->extractRequestParams();
598  $cacheMode = $this->mergeCacheMode(
599  $cacheMode, $module->getCacheMode( $params ) );
600  $module->execute();
601  $this->getHookRunner()->onAPIQueryAfterExecute( $module );
602  }
603 
604  // Set the cache mode
605  $this->getMain()->setCacheMode( $cacheMode );
606 
607  // Write the continuation data into the result
608  $this->setContinuationManager( null );
609  if ( $this->mParams['rawcontinue'] ) {
610  $data = $continuationManager->getRawNonContinuation();
611  if ( $data ) {
612  $this->getResult()->addValue( null, 'query-noncontinue', $data,
614  }
615  $data = $continuationManager->getRawContinuation();
616  if ( $data ) {
617  $this->getResult()->addValue( null, 'query-continue', $data,
619  }
620  } else {
621  $continuationManager->setContinuationIntoResult( $this->getResult() );
622  }
623  }
624 
634  protected function mergeCacheMode( $cacheMode, $modCacheMode ) {
635  if ( $modCacheMode === 'anon-public-user-private' ) {
636  if ( $cacheMode !== 'private' ) {
637  $cacheMode = 'anon-public-user-private';
638  }
639  } elseif ( $modCacheMode === 'public' ) {
640  // do nothing, if it's public already it will stay public
641  } else {
642  $cacheMode = 'private';
643  }
644 
645  return $cacheMode;
646  }
647 
653  private function instantiateModules( &$modules, $param ) {
654  $wasPosted = $this->getRequest()->wasPosted();
655  if ( isset( $this->mParams[$param] ) ) {
656  foreach ( $this->mParams[$param] as $moduleName ) {
657  $instance = $this->mModuleMgr->getModule( $moduleName, $param );
658  if ( $instance === null ) {
659  ApiBase::dieDebug( __METHOD__, 'Error instantiating module' );
660  }
661  if ( !$wasPosted && $instance->mustBePosted() ) {
662  $this->dieWithErrorOrDebug( [ 'apierror-mustbeposted', $moduleName ] );
663  }
664  // Ignore duplicates. TODO 2.0: die()?
665  if ( !array_key_exists( $moduleName, $modules ) ) {
666  $modules[$moduleName] = $instance;
667  }
668  }
669  }
670  }
671 
677  private function outputGeneralPageInfo() {
678  $pageSet = $this->getPageSet();
679  $result = $this->getResult();
680 
681  // We can't really handle max-result-size failure here, but we need to
682  // check anyway in case someone set the limit stupidly low.
683  $fit = true;
684 
685  $values = $pageSet->getNormalizedTitlesAsResult( $result );
686  if ( $values ) {
687  // @phan-suppress-next-line PhanRedundantCondition
688  $fit = $fit && $result->addValue( 'query', 'normalized', $values );
689  }
690  $values = $pageSet->getConvertedTitlesAsResult( $result );
691  if ( $values ) {
692  $fit = $fit && $result->addValue( 'query', 'converted', $values );
693  }
694  $values = $pageSet->getInterwikiTitlesAsResult( $result, $this->mParams['iwurl'] );
695  if ( $values ) {
696  $fit = $fit && $result->addValue( 'query', 'interwiki', $values );
697  }
698  $values = $pageSet->getRedirectTitlesAsResult( $result );
699  if ( $values ) {
700  $fit = $fit && $result->addValue( 'query', 'redirects', $values );
701  }
702  $values = $pageSet->getMissingRevisionIDsAsResult( $result );
703  if ( $values ) {
704  $fit = $fit && $result->addValue( 'query', 'badrevids', $values );
705  }
706 
707  // Page elements
708  $pages = [];
709 
710  // Report any missing titles
711  foreach ( $pageSet->getMissingTitles() as $fakeId => $title ) {
712  $vals = [];
714  $vals['missing'] = true;
715  if ( $title->isKnown() ) {
716  $vals['known'] = true;
717  }
718  $pages[$fakeId] = $vals;
719  }
720  // Report any invalid titles
721  foreach ( $pageSet->getInvalidTitlesAndReasons() as $fakeId => $data ) {
722  $pages[$fakeId] = $data + [ 'invalid' => true ];
723  }
724  // Report any missing page ids
725  foreach ( $pageSet->getMissingPageIDs() as $pageid ) {
726  $pages[$pageid] = [
727  'pageid' => $pageid,
728  'missing' => true,
729  ];
730  }
731  // Report special pages
733  foreach ( $pageSet->getSpecialTitles() as $fakeId => $title ) {
734  $vals = [];
736  $vals['special'] = true;
737  if ( !$title->isKnown() ) {
738  $vals['missing'] = true;
739  }
740  $pages[$fakeId] = $vals;
741  }
742 
743  // Output general page information for found titles
744  foreach ( $pageSet->getGoodTitles() as $pageid => $title ) {
745  $vals = [];
746  $vals['pageid'] = $pageid;
748  $pages[$pageid] = $vals;
749  }
750 
751  if ( count( $pages ) ) {
752  $pageSet->populateGeneratorData( $pages );
753  ApiResult::setArrayType( $pages, 'BCarray' );
754 
755  if ( $this->mParams['indexpageids'] ) {
756  $pageIDs = array_keys( ApiResult::stripMetadataNonRecursive( $pages ) );
757  // json treats all map keys as strings - converting to match
758  $pageIDs = array_map( 'strval', $pageIDs );
759  ApiResult::setIndexedTagName( $pageIDs, 'id' );
760  $fit = $fit && $result->addValue( 'query', 'pageids', $pageIDs );
761  }
762 
763  ApiResult::setIndexedTagName( $pages, 'page' );
764  $fit = $fit && $result->addValue( 'query', 'pages', $pages );
765  }
766 
767  if ( !$fit ) {
768  $this->dieWithError( 'apierror-badconfig-resulttoosmall', 'badconfig' );
769  }
770 
771  if ( $this->mParams['export'] ) {
772  $this->doExport( $pageSet, $result );
773  }
774  }
775 
780  private function doExport( $pageSet, $result ) {
781  $exportTitles = [];
782  $titles = $pageSet->getGoodPages();
783  if ( count( $titles ) ) {
785  foreach ( $titles as $title ) {
786  if ( $this->getAuthority()->authorizeRead( 'read', $title ) ) {
787  $exportTitles[] = $title;
788  }
789  }
790  }
791 
792  $exporter = MediaWikiServices::getInstance()
793  ->getWikiExporterFactory()
794  ->getWikiExporter( $this->getDB() );
795  $sink = new DumpStringOutput;
796  $exporter->setOutputSink( $sink );
797  $exporter->setSchemaVersion( $this->mParams['exportschema'] );
798  $exporter->openStream();
799  foreach ( $exportTitles as $title ) {
800  $exporter->pageByTitle( $title );
801  }
802  $exporter->closeStream();
803 
804  // Don't check the size of exported stuff
805  // It's not continuable, so it would cause more
806  // problems than it'd solve
807  if ( $this->mParams['exportnowrap'] ) {
808  $result->reset();
809  // Raw formatter will handle this
810  $result->addValue( null, 'text', $sink, ApiResult::NO_SIZE_CHECK );
811  $result->addValue( null, 'mime', 'text/xml', ApiResult::NO_SIZE_CHECK );
812  $result->addValue( null, 'filename', 'export.xml', ApiResult::NO_SIZE_CHECK );
813  } else {
814  $result->addValue( 'query', 'export', $sink, ApiResult::NO_SIZE_CHECK );
815  $result->addValue( 'query', ApiResult::META_BC_SUBELEMENTS, [ 'export' ] );
816  }
817  }
818 
819  public function getAllowedParams( $flags = 0 ) {
820  $result = [
821  'prop' => [
822  ApiBase::PARAM_ISMULTI => true,
823  ApiBase::PARAM_TYPE => 'submodule',
824  ],
825  'list' => [
826  ApiBase::PARAM_ISMULTI => true,
827  ApiBase::PARAM_TYPE => 'submodule',
828  ],
829  'meta' => [
830  ApiBase::PARAM_ISMULTI => true,
831  ApiBase::PARAM_TYPE => 'submodule',
832  ],
833  'indexpageids' => false,
834  'export' => false,
835  'exportnowrap' => false,
836  'exportschema' => [
839  ],
840  'iwurl' => false,
841  'continue' => [
842  ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
843  ],
844  'rawcontinue' => false,
845  ];
846  if ( $flags ) {
847  $result += $this->getPageSet()->getFinalParams( $flags );
848  }
849 
850  return $result;
851  }
852 
853  public function isReadMode() {
854  // We need to make an exception for certain meta modules that should be
855  // accessible even without the 'read' right. Restrict the exception as
856  // much as possible: no other modules allowed, and no pageset
857  // parameters either. We do allow the 'rawcontinue' and 'indexpageids'
858  // parameters since frameworks might add these unconditionally and they
859  // can't expose anything here.
860  $allowedParams = [ 'rawcontinue' => 1, 'indexpageids' => 1 ];
861  $this->mParams = $this->extractRequestParams();
862  $request = $this->getRequest();
863  foreach ( $this->mParams + $this->getPageSet()->extractRequestParams() as $param => $value ) {
864  $needed = $param === 'meta';
865  if ( !isset( $allowedParams[$param] ) && $request->getCheck( $param ) !== $needed ) {
866  return true;
867  }
868  }
869 
870  // Ask each module if it requires read mode. Any true => this returns
871  // true.
872  $modules = [];
873  $this->instantiateModules( $modules, 'meta' );
874  foreach ( $modules as $module ) {
875  if ( $module->isReadMode() ) {
876  return true;
877  }
878  }
879 
880  return false;
881  }
882 
883  protected function getExamplesMessages() {
884  return [
885  'action=query&prop=revisions&meta=siteinfo&' .
886  'titles=Main%20Page&rvprop=user|comment&continue='
887  => 'apihelp-query-example-revisions',
888  'action=query&generator=allpages&gapprefix=API/&prop=revisions&continue='
889  => 'apihelp-query-example-allpages',
890  ];
891  }
892 
893  public function getHelpUrls() {
894  return [
895  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Query',
896  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Meta',
897  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Properties',
898  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Lists',
899  ];
900  }
901 }
ApiMain
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:49
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:72
ApiQuery\isReadMode
isReadMode()
Indicates whether this module requires read rights.
Definition: ApiQuery.php:853
WikiExporter\schemaVersion
static schemaVersion()
Returns the default export schema version, as defined by $wgXmlDumpSchemaVersion.
Definition: WikiExporter.php:97
ApiQuery\$mParams
$mParams
Definition: ApiQuery.php:472
ApiQuery
This is the main query class.
Definition: ApiQuery.php:37
ApiQuery\getPageSet
getPageSet()
Gets the set of pages the user has requested (or generated)
Definition: ApiQuery.php:533
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:193
ApiContinuationManager
This manages continuation state.
Definition: ApiContinuationManager.php:26
ApiBase\dieWithError
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition: ApiBase.php:1379
ApiBase\PARAM_HELP_MSG
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:105
true
return true
Definition: router.php:90
ApiResult\META_BC_SUBELEMENTS
const META_BC_SUBELEMENTS
Key for the 'BC subelements' metadata item.
Definition: ApiResult.php:143
ApiBase\PARAM_TYPE
const PARAM_TYPE
Definition: ApiBase.php:72
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:571
ApiBase\dieWithErrorOrDebug
dieWithErrorOrDebug( $msg, $code=null, $data=null, $httpCode=null)
Will only set a warning instead of failing if the global $wgDebugAPI is set to true.
Definition: ApiBase.php:1551
ApiBase\setContinuationManager
setContinuationManager(ApiContinuationManager $manager=null)
Definition: ApiBase.php:615
ApiQuery\QUERY_LIST_MODULES
const QUERY_LIST_MODULES
List of Api Query list modules.
Definition: ApiQuery.php:169
ApiBase\getDB
getDB()
Gets a default replica DB connection object.
Definition: ApiBase.php:594
ApiResult\NO_SIZE_CHECK
const NO_SIZE_CHECK
For addValue() and similar functions, do not check size while adding a value Don't use this unless yo...
Definition: ApiResult.php:58
ContextSource\getRequest
getRequest()
Definition: ContextSource.php:81
XmlDumpWriter\$supportedSchemas
static string[] $supportedSchemas
the schema versions supported for output @final
Definition: XmlDumpWriter.php:57
ApiQuery\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiQuery.php:893
ApiPageSet
This class contains a list of pages that the client has requested.
Definition: ApiPageSet.php:45
ApiBase
This abstract class implements many basic API functions, and is the base of all API classes.
Definition: ApiBase.php:55
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
ApiQuery\QUERY_META_MODULES
const QUERY_META_MODULES
List of Api Query meta modules.
Definition: ApiQuery.php:401
ApiQuery\__construct
__construct(ApiMain $main, $action)
Definition: ApiQuery.php:480
ApiResult\setArrayType
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:715
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2203
$modules
$modules
Definition: HTMLFormElement.php:15
ApiFormatRaw
Formatter that spits out anything you like with any desired MIME type.
Definition: ApiFormatRaw.php:27
ApiQuery\getNamedDB
getNamedDB( $name, $db, $groups)
Get the query database connection with the given name.
Definition: ApiQuery.php:521
ApiBase\extractRequestParams
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:707
ApiResult\stripMetadataNonRecursive
static stripMetadataNonRecursive( $data, &$metadata=null)
Remove metadata keys from a data array or object, non-recursive.
Definition: ApiResult.php:1045
$title
$title
Definition: testCompression.php:38
ApiModuleManager
This class holds a list of modules and handles instantiation.
Definition: ApiModuleManager.php:33
ApiResult\setIndexedTagName
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:603
ContextSource\getAuthority
getAuthority()
Definition: ContextSource.php:144
ApiQuery\doExport
doExport( $pageSet, $result)
Definition: ApiQuery.php:780
ApiQuery\getModuleManager
getModuleManager()
Overrides to return this instance's module manager.
Definition: ApiQuery.php:507
Title
Represents a title within MediaWiki.
Definition: Title.php:48
ApiQuery\getCustomPrinter
getCustomPrinter()
Definition: ApiQuery.php:540
ApiResult\ADD_ON_TOP
const ADD_ON_TOP
For addValue(), setValue() and similar functions, if the value does not exist, add it as the first el...
Definition: ApiResult.php:49
ApiQuery\QUERY_PROP_MODULES
const QUERY_PROP_MODULES
List of Api Query prop modules.
Definition: ApiQuery.php:42
ApiQuery\mergeCacheMode
mergeCacheMode( $cacheMode, $modCacheMode)
Update a cache mode string, applying the cache mode of a new module to it.
Definition: ApiQuery.php:634
ApiQuery\$mPageSet
ApiPageSet $mPageSet
Definition: ApiQuery.php:470
ApiBase\PARAM_DFLT
const PARAM_DFLT
Definition: ApiBase.php:70
ApiQuery\outputGeneralPageInfo
outputGeneralPageInfo()
Appends an element for each page in the current pageSet with the most general information (id,...
Definition: ApiQuery.php:677
ApiQuery\getAllowedParams
getAllowedParams( $flags=0)
Definition: ApiQuery.php:819
ApiBase\getParameter
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
Definition: ApiBase.php:827
ApiQuery\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiQuery.php:883
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
Definition: ApiBase.php:71
ApiQuery\$mModuleMgr
$mModuleMgr
Definition: ApiQuery.php:474
ApiBase\getMain
getMain()
Get the main module.
Definition: ApiBase.php:456
ApiBase\getHookRunner
getHookRunner()
Get an ApiHookRunner for running core API hooks.
Definition: ApiBase.php:653
ApiQuery\execute
execute()
Query execution happens in the following steps: #1 Create a PageSet object with any pages requested b...
Definition: ApiQuery.php:562
ApiBase\dieDebug
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition: ApiBase.php:1582
ApiQuery\$mNamedDB
$mNamedDB
Definition: ApiQuery.php:473
DumpStringOutput
Definition: DumpStringOutput.php:27
ApiQuery\instantiateModules
instantiateModules(&$modules, $param)
Create instances of all modules requested by the client.
Definition: ApiQuery.php:653
ApiQueryBase\addTitleInfo
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:466