MediaWiki REL1_37
ApiQuery.php
Go to the documentation of this file.
1<?php
25
37class 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,
613 ApiResult::ADD_ON_TOP | ApiResult::NO_SIZE_CHECK );
614 }
615 $data = $continuationManager->getRawContinuation();
616 if ( $data ) {
617 $this->getResult()->addValue( null, 'query-continue', $data,
618 ApiResult::ADD_ON_TOP | ApiResult::NO_SIZE_CHECK );
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 = [];
713 ApiQueryBase::addTitleInfo( $vals, $title );
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 = [];
735 ApiQueryBase::addTitleInfo( $vals, $title );
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;
747 ApiQueryBase::addTitleInfo( $vals, $title );
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 = new WikiExporter( $this->getDB() );
793 $sink = new DumpStringOutput;
794 $exporter->setOutputSink( $sink );
795 $exporter->setSchemaVersion( $this->mParams['exportschema'] );
796 $exporter->openStream();
797 foreach ( $exportTitles as $title ) {
798 $exporter->pageByTitle( $title );
799 }
800 $exporter->closeStream();
801
802 // Don't check the size of exported stuff
803 // It's not continuable, so it would cause more
804 // problems than it'd solve
805 if ( $this->mParams['exportnowrap'] ) {
806 $result->reset();
807 // Raw formatter will handle this
808 $result->addValue( null, 'text', $sink, ApiResult::NO_SIZE_CHECK );
809 $result->addValue( null, 'mime', 'text/xml', ApiResult::NO_SIZE_CHECK );
810 $result->addValue( null, 'filename', 'export.xml', ApiResult::NO_SIZE_CHECK );
811 } else {
812 $result->addValue( 'query', 'export', $sink, ApiResult::NO_SIZE_CHECK );
813 $result->addValue( 'query', ApiResult::META_BC_SUBELEMENTS, [ 'export' ] );
814 }
815 }
816
817 public function getAllowedParams( $flags = 0 ) {
818 $result = [
819 'prop' => [
821 ApiBase::PARAM_TYPE => 'submodule',
822 ],
823 'list' => [
825 ApiBase::PARAM_TYPE => 'submodule',
826 ],
827 'meta' => [
829 ApiBase::PARAM_TYPE => 'submodule',
830 ],
831 'indexpageids' => false,
832 'export' => false,
833 'exportnowrap' => false,
834 'exportschema' => [
836 ApiBase::PARAM_TYPE => XmlDumpWriter::$supportedSchemas,
837 ],
838 'iwurl' => false,
839 'continue' => [
840 ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
841 ],
842 'rawcontinue' => false,
843 ];
844 if ( $flags ) {
845 $result += $this->getPageSet()->getFinalParams( $flags );
846 }
847
848 return $result;
849 }
850
851 public function isReadMode() {
852 // We need to make an exception for certain meta modules that should be
853 // accessible even without the 'read' right. Restrict the exception as
854 // much as possible: no other modules allowed, and no pageset
855 // parameters either. We do allow the 'rawcontinue' and 'indexpageids'
856 // parameters since frameworks might add these unconditionally and they
857 // can't expose anything here.
858 $allowedParams = [ 'rawcontinue' => 1, 'indexpageids' => 1 ];
859 $this->mParams = $this->extractRequestParams();
860 $request = $this->getRequest();
861 foreach ( $this->mParams + $this->getPageSet()->extractRequestParams() as $param => $value ) {
862 $needed = $param === 'meta';
863 if ( !isset( $allowedParams[$param] ) && $request->getCheck( $param ) !== $needed ) {
864 return true;
865 }
866 }
867
868 // Ask each module if it requires read mode. Any true => this returns
869 // true.
870 $modules = [];
871 $this->instantiateModules( $modules, 'meta' );
872 foreach ( $modules as $module ) {
873 if ( $module->isReadMode() ) {
874 return true;
875 }
876 }
877
878 return false;
879 }
880
881 protected function getExamplesMessages() {
882 return [
883 'action=query&prop=revisions&meta=siteinfo&' .
884 'titles=Main%20Page&rvprop=user|comment&continue='
885 => 'apihelp-query-example-revisions',
886 'action=query&generator=allpages&gapprefix=API/&prop=revisions&continue='
887 => 'apihelp-query-example-allpages',
888 ];
889 }
890
891 public function getHelpUrls() {
892 return [
893 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Query',
894 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Meta',
895 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Properties',
896 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Lists',
897 ];
898 }
899}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
This abstract class implements many basic API functions, and is the base of all API classes.
Definition ApiBase.php:55
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
Definition ApiBase.php:1436
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
Definition ApiBase.php:884
getDB()
Gets a default replica DB connection object.
Definition ApiBase.php:651
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:1602
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition ApiBase.php:1633
getMain()
Get the main module.
Definition ApiBase.php:513
const PARAM_TYPE
Definition ApiBase.php:81
const PARAM_DFLT
Definition ApiBase.php:73
setContinuationManager(ApiContinuationManager $manager=null)
Definition ApiBase.php:672
getResult()
Get the result object.
Definition ApiBase.php:628
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:764
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:162
getHookRunner()
Get an ApiHookRunner for running core API hooks.
Definition ApiBase.php:710
const PARAM_ISMULTI
Definition ApiBase.php:77
This manages continuation state.
Formatter that spits out anything you like with any desired MIME type.
This is the main API class, used for both external and internal processing.
Definition ApiMain.php:49
This class holds a list of modules and handles instantiation.
This class contains a list of pages that the client has requested.
This is the main query class.
Definition ApiQuery.php:37
isReadMode()
Indicates whether this module requires read rights.
Definition ApiQuery.php:851
const QUERY_PROP_MODULES
List of Api Query prop modules.
Definition ApiQuery.php:42
instantiateModules(&$modules, $param)
Create instances of all modules requested by the client.
Definition ApiQuery.php:653
mergeCacheMode( $cacheMode, $modCacheMode)
Update a cache mode string, applying the cache mode of a new module to it.
Definition ApiQuery.php:634
getAllowedParams( $flags=0)
Definition ApiQuery.php:817
getModuleManager()
Overrides to return this instance's module manager.
Definition ApiQuery.php:507
ApiPageSet $mPageSet
Definition ApiQuery.php:470
__construct(ApiMain $main, $action)
Definition ApiQuery.php:480
const QUERY_META_MODULES
List of Api Query meta modules.
Definition ApiQuery.php:401
outputGeneralPageInfo()
Appends an element for each page in the current pageSet with the most general information (id,...
Definition ApiQuery.php:677
getExamplesMessages()
Returns usage examples for this module.
Definition ApiQuery.php:881
doExport( $pageSet, $result)
Definition ApiQuery.php:780
const QUERY_LIST_MODULES
List of Api Query list modules.
Definition ApiQuery.php:169
getHelpUrls()
Return links to more detailed help pages about the module.
Definition ApiQuery.php:891
getPageSet()
Gets the set of pages the user has requested (or generated)
Definition ApiQuery.php:533
execute()
Query execution happens in the following steps: #1 Create a PageSet object with any pages requested b...
Definition ApiQuery.php:562
getNamedDB( $name, $db, $groups)
Get the query database connection with the given name.
Definition ApiQuery.php:521
getCustomPrinter()
Definition ApiQuery.php:540
MediaWikiServices is the service locator for the application scope of MediaWiki.
Represents a title within MediaWiki.
Definition Title.php:48
static schemaVersion()
Returns the default export schema version, as defined by $wgXmlDumpSchemaVersion.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
return true
Definition router.php:92