63 private Language $contentLanguage;
103 Language $contentLanguage,
115 parent::__construct( $query, $moduleName,
'si' );
116 $this->userOptionsLookup = $userOptionsLookup;
117 $this->userGroupManager = $userGroupManager;
118 $this->languageConverterFactory = $languageConverterFactory;
119 $this->languageFactory = $languageFactory;
120 $this->languageNameUtils = $languageNameUtils;
121 $this->contentLanguage = $contentLanguage;
122 $this->namespaceInfo = $namespaceInfo;
123 $this->interwikiLookup = $interwikiLookup;
124 $this->parserFactory = $parserFactory;
125 $this->magicWordFactory = $magicWordFactory;
126 $this->specialPageFactory = $specialPageFactory;
127 $this->skinFactory = $skinFactory;
128 $this->loadBalancer = $loadBalancer;
129 $this->readOnlyMode = $readOnlyMode;
130 $this->urlUtils = $urlUtils;
131 $this->tempUserConfig = $tempUserConfig;
137 foreach (
$params[
'prop'] as $p ) {
145 case 'namespacealiases':
148 case 'specialpagealiases':
166 case 'autocreatetempuser':
169 case 'clientlibraries':
178 case 'fileextensions':
190 case 'languagevariants':
196 case 'extensiontags':
199 case 'functionhooks':
211 case 'defaultoptions':
218 $fit = $this->appendAutoPromote( $p );
220 case 'autopromoteonce':
221 $fit = $this->appendAutoPromoteOnce( $p );
230 array_diff(
$params[
'prop'], $done ) ) );
239 $mainPage = Title::newMainPage();
240 $logo = SkinModule::getAvailableLogos( $config, $this->
getLanguage()->getCode() );
243 'mainpage' => $mainPage->getPrefixedText(),
244 'base' => (string)$this->urlUtils->expand( $mainPage->getFullURL(),
PROTO_CURRENT ),
245 'sitename' => $config->get( MainConfigNames::Sitename ),
246 'mainpageisdomainroot' => (bool)$config->get( MainConfigNames::MainPageIsDomainRoot ),
250 'logo' => (string)$this->urlUtils->expand( $logo[
'1x'],
PROTO_RELATIVE ),
254 'phpversion' => PHP_VERSION,
255 'phpsapi' => PHP_SAPI,
256 'dbtype' => $config->get( MainConfigNames::DBtype ),
257 'dbversion' => $this->
getDB()->getServerVersion(),
261 $allowException =
true;
262 if ( !$config->get( MainConfigNames::AllowExternalImages ) ) {
263 $data[
'imagewhitelistenabled'] =
264 (bool)$config->get( MainConfigNames::EnableImageWhitelist );
265 $allowFrom = $config->get( MainConfigNames::AllowExternalImagesFrom );
266 $allowException = (bool)$allowFrom;
268 if ( $allowException ) {
269 $data[
'externalimages'] = (array)$allowFrom;
270 ApiResult::setIndexedTagName( $data[
'externalimages'],
'prefix' );
273 $data[
'langconversion'] = !$this->languageConverterFactory->isConversionDisabled();
274 $data[
'linkconversion'] = !$this->languageConverterFactory->isLinkConversionDisabled();
276 $data[
'titleconversion'] = $data[
'linkconversion'];
278 $contLangConverter = $this->languageConverterFactory->getLanguageConverter( $this->contentLanguage );
279 if ( $this->contentLanguage->linkPrefixExtension() ) {
283 $data[
'linkprefix'] =
"/^((?>.*[^$linkPrefixCharset]|))(.+)$/sDu";
285 $data[
'linkprefixcharset'] =
'';
286 $data[
'linkprefix'] =
'';
289 $data[
'linktrail'] = $this->contentLanguage->linkTrail() ?:
'';
291 $data[
'legaltitlechars'] = Title::legalChars();
292 $data[
'invalidusernamechars'] = $config->get( MainConfigNames::InvalidUsernameCharacters );
294 $data[
'allunicodefixes'] = (bool)$config->get( MainConfigNames::AllUnicodeFixes );
295 $data[
'fixarabicunicode'] =
true;
296 $data[
'fixmalayalamunicode'] =
true;
298 $git = GitInfo::repo()->getHeadSHA1();
300 $data[
'git-hash'] = $git;
301 $data[
'git-branch'] = GitInfo::repo()->getCurrentBranch();
306 $config->get( MainConfigNames::CapitalLinks ) ?
'first-letter' :
'case-sensitive';
307 $data[
'lang'] = $config->get( MainConfigNames::LanguageCode );
309 $data[
'fallback'] = [];
310 foreach ( $this->contentLanguage->getFallbackLanguages() as $code ) {
311 $data[
'fallback'][] = [
'code' => $code ];
313 ApiResult::setIndexedTagName( $data[
'fallback'],
'lang' );
315 if ( $contLangConverter->hasVariants() ) {
316 $data[
'variants'] = [];
317 foreach ( $contLangConverter->getVariants() as $code ) {
318 $data[
'variants'][] = [
320 'name' => $this->contentLanguage->getVariantname( $code ),
323 ApiResult::setIndexedTagName( $data[
'variants'],
'lang' );
326 $data[
'rtl'] = $this->contentLanguage->isRTL();
327 $data[
'fallback8bitEncoding'] = $this->contentLanguage->fallback8bitEncoding();
329 $data[
'readonly'] = $this->readOnlyMode->isReadOnly();
330 if ( $data[
'readonly'] ) {
331 $data[
'readonlyreason'] = $this->readOnlyMode->getReason();
333 $data[
'writeapi'] =
true;
335 $data[
'maxarticlesize'] = $config->get( MainConfigNames::MaxArticleSize ) * 1024;
337 $data[
'timezone'] = $config->get( MainConfigNames::Localtimezone );
338 $data[
'timeoffset'] = (int)( $config->get( MainConfigNames::LocalTZoffset ) );
339 $data[
'articlepath'] = $config->get( MainConfigNames::ArticlePath );
340 $data[
'scriptpath'] = $config->get( MainConfigNames::ScriptPath );
341 $data[
'script'] = $config->get( MainConfigNames::Script );
342 $data[
'variantarticlepath'] = $config->get( MainConfigNames::VariantArticlePath );
343 $data[ApiResult::META_BC_BOOLS][] =
'variantarticlepath';
344 $data[
'server'] = $config->get( MainConfigNames::Server );
345 $data[
'servername'] = $config->get( MainConfigNames::ServerName );
346 $data[
'wikiid'] = WikiMap::getCurrentWikiId();
347 $data[
'time'] =
wfTimestamp( TS_ISO_8601, time() );
349 $data[
'misermode'] = (bool)$config->get( MainConfigNames::MiserMode );
351 $data[
'uploadsenabled'] = UploadBase::isEnabled();
352 $data[
'maxuploadsize'] = UploadBase::getMaxUploadSize();
355 $data[
'galleryoptions'] = $config->get( MainConfigNames::GalleryOptions );
357 $data[
'thumblimits'] = $config->get( MainConfigNames::ThumbLimits );
358 ApiResult::setArrayType( $data[
'thumblimits'],
'BCassoc' );
359 ApiResult::setIndexedTagName( $data[
'thumblimits'],
'limit' );
360 $data[
'imagelimits'] = [];
361 foreach ( $config->get( MainConfigNames::ImageLimits ) as $k => $limit ) {
362 $data[
'imagelimits'][$k] = [
'width' => $limit[0],
'height' => $limit[1] ];
364 ApiResult::setArrayType( $data[
'imagelimits'],
'BCassoc' );
365 ApiResult::setIndexedTagName( $data[
'imagelimits'],
'limit' );
367 $favicon = $config->get( MainConfigNames::Favicon );
370 $data[
'favicon'] = (string)$this->urlUtils->expand( $favicon );
373 $data[
'centralidlookupprovider'] = $config->get( MainConfigNames::CentralIdLookupProvider );
374 $providerIds = array_keys( $config->get( MainConfigNames::CentralIdLookupProviders ) );
375 $data[
'allcentralidlookupproviders'] = $providerIds;
377 $data[
'interwikimagic'] = (bool)$config->get( MainConfigNames::InterwikiMagic );
378 $data[
'magiclinks'] = $config->get( MainConfigNames::EnableMagicLinks );
380 $data[
'categorycollation'] = $config->get( MainConfigNames::CategoryCollation );
382 $data[
'nofollowlinks'] = $config->get( MainConfigNames::NoFollowLinks );
383 $data[
'nofollownsexceptions'] = $config->get( MainConfigNames::NoFollowNsExceptions );
384 $data[
'nofollowdomainexceptions'] = $config->get( MainConfigNames::NoFollowDomainExceptions );
385 $data[
'externallinktarget'] = $config->get( MainConfigNames::ExternalLinkTarget );
387 $this->
getHookRunner()->onAPIQuerySiteInfoGeneralInfo( $this, $data );
389 return $this->
getResult()->addValue(
'query', $property, $data );
393 $nsProtection = $this->
getConfig()->get( MainConfigNames::NamespaceProtection );
395 $data = [ ApiResult::META_TYPE =>
'assoc' ];
396 foreach ( $this->contentLanguage->getFormattedNamespaces() as $ns => $title ) {
399 'case' => $this->namespaceInfo->isCapitalized( $ns ) ?
'first-letter' :
'case-sensitive',
401 ApiResult::setContentValue( $data[$ns],
'name', $title );
402 $canonical = $this->namespaceInfo->getCanonicalName( $ns );
404 $data[$ns][
'subpages'] = $this->namespaceInfo->hasSubpages( $ns );
407 $data[$ns][
'canonical'] = strtr( $canonical,
'_',
' ' );
410 $data[$ns][
'content'] = $this->namespaceInfo->isContent( $ns );
411 $data[$ns][
'nonincludable'] = $this->namespaceInfo->isNonincludable( $ns );
413 $specificNs = $nsProtection[$ns] ??
'';
414 if ( is_array( $specificNs ) ) {
415 $specificNs = implode(
"|", array_filter( $specificNs ) );
417 if ( $specificNs !==
'' ) {
418 $data[$ns][
'namespaceprotection'] = $specificNs;
421 $contentmodel = $this->namespaceInfo->getNamespaceContentModel( $ns );
422 if ( $contentmodel ) {
423 $data[$ns][
'defaultcontentmodel'] = $contentmodel;
427 ApiResult::setArrayType( $data,
'assoc' );
428 ApiResult::setIndexedTagName( $data,
'ns' );
430 return $this->
getResult()->addValue(
'query', $property, $data );
434 $aliases = $this->contentLanguage->getNamespaceAliases();
435 $namespaces = $this->contentLanguage->getNamespaces();
437 foreach ( $aliases as $title => $ns ) {
438 if ( $namespaces[$ns] == $title ) {
442 $item = [
'id' => (int)$ns ];
443 ApiResult::setContentValue( $item,
'alias', strtr( $title,
'_',
' ' ) );
449 ApiResult::setIndexedTagName( $data,
'ns' );
451 return $this->
getResult()->addValue(
'query', $property, $data );
456 $aliases = $this->contentLanguage->getSpecialPageAliases();
457 foreach ( $this->specialPageFactory->getNames() as $specialpage ) {
458 if ( isset( $aliases[$specialpage] ) ) {
459 $arr = [
'realname' => $specialpage,
'aliases' => $aliases[$specialpage] ];
460 ApiResult::setIndexedTagName( $arr[
'aliases'],
'alias' );
464 ApiResult::setIndexedTagName( $data,
'specialpage' );
466 return $this->
getResult()->addValue(
'query', $property, $data );
471 foreach ( $this->contentLanguage->getMagicWords() as $name => $aliases ) {
472 $caseSensitive = (bool)array_shift( $aliases );
475 'aliases' => $aliases,
476 'case-sensitive' => $caseSensitive,
478 ApiResult::setIndexedTagName( $arr[
'aliases'],
'alias' );
481 ApiResult::setIndexedTagName( $data,
'magicword' );
483 return $this->
getResult()->addValue(
'query', $property, $data );
487 $local = $filter ? $filter ===
'local' :
null;
490 $langCode =
$params[
'inlanguagecode'] ??
'';
491 $interwikiMagic = $this->
getConfig()->get( MainConfigNames::InterwikiMagic );
493 if ( $interwikiMagic ) {
494 $langNames = $this->languageNameUtils->getLanguageNames( $langCode );
497 $extraLangPrefixes = $this->
getConfig()->get( MainConfigNames::ExtraInterlanguageLinkPrefixes );
498 $extraLangCodeMap = $this->
getConfig()->get( MainConfigNames::InterlanguageLinkCodeMap );
499 $localInterwikis = $this->
getConfig()->get( MainConfigNames::LocalInterwikis );
502 foreach ( $this->interwikiLookup->getAllPrefixes( $local ) as $row ) {
503 $prefix = $row[
'iw_prefix'];
505 $val[
'prefix'] = $prefix;
506 if ( $row[
'iw_local'] ??
false ) {
507 $val[
'local'] =
true;
509 if ( $row[
'iw_trans'] ??
false ) {
510 $val[
'trans'] =
true;
513 if ( $interwikiMagic && isset( $langNames[$prefix] ) ) {
514 $val[
'language'] = $langNames[$prefix];
515 $standard = LanguageCode::replaceDeprecatedCodes( $prefix );
516 if ( $standard !== $prefix ) {
517 # Note that even if this code is deprecated, it should
518 # only be remapped if extralanglink (set below) is false.
519 $val[
'deprecated'] = $standard;
521 $val[
'bcp47'] = LanguageCode::bcp47( $standard );
523 if ( in_array( $prefix, $localInterwikis ) ) {
524 $val[
'localinterwiki'] =
true;
526 if ( $interwikiMagic && in_array( $prefix, $extraLangPrefixes ) ) {
527 $val[
'extralanglink'] =
true;
528 $val[
'code'] = $extraLangCodeMap[$prefix] ?? $prefix;
529 $val[
'bcp47'] = LanguageCode::bcp47( $val[
'code'] );
531 $linktext = $this->
msg(
"interlanguage-link-$prefix" );
532 if ( !$linktext->isDisabled() ) {
533 $val[
'linktext'] = $linktext->text();
536 $sitename = $this->
msg(
"interlanguage-link-sitename-$prefix" );
537 if ( !$sitename->isDisabled() ) {
538 $val[
'sitename'] = $sitename->text();
542 $val[
'url'] = (string)$this->urlUtils->expand( $row[
'iw_url'],
PROTO_CURRENT );
543 $val[
'protorel'] = str_starts_with( $row[
'iw_url'],
'//' );
544 if ( ( $row[
'iw_wikiid'] ??
'' ) !==
'' ) {
545 $val[
'wikiid'] = $row[
'iw_wikiid'];
547 if ( ( $row[
'iw_api'] ??
'' ) !==
'' ) {
548 $val[
'api'] = $row[
'iw_api'];
554 ApiResult::setIndexedTagName( $data,
'iw' );
556 return $this->
getResult()->addValue(
'query', $property, $data );
561 $showHostnames = $this->
getConfig()->get( MainConfigNames::ShowHostnames );
563 if ( !$showHostnames ) {
564 $this->
dieWithError(
'apierror-siteinfo-includealldenied',
'includeAllDenied' );
567 foreach ( $this->loadBalancer->getLagTimes() as $i => $lag ) {
569 'host' => $this->loadBalancer->getServerName( $i ),
574 [ , $lag, $index ] = $this->loadBalancer->getMaxLag();
576 'host' => $showHostnames ? $this->loadBalancer->getServerName( $index ) :
'',
581 ApiResult::setIndexedTagName( $data,
'db' );
583 return $this->
getResult()->addValue(
'query', $property, $data );
588 'pages' => SiteStats::pages(),
589 'articles' => SiteStats::articles(),
590 'edits' => SiteStats::edits(),
591 'images' => SiteStats::images(),
592 'users' => SiteStats::users(),
593 'activeusers' => SiteStats::activeUsers(),
594 'admins' => SiteStats::numberingroup(
'sysop' ),
595 'jobs' => SiteStats::jobs(),
598 $this->
getHookRunner()->onAPIQuerySiteInfoStatisticsInfo( $data );
600 return $this->
getResult()->addValue(
'query', $property, $data );
608 $allGroups = array_values( $this->userGroupManager->listAllGroups() );
609 foreach ( $config->get( MainConfigNames::GroupPermissions ) as $group => $permissions ) {
612 'rights' => array_keys( $permissions,
true ),
615 if ( $numberInGroup ) {
616 $autopromote = $config->get( MainConfigNames::Autopromote );
618 if ( $group ==
'user' ) {
619 $arr[
'number'] = SiteStats::users();
621 } elseif ( $group !==
'*' && !isset( $autopromote[$group] ) ) {
622 $arr[
'number'] = SiteStats::numberingroup( $group );
627 'add' => $config->get( MainConfigNames::AddGroups ),
628 'remove' => $config->get( MainConfigNames::RemoveGroups ),
629 'add-self' => $config->get( MainConfigNames::GroupsAddToSelf ),
630 'remove-self' => $config->get( MainConfigNames::GroupsRemoveFromSelf )
633 foreach ( $groupArr as $type => $rights ) {
634 if ( isset( $rights[$group] ) ) {
635 if ( $rights[$group] ===
true ) {
636 $groups = $allGroups;
638 $groups = array_intersect( $rights[$group], $allGroups );
641 $arr[$type] = $groups;
642 ApiResult::setArrayType( $arr[$type],
'BCarray' );
643 ApiResult::setIndexedTagName( $arr[$type],
'group' );
648 ApiResult::setIndexedTagName( $arr[
'rights'],
'permission' );
652 ApiResult::setIndexedTagName( $data,
'group' );
654 return $result->addValue(
'query', $property, $data );
658 $data = [
'enabled' => $this->tempUserConfig->isEnabled() ];
659 if ( $this->tempUserConfig->isKnown() ) {
660 $data[
'matchPatterns'] = $this->tempUserConfig->getMatchPatterns();
662 return $this->
getResult()->addValue(
'query', $property, $data );
668 array_unique( $this->
getConfig()->
get( MainConfigNames::FileExtensions ) ) as $ext
670 $data[] = [
'ext' => $ext ];
672 ApiResult::setIndexedTagName( $data,
'fe' );
674 return $this->
getResult()->addValue(
'query', $property, $data );
679 foreach ( SpecialVersion::parseForeignResources() as $name => $info ) {
683 'name' => $info[
'name'],
684 'version' => $info[
'version'],
687 ApiResult::setIndexedTagName( $data,
'library' );
688 return $this->
getResult()->addValue(
'query', $property, $data );
692 $path = MW_INSTALL_PATH .
'/vendor/composer/installed.json';
693 if ( !file_exists(
$path ) ) {
699 foreach ( $installed->getInstalledDependencies() as $name => $info ) {
700 if ( str_starts_with( $info[
'type'],
'mediawiki-' ) ) {
707 'version' => $info[
'version'],
710 ApiResult::setIndexedTagName( $data,
'library' );
712 return $this->
getResult()->addValue(
'query', $property, $data );
717 $credits = SpecialVersion::getCredits(
718 ExtensionRegistry::getInstance(),
721 foreach ( $credits as $type => $extensions ) {
722 foreach ( $extensions as $ext ) {
723 $ret = [
'type' => $type ];
724 if ( isset( $ext[
'name'] ) ) {
725 $ret[
'name'] = $ext[
'name'];
727 if ( isset( $ext[
'namemsg'] ) ) {
728 $ret[
'namemsg'] = $ext[
'namemsg'];
730 if ( isset( $ext[
'description'] ) ) {
731 $ret[
'description'] = $ext[
'description'];
733 if ( isset( $ext[
'descriptionmsg'] ) ) {
735 if ( is_array( $ext[
'descriptionmsg'] ) ) {
736 $ret[
'descriptionmsg'] = $ext[
'descriptionmsg'][0];
737 $ret[
'descriptionmsgparams'] = array_slice( $ext[
'descriptionmsg'], 1 );
738 ApiResult::setIndexedTagName( $ret[
'descriptionmsgparams'],
'param' );
740 $ret[
'descriptionmsg'] = $ext[
'descriptionmsg'];
743 if ( isset( $ext[
'author'] ) ) {
744 $ret[
'author'] = is_array( $ext[
'author'] ) ?
745 implode(
', ', $ext[
'author'] ) : $ext[
'author'];
747 if ( isset( $ext[
'url'] ) ) {
748 $ret[
'url'] = $ext[
'url'];
750 if ( isset( $ext[
'version'] ) ) {
751 $ret[
'version'] = $ext[
'version'];
753 if ( isset( $ext[
'path'] ) ) {
754 $extensionPath = dirname( $ext[
'path'] );
755 $gitInfo =
new GitInfo( $extensionPath );
756 $vcsVersion = $gitInfo->getHeadSHA1();
757 if ( $vcsVersion !==
false ) {
758 $ret[
'vcs-system'] =
'git';
759 $ret[
'vcs-version'] = $vcsVersion;
760 $ret[
'vcs-url'] = $gitInfo->getHeadViewUrl();
761 $vcsDate = $gitInfo->getHeadCommitDate();
762 if ( $vcsDate !==
false ) {
763 $ret[
'vcs-date'] =
wfTimestamp( TS_ISO_8601, $vcsDate );
767 if ( ExtensionInfo::getLicenseFileNames( $extensionPath ) ) {
768 $ret[
'license-name'] = $ext[
'license-name'] ??
'';
769 $ret[
'license'] = SpecialPage::getTitleFor(
771 "License/{$ext['name']}"
775 if ( ExtensionInfo::getAuthorsFileName( $extensionPath ) ) {
776 $ret[
'credits'] = SpecialPage::getTitleFor(
778 "Credits/{$ext['name']}"
786 ApiResult::setIndexedTagName( $data,
'ext' );
788 return $this->
getResult()->addValue(
'query', $property, $data );
793 $title = Title::newFromText( $config->get( MainConfigNames::RightsPage ) );
797 $url = $config->get( MainConfigNames::RightsUrl );
799 $text = $config->get( MainConfigNames::RightsText ) ??
'';
800 if ( $text ===
'' && $title ) {
801 $text = $title->getPrefixedText();
805 'url' => (string)
$url,
806 'text' => (
string)$text,
809 return $this->
getResult()->addValue(
'query', $property, $data );
815 'types' => $config->get( MainConfigNames::RestrictionTypes ),
816 'levels' => $config->get( MainConfigNames::RestrictionLevels ),
817 'cascadinglevels' => $config->get( MainConfigNames::CascadingRestrictionLevels ),
818 'semiprotectedlevels' => $config->get( MainConfigNames::SemiprotectedRestrictionLevels ),
821 ApiResult::setArrayType( $data[
'types'],
'BCarray' );
822 ApiResult::setArrayType( $data[
'levels'],
'BCarray' );
823 ApiResult::setArrayType( $data[
'cascadinglevels'],
'BCarray' );
824 ApiResult::setArrayType( $data[
'semiprotectedlevels'],
'BCarray' );
826 ApiResult::setIndexedTagName( $data[
'types'],
'type' );
827 ApiResult::setIndexedTagName( $data[
'levels'],
'level' );
828 ApiResult::setIndexedTagName( $data[
'cascadinglevels'],
'level' );
829 ApiResult::setIndexedTagName( $data[
'semiprotectedlevels'],
'level' );
831 return $this->
getResult()->addValue(
'query', $property, $data );
836 $langCode =
$params[
'inlanguagecode'] ??
'';
837 $langNames = $this->languageNameUtils->getLanguageNames( $langCode );
841 foreach ( $langNames as $code => $name ) {
844 'bcp47' => LanguageCode::bcp47( $code ),
846 ApiResult::setContentValue( $lang,
'name', $name );
849 ApiResult::setIndexedTagName( $data,
'lang' );
851 return $this->
getResult()->addValue(
'query', $property, $data );
857 $langNames = $this->languageConverterFactory->isConversionDisabled() ? [] :
858 LanguageConverter::$languagesWithVariants;
862 foreach ( $langNames as $langCode ) {
863 $lang = $this->languageFactory->getLanguage( $langCode );
864 $langConverter = $this->languageConverterFactory->getLanguageConverter( $lang );
865 if ( !$langConverter->hasVariants() ) {
869 $data[$langCode] = [];
870 ApiResult::setIndexedTagName( $data[$langCode],
'variant' );
871 ApiResult::setArrayType( $data[$langCode],
'kvp',
'code' );
873 $variants = $langConverter->getVariants();
875 foreach ( $variants as $v ) {
876 $data[$langCode][$v] = [
877 'fallbacks' => (array)$langConverter->getVariantFallbacks( $v ),
879 ApiResult::setIndexedTagName(
880 $data[$langCode][$v][
'fallbacks'],
'variant'
884 ApiResult::setIndexedTagName( $data,
'lang' );
885 ApiResult::setArrayType( $data,
'kvp',
'code' );
887 return $this->
getResult()->addValue(
'query', $property, $data );
892 $allowed = $this->skinFactory->getAllowedSkins();
895 foreach ( $this->skinFactory->getInstalledSkins() as $name => $displayName ) {
896 $msg = $this->
msg(
"skinname-{$name}" );
898 if ( $code && $this->languageNameUtils->isValidCode( $code ) ) {
899 $msg->inLanguage( $code );
901 $msg->inContentLanguage();
903 if ( $msg->exists() ) {
904 $displayName = $msg->text();
906 $skin = [
'code' => $name ];
907 ApiResult::setContentValue( $skin,
'name', $displayName );
908 if ( !isset( $allowed[$name] ) ) {
909 $skin[
'unusable'] =
true;
911 if ( $name === $default ) {
912 $skin[
'default'] =
true;
916 ApiResult::setIndexedTagName( $data,
'skin' );
918 return $this->
getResult()->addValue(
'query', $property, $data );
923 static function ( $item ) {
926 $this->parserFactory->getMainInstance()->getTags()
928 ApiResult::setArrayType( $tags,
'BCarray' );
929 ApiResult::setIndexedTagName( $tags,
't' );
931 return $this->
getResult()->addValue(
'query', $property, $tags );
935 $hooks = $this->parserFactory->getMainInstance()->getFunctionHooks();
936 ApiResult::setArrayType( $hooks,
'BCarray' );
937 ApiResult::setIndexedTagName( $hooks,
'h' );
939 return $this->
getResult()->addValue(
'query', $property, $hooks );
943 $variables = $this->magicWordFactory->getVariableIDs();
944 ApiResult::setArrayType( $variables,
'BCarray' );
945 ApiResult::setIndexedTagName( $variables,
'v' );
947 return $this->
getResult()->addValue(
'query', $property, $variables );
952 $protocols = array_values( $this->
getConfig()->
get( MainConfigNames::UrlProtocols ) );
953 ApiResult::setArrayType( $protocols,
'BCarray' );
954 ApiResult::setIndexedTagName( $protocols,
'p' );
956 return $this->
getResult()->addValue(
'query', $property, $protocols );
960 $options = $this->userOptionsLookup->getDefaultOptions(
null );
961 $options[ApiResult::META_BC_BOOLS] = array_keys( $options );
962 return $this->
getResult()->addValue(
'query', $property, $options );
966 $config = $this->
getConfig()->get( MainConfigNames::UploadDialog );
967 return $this->
getResult()->addValue(
'query', $property, $config );
970 private function getAutoPromoteConds() {
971 $allowedConditions = [];
972 foreach ( get_defined_constants() as $constantName => $constantValue ) {
973 if ( strpos( $constantName,
'APCOND_' ) !==
false ) {
974 $allowedConditions[$constantName] = $constantValue;
977 return $allowedConditions;
980 private function processAutoPromote( $input, $allowedConditions ) {
982 foreach ( $input as $groupName => $conditions ) {
983 $row = $this->recAutopromote( $conditions, $allowedConditions );
984 if ( !isset( $row[0] ) || is_string( $row ) ) {
987 $data[$groupName] = $row;
992 private function appendAutoPromote( $property ) {
996 $this->processAutoPromote(
997 $this->
getConfig()->
get( MainConfigNames::Autopromote ),
998 $this->getAutoPromoteConds()
1003 private function appendAutoPromoteOnce( $property ) {
1004 $allowedConditions = $this->getAutoPromoteConds();
1006 foreach ( $this->
getConfig()->
get( MainConfigNames::AutopromoteOnce ) as $key => $value ) {
1007 $data[$key] = $this->processAutoPromote( $value, $allowedConditions );
1009 return $this->
getResult()->addValue(
'query', $property, $data );
1017 private function recAutopromote( $cond, $allowedConditions ) {
1020 if ( is_array( $cond ) ) {
1022 if ( in_array( $cond[0], UserGroupManager::VALID_OPS,
true ) ) {
1023 $config[
'operand'] = $cond[0];
1025 foreach ( array_slice( $cond, 1 ) as $value ) {
1026 $config[] = $this->recAutopromote( $value, $allowedConditions );
1028 } elseif ( is_string( $cond[0] ) ) {
1033 $params = array_slice( $cond, 1 );
1038 $params = [ $this->
getConfig()->get( MainConfigNames::AutoConfirmCount ) ];
1044 'condname' => array_search( $cond[0], $allowedConditions ),
1049 } elseif ( is_string( $cond ) ) {
1054 'condname' => array_search( $cond, $allowedConditions ),
1064 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
1065 $hookNames = $hookContainer->getHookNames();
1069 foreach ( $hookNames as $name ) {
1072 'subscribers' => $hookContainer->getHandlerDescriptions( $name ),
1075 ApiResult::setArrayType( $arr[
'subscribers'],
'array' );
1076 ApiResult::setIndexedTagName( $arr[
'subscribers'],
's' );
1080 ApiResult::setIndexedTagName( $data,
'hook' );
1082 return $this->
getResult()->addValue(
'query', $property, $data );
1087 if ( $this->
getConfig()->
get( MainConfigNames::ExtraInterlanguageLinkPrefixes ) &&
1088 in_array(
'interwikimap',
$params[
'prop'] ?? [] )
1090 return 'anon-public-user-private';
1099 ParamValidator::PARAM_DEFAULT =>
'general',
1100 ParamValidator::PARAM_ISMULTI =>
true,
1101 ParamValidator::PARAM_TYPE => [
1105 'specialpagealiases',
1111 'autocreatetempuser',
1134 ParamValidator::PARAM_TYPE => [
1139 'showalldb' =>
false,
1140 'numberingroup' =>
false,
1141 'inlanguagecode' =>
null,
1147 'action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics'
1148 =>
'apihelp-query+siteinfo-example-simple',
1149 'action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local'
1150 =>
'apihelp-query+siteinfo-example-interwiki',
1151 'action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb='
1152 =>
'apihelp-query+siteinfo-example-replag',
1157 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Siteinfo';
const MW_VERSION
The running version of MediaWiki.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
array $params
The job parameters.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getHookRunner()
Get an ApiHookRunner for running core API hooks.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
A query action to return meta information about the wiki site.
appendLanguageVariants( $property)
appendLanguages( $property)
appendInterwikiMap( $property, $filter)
appendGeneralInfo( $property)
appendRightsInfo( $property)
getExamplesMessages()
Returns usage examples for this module.
appendInstalledLibraries( $property)
appendVariables( $property)
appendAutoCreateTempUser( $property)
appendInstalledClientLibraries( $property)
__construct(ApiQuery $query, $moduleName, UserOptionsLookup $userOptionsLookup, UserGroupManager $userGroupManager, LanguageConverterFactory $languageConverterFactory, LanguageFactory $languageFactory, LanguageNameUtils $languageNameUtils, Language $contentLanguage, NamespaceInfo $namespaceInfo, InterwikiLookup $interwikiLookup, ParserFactory $parserFactory, MagicWordFactory $magicWordFactory, SpecialPageFactory $specialPageFactory, SkinFactory $skinFactory, ILoadBalancer $loadBalancer, ReadOnlyMode $readOnlyMode, UrlUtils $urlUtils, TempUserConfig $tempUserConfig)
appendUserGroups( $property, $numberInGroup)
appendFileExtensions( $property)
appendNamespaces( $property)
appendDefaultOptions( $property)
appendMagicWords( $property)
getHelpUrls()
Return links to more detailed help pages about the module.
appendExtensions( $property)
getCacheMode( $params)
Get the cache mode for the data generated by this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
appendRestrictions( $property)
appendExtensionTags( $property)
appendUploadDialog( $property)
appendProtocols( $property)
appendStatistics( $property)
appendSpecialPageAliases( $property)
appendDbReplLagInfo( $property, $includeAll)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
appendSubscribedHooks( $property)
appendFunctionHooks( $property)
appendNamespaceAliases( $property)
This is the main query class.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static getMinUploadChunkSize(Config $config)
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
A class containing constants representing the names of configuration variables.
Factory for handling the special page list and generating SpecialPage objects.
Parent class for all special pages.
Factory class to create Skin objects.
static normalizeKey(string $key)
Normalize a skin preference value to a form that can be loaded.