108 parent::__construct( $query, $moduleName,
'si' );
109 $this->userOptionsLookup = $userOptionsLookup;
110 $this->userGroupManager = $userGroupManager;
111 $this->languageConverterFactory = $languageConverterFactory;
112 $this->languageFactory = $languageFactory;
113 $this->languageNameUtils = $languageNameUtils;
114 $this->contentLanguage = $contentLanguage;
115 $this->namespaceInfo = $namespaceInfo;
116 $this->interwikiLookup = $interwikiLookup;
117 $this->parserFactory = $parserFactory;
118 $this->magicWordFactory = $magicWordFactory;
119 $this->specialPageFactory = $specialPageFactory;
120 $this->skinFactory = $skinFactory;
121 $this->loadBalancer = $loadBalancer;
122 $this->readOnlyMode = $readOnlyMode;
123 $this->urlUtils = $urlUtils;
129 foreach ( $params[
'prop'] as $p ) {
137 case 'namespacealiases':
140 case 'specialpagealiases':
158 case 'autocreatetempuser':
167 case 'fileextensions':
179 case 'languagevariants':
185 case 'extensiontags':
188 case 'functionhooks':
200 case 'defaultoptions':
213 array_diff( $params[
'prop'], $done ) ) );
224 $mainPage = Title::newMainPage();
225 $data[
'mainpage'] = $mainPage->getPrefixedText();
226 $data[
'base'] = (string)$this->urlUtils->expand( $mainPage->getFullURL(),
PROTO_CURRENT );
227 $data[
'sitename'] = $config->get( MainConfigNames::Sitename );
228 $data[
'mainpageisdomainroot'] = (bool)$config->get( MainConfigNames::MainPageIsDomainRoot );
232 $logo = SkinModule::getAvailableLogos( $config );
233 $data[
'logo'] = (string)$this->urlUtils->expand( $logo[
'1x'],
PROTO_RELATIVE );
235 $data[
'generator'] =
'MediaWiki ' .
MW_VERSION;
237 $data[
'phpversion'] = PHP_VERSION;
238 $data[
'phpsapi'] = PHP_SAPI;
239 $data[
'dbtype'] = $config->get( MainConfigNames::DBtype );
240 $data[
'dbversion'] = $this->
getDB()->getServerVersion();
243 $allowException =
true;
244 if ( !$config->get( MainConfigNames::AllowExternalImages ) ) {
245 $data[
'imagewhitelistenabled'] =
246 (bool)$config->get( MainConfigNames::EnableImageWhitelist );
247 $allowFrom = $config->get( MainConfigNames::AllowExternalImagesFrom );
248 $allowException = (bool)$allowFrom;
250 if ( $allowException ) {
251 $data[
'externalimages'] = (array)$allowFrom;
252 ApiResult::setIndexedTagName( $data[
'externalimages'],
'prefix' );
255 $data[
'langconversion'] = !$this->languageConverterFactory->isConversionDisabled();
256 $data[
'linkconversion'] = !$this->languageConverterFactory->isLinkConversionDisabled();
258 $data[
'titleconversion'] = $data[
'linkconversion'];
260 $contLangConverter = $this->languageConverterFactory->getLanguageConverter( $this->contentLanguage );
261 if ( $this->contentLanguage->linkPrefixExtension() ) {
265 $data[
'linkprefix'] =
"/^((?>.*[^$linkPrefixCharset]|))(.+)$/sDu";
267 $data[
'linkprefixcharset'] =
'';
268 $data[
'linkprefix'] =
'';
271 $linktrail = $this->contentLanguage->linkTrail();
272 $data[
'linktrail'] = $linktrail ?:
'';
274 $data[
'legaltitlechars'] = Title::legalChars();
275 $data[
'invalidusernamechars'] = $config->get( MainConfigNames::InvalidUsernameCharacters );
277 $data[
'allunicodefixes'] = (bool)$config->get( MainConfigNames::AllUnicodeFixes );
278 $data[
'fixarabicunicode'] =
true;
279 $data[
'fixmalayalamunicode'] =
true;
281 $baseDir = $this->
getConfig()->get( MainConfigNames::BaseDirectory );
282 $git = SpecialVersion::getGitHeadSha1( $baseDir );
284 $data[
'git-hash'] = $git;
285 $data[
'git-branch'] =
286 SpecialVersion::getGitCurrentBranch( $baseDir );
291 $config->get( MainConfigNames::CapitalLinks ) ?
'first-letter' :
'case-sensitive';
292 $data[
'lang'] = $config->get( MainConfigNames::LanguageCode );
295 foreach ( $this->contentLanguage->getFallbackLanguages() as $code ) {
296 $fallbacks[] = [
'code' => $code ];
298 $data[
'fallback'] = $fallbacks;
299 ApiResult::setIndexedTagName( $data[
'fallback'],
'lang' );
301 if ( $contLangConverter->hasVariants() ) {
303 foreach ( $contLangConverter->getVariants() as $code ) {
306 'name' => $this->contentLanguage->getVariantname( $code ),
309 $data[
'variants'] = $variants;
310 ApiResult::setIndexedTagName( $data[
'variants'],
'lang' );
313 $data[
'rtl'] = $this->contentLanguage->isRTL();
314 $data[
'fallback8bitEncoding'] = $this->contentLanguage->fallback8bitEncoding();
316 $data[
'readonly'] = $this->readOnlyMode->isReadOnly();
317 if ( $data[
'readonly'] ) {
318 $data[
'readonlyreason'] = $this->readOnlyMode->getReason();
320 $data[
'writeapi'] =
true;
322 $data[
'maxarticlesize'] = $config->get( MainConfigNames::MaxArticleSize ) * 1024;
324 $tz = $config->get( MainConfigNames::Localtimezone );
325 $offset = $config->get( MainConfigNames::LocalTZoffset );
326 $data[
'timezone'] = $tz;
327 $data[
'timeoffset'] = (int)$offset;
328 $data[
'articlepath'] = $config->get( MainConfigNames::ArticlePath );
329 $data[
'scriptpath'] = $config->get( MainConfigNames::ScriptPath );
330 $data[
'script'] = $config->get( MainConfigNames::Script );
331 $data[
'variantarticlepath'] = $config->get( MainConfigNames::VariantArticlePath );
332 $data[ApiResult::META_BC_BOOLS][] =
'variantarticlepath';
333 $data[
'server'] = $config->get( MainConfigNames::Server );
334 $data[
'servername'] = $config->get( MainConfigNames::ServerName );
335 $data[
'wikiid'] = WikiMap::getCurrentWikiId();
336 $data[
'time'] =
wfTimestamp( TS_ISO_8601, time() );
338 $data[
'misermode'] = (bool)$config->get( MainConfigNames::MiserMode );
340 $data[
'uploadsenabled'] = UploadBase::isEnabled();
341 $data[
'maxuploadsize'] = UploadBase::getMaxUploadSize();
344 $data[
'galleryoptions'] = $config->get( MainConfigNames::GalleryOptions );
346 $data[
'thumblimits'] = $config->get( MainConfigNames::ThumbLimits );
347 ApiResult::setArrayType( $data[
'thumblimits'],
'BCassoc' );
348 ApiResult::setIndexedTagName( $data[
'thumblimits'],
'limit' );
349 $data[
'imagelimits'] = [];
350 ApiResult::setArrayType( $data[
'imagelimits'],
'BCassoc' );
351 ApiResult::setIndexedTagName( $data[
'imagelimits'],
'limit' );
352 foreach ( $config->get( MainConfigNames::ImageLimits ) as $k => $limit ) {
353 $data[
'imagelimits'][$k] = [
'width' => $limit[0],
'height' => $limit[1] ];
356 $favicon = $config->get( MainConfigNames::Favicon );
359 $data[
'favicon'] = (string)$this->urlUtils->expand( $favicon );
362 $data[
'centralidlookupprovider'] =
363 $config->get( MainConfigNames::CentralIdLookupProvider );
364 $providerIds = array_keys( $config->get( MainConfigNames::CentralIdLookupProviders ) );
365 $data[
'allcentralidlookupproviders'] = $providerIds;
367 $data[
'interwikimagic'] = (bool)$config->get( MainConfigNames::InterwikiMagic );
368 $data[
'magiclinks'] = $config->get( MainConfigNames::EnableMagicLinks );
370 $data[
'categorycollation'] = $config->get( MainConfigNames::CategoryCollation );
372 $data[
'nofollowlinks'] = $config->get( MainConfigNames::NoFollowLinks );
373 $data[
'nofollownsexceptions'] = $config->get( MainConfigNames::NoFollowNsExceptions );
374 $data[
'nofollowdomainexceptions'] = $config->get( MainConfigNames::NoFollowDomainExceptions );
375 $data[
'externallinktarget'] = $config->get( MainConfigNames::ExternalLinkTarget );
377 $this->
getHookRunner()->onAPIQuerySiteInfoGeneralInfo( $this, $data );
379 return $this->
getResult()->addValue(
'query', $property, $data );
383 $nsProtection = $this->
getConfig()->get( MainConfigNames::NamespaceProtection );
386 ApiResult::META_TYPE =>
'assoc',
389 $this->contentLanguage->getFormattedNamespaces()
394 'case' => $this->namespaceInfo->isCapitalized( $ns ) ?
'first-letter' :
'case-sensitive',
396 ApiResult::setContentValue( $data[$ns],
'name', $title );
397 $canonical = $this->namespaceInfo->getCanonicalName( $ns );
399 $data[$ns][
'subpages'] = $this->namespaceInfo->hasSubpages( $ns );
402 $data[$ns][
'canonical'] = strtr( $canonical,
'_',
' ' );
405 $data[$ns][
'content'] = $this->namespaceInfo->isContent( $ns );
406 $data[$ns][
'nonincludable'] = $this->namespaceInfo->isNonincludable( $ns );
408 if ( isset( $nsProtection[$ns] ) ) {
409 if ( is_array( $nsProtection[$ns] ) ) {
410 $specificNs = implode(
"|", array_filter( $nsProtection[$ns] ) );
411 } elseif ( $nsProtection[$ns] !==
'' ) {
412 $specificNs = $nsProtection[$ns];
414 if ( isset( $specificNs ) && $specificNs !==
'' ) {
415 $data[$ns][
'namespaceprotection'] = $specificNs;
419 $contentmodel = $this->namespaceInfo->getNamespaceContentModel( $ns );
420 if ( $contentmodel ) {
421 $data[$ns][
'defaultcontentmodel'] = $contentmodel;
425 ApiResult::setArrayType( $data,
'assoc' );
426 ApiResult::setIndexedTagName( $data,
'ns' );
428 return $this->
getResult()->addValue(
'query', $property, $data );
432 $aliases = $this->contentLanguage->getNamespaceAliases();
433 $namespaces = $this->contentLanguage->getNamespaces();
435 foreach ( $aliases as $title => $ns ) {
436 if ( $namespaces[$ns] == $title ) {
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 );
472 $this->contentLanguage->getMagicWords()
473 as $magicword => $aliases
475 $caseSensitive = array_shift( $aliases );
476 $arr = [
'name' => $magicword,
'aliases' => $aliases ];
477 $arr[
'case-sensitive'] = (bool)$caseSensitive;
478 ApiResult::setIndexedTagName( $arr[
'aliases'],
'alias' );
481 ApiResult::setIndexedTagName( $data,
'magicword' );
483 return $this->
getResult()->addValue(
'query', $property, $data );
487 if ( $filter ===
'local' ) {
489 } elseif ( $filter ===
'!local' ) {
497 $langCode = $params[
'inlanguagecode'] ??
'';
498 $interwikiMagic = $this->
getConfig()->get( MainConfigNames::InterwikiMagic );
500 if ( $interwikiMagic ) {
501 $langNames = $this->languageNameUtils->getLanguageNames( $langCode );
504 $getPrefixes = $this->interwikiLookup->getAllPrefixes( $local );
505 $extraLangPrefixes = $this->
getConfig()->get( MainConfigNames::ExtraInterlanguageLinkPrefixes );
506 $extraLangCodeMap = $this->
getConfig()->get( MainConfigNames::InterlanguageLinkCodeMap );
507 $localInterwikis = $this->
getConfig()->get( MainConfigNames::LocalInterwikis );
510 foreach ( $getPrefixes as $row ) {
511 $prefix = $row[
'iw_prefix'];
513 $val[
'prefix'] = $prefix;
514 if ( isset( $row[
'iw_local'] ) && $row[
'iw_local'] ==
'1' ) {
515 $val[
'local'] =
true;
517 if ( isset( $row[
'iw_trans'] ) && $row[
'iw_trans'] ==
'1' ) {
518 $val[
'trans'] =
true;
521 if ( $interwikiMagic && isset( $langNames[$prefix] ) ) {
522 $val[
'language'] = $langNames[$prefix];
523 $standard = LanguageCode::replaceDeprecatedCodes( $prefix );
524 if ( $standard !== $prefix ) {
525 # Note that even if this code is deprecated, it should
526 # only be remapped if extralanglink (set below) is false.
527 $val[
'deprecated'] = $standard;
529 $val[
'bcp47'] = LanguageCode::bcp47( $standard );
531 if ( in_array( $prefix, $localInterwikis ) ) {
532 $val[
'localinterwiki'] =
true;
534 if ( $interwikiMagic && in_array( $prefix, $extraLangPrefixes ) ) {
535 $val[
'extralanglink'] =
true;
536 $val[
'code'] = $extraLangCodeMap[$prefix] ?? $prefix;
537 $val[
'bcp47'] = LanguageCode::bcp47( $val[
'code'] );
539 $linktext = $this->
msg(
"interlanguage-link-$prefix" );
540 if ( !$linktext->isDisabled() ) {
541 $val[
'linktext'] = $linktext->text();
544 $sitename = $this->
msg(
"interlanguage-link-sitename-$prefix" );
545 if ( !$sitename->isDisabled() ) {
546 $val[
'sitename'] = $sitename->text();
550 $val[
'url'] = (string)$this->urlUtils->expand( $row[
'iw_url'],
PROTO_CURRENT );
551 $val[
'protorel'] = str_starts_with( $row[
'iw_url'],
'//' );
552 if ( isset( $row[
'iw_wikiid'] ) && $row[
'iw_wikiid'] !==
'' ) {
553 $val[
'wikiid'] = $row[
'iw_wikiid'];
555 if ( isset( $row[
'iw_api'] ) && $row[
'iw_api'] !==
'' ) {
556 $val[
'api'] = $row[
'iw_api'];
562 ApiResult::setIndexedTagName( $data,
'iw' );
564 return $this->
getResult()->addValue(
'query', $property, $data );
569 $showHostnames = $this->
getConfig()->get( MainConfigNames::ShowHostnames );
571 if ( !$showHostnames ) {
572 $this->
dieWithError(
'apierror-siteinfo-includealldenied',
'includeAllDenied' );
575 $lags = $this->loadBalancer->getLagTimes();
576 foreach ( $lags as $i => $lag ) {
578 'host' => $this->loadBalancer->getServerName( $i ),
583 [ , $lag, $index ] = $this->loadBalancer->getMaxLag();
585 'host' => $showHostnames
586 ? $this->loadBalancer->getServerName( $index )
592 ApiResult::setIndexedTagName( $data,
'db' );
594 return $this->
getResult()->addValue(
'query', $property, $data );
599 $data[
'pages'] = (int)SiteStats::pages();
600 $data[
'articles'] = (int)SiteStats::articles();
601 $data[
'edits'] = (int)SiteStats::edits();
602 $data[
'images'] = (int)SiteStats::images();
603 $data[
'users'] = (int)SiteStats::users();
604 $data[
'activeusers'] = (int)SiteStats::activeUsers();
605 $data[
'admins'] = (int)SiteStats::numberingroup(
'sysop' );
606 $data[
'jobs'] = (int)SiteStats::jobs();
608 $this->
getHookRunner()->onAPIQuerySiteInfoStatisticsInfo( $data );
610 return $this->
getResult()->addValue(
'query', $property, $data );
618 $allGroups = array_values( $this->userGroupManager->listAllGroups() );
619 foreach ( $config->get( MainConfigNames::GroupPermissions ) as $group => $permissions ) {
622 'rights' => array_keys( $permissions,
true ),
625 if ( $numberInGroup ) {
626 $autopromote = $config->get( MainConfigNames::Autopromote );
628 if ( $group ==
'user' ) {
629 $arr[
'number'] = SiteStats::users();
631 } elseif ( $group !==
'*' && !isset( $autopromote[$group] ) ) {
632 $arr[
'number'] = SiteStats::numberingroup( $group );
637 'add' => $config->get( MainConfigNames::AddGroups ),
638 'remove' => $config->get( MainConfigNames::RemoveGroups ),
639 'add-self' => $config->get( MainConfigNames::GroupsAddToSelf ),
640 'remove-self' => $config->get( MainConfigNames::GroupsRemoveFromSelf )
643 foreach ( $groupArr as $type => $rights ) {
644 if ( isset( $rights[$group] ) ) {
645 if ( $rights[$group] ===
true ) {
646 $groups = $allGroups;
648 $groups = array_intersect( $rights[$group], $allGroups );
651 $arr[$type] = $groups;
652 ApiResult::setArrayType( $arr[$type],
'BCarray' );
653 ApiResult::setIndexedTagName( $arr[$type],
'group' );
658 ApiResult::setIndexedTagName( $arr[
'rights'],
'permission' );
662 ApiResult::setIndexedTagName( $data,
'group' );
664 return $result->addValue(
'query', $property, $data );
668 $config = $this->
getConfig()->get( MainConfigNames::AutoCreateTempUser );
670 $data = [
'enabled' => false ];
671 if ( $config[
'enabled'] ??
false ) {
672 $data[
'enabled'] =
true;
673 $data[
'actions'] = $config[
'actions'];
674 $data[
'genPattern'] = $config[
'genPattern'];
675 $data[
'matchPattern'] = $config[
'matchPattern'] ?? $data[
'genPattern'];
676 $data[
'serialProvider'] = $config[
'serialProvider'];
677 $data[
'serialMapping'] = $config[
'serialMapping'];
679 if ( isset( $config[
'reservedPattern'] ) ) {
680 $data[
'reservedPattern'] = $config[
'reservedPattern'];
683 return $this->
getResult()->addValue(
'query', $property, $data );
689 array_unique( $this->
getConfig()->
get( MainConfigNames::FileExtensions ) ) as
$ext
691 $data[] = [
'ext' =>
$ext ];
693 ApiResult::setIndexedTagName( $data,
'fe' );
695 return $this->
getResult()->addValue(
'query', $property, $data );
699 $baseDir = $this->
getConfig()->get( MainConfigNames::BaseDirectory );
700 $path =
"$baseDir/vendor/composer/installed.json";
701 if ( !file_exists(
$path ) ) {
707 foreach ( $installed->getInstalledDependencies() as $name => $info ) {
708 if ( str_starts_with( $info[
'type'],
'mediawiki-' ) ) {
715 'version' => $info[
'version'],
718 ApiResult::setIndexedTagName( $data,
'library' );
720 return $this->
getResult()->addValue(
'query', $property, $data );
725 $credits = SpecialVersion::getCredits(
726 ExtensionRegistry::getInstance(),
729 foreach ( $credits as $type => $extensions ) {
730 foreach ( $extensions as
$ext ) {
732 $ret[
'type'] = $type;
733 if ( isset(
$ext[
'name'] ) ) {
734 $ret[
'name'] =
$ext[
'name'];
736 if ( isset(
$ext[
'namemsg'] ) ) {
737 $ret[
'namemsg'] =
$ext[
'namemsg'];
739 if ( isset(
$ext[
'description'] ) ) {
740 $ret[
'description'] =
$ext[
'description'];
742 if ( isset(
$ext[
'descriptionmsg'] ) ) {
744 if ( is_array(
$ext[
'descriptionmsg'] ) ) {
745 $ret[
'descriptionmsg'] =
$ext[
'descriptionmsg'][0];
746 $ret[
'descriptionmsgparams'] = array_slice(
$ext[
'descriptionmsg'], 1 );
747 ApiResult::setIndexedTagName( $ret[
'descriptionmsgparams'],
'param' );
749 $ret[
'descriptionmsg'] =
$ext[
'descriptionmsg'];
752 if ( isset(
$ext[
'author'] ) ) {
753 $ret[
'author'] = is_array(
$ext[
'author'] ) ?
754 implode(
', ',
$ext[
'author'] ) :
$ext[
'author'];
756 if ( isset(
$ext[
'url'] ) ) {
757 $ret[
'url'] =
$ext[
'url'];
759 if ( isset(
$ext[
'version'] ) ) {
760 $ret[
'version'] =
$ext[
'version'];
762 if ( isset(
$ext[
'path'] ) ) {
763 $extensionPath = dirname(
$ext[
'path'] );
764 $gitInfo =
new GitInfo( $extensionPath );
765 $vcsVersion = $gitInfo->getHeadSHA1();
766 if ( $vcsVersion !==
false ) {
767 $ret[
'vcs-system'] =
'git';
768 $ret[
'vcs-version'] = $vcsVersion;
769 $ret[
'vcs-url'] = $gitInfo->getHeadViewUrl();
770 $vcsDate = $gitInfo->getHeadCommitDate();
771 if ( $vcsDate !==
false ) {
772 $ret[
'vcs-date'] =
wfTimestamp( TS_ISO_8601, $vcsDate );
776 if ( ExtensionInfo::getLicenseFileNames( $extensionPath ) ) {
777 $ret[
'license-name'] =
$ext[
'license-name'] ??
'';
778 $ret[
'license'] = SpecialPage::getTitleFor(
780 "License/{$ext['name']}"
784 if ( ExtensionInfo::getAuthorsFileName( $extensionPath ) ) {
785 $ret[
'credits'] = SpecialPage::getTitleFor(
787 "Credits/{$ext['name']}"
795 ApiResult::setIndexedTagName( $data,
'ext' );
797 return $this->
getResult()->addValue(
'query', $property, $data );
802 $rightsPage = $config->get( MainConfigNames::RightsPage );
804 if ( strlen( (
string)$rightsPage ) ) {
805 $title = Title::newFromText( $rightsPage );
806 $url = (string)$this->urlUtils->expand( $title->getLinkURL(),
PROTO_CURRENT );
809 $url = $config->get( MainConfigNames::RightsUrl );
811 $text = $config->get( MainConfigNames::RightsText );
812 if ( $title && !strlen( (
string)$text ) ) {
813 $text = $title->getPrefixedText();
817 'url' => (string)$url,
818 'text' => (
string)$text,
821 return $this->
getResult()->addValue(
'query', $property, $data );
827 'types' => $config->get( MainConfigNames::RestrictionTypes ),
828 'levels' => $config->get( MainConfigNames::RestrictionLevels ),
829 'cascadinglevels' => $config->get( MainConfigNames::CascadingRestrictionLevels ),
830 'semiprotectedlevels' => $config->get( MainConfigNames::SemiprotectedRestrictionLevels ),
833 ApiResult::setArrayType( $data[
'types'],
'BCarray' );
834 ApiResult::setArrayType( $data[
'levels'],
'BCarray' );
835 ApiResult::setArrayType( $data[
'cascadinglevels'],
'BCarray' );
836 ApiResult::setArrayType( $data[
'semiprotectedlevels'],
'BCarray' );
838 ApiResult::setIndexedTagName( $data[
'types'],
'type' );
839 ApiResult::setIndexedTagName( $data[
'levels'],
'level' );
840 ApiResult::setIndexedTagName( $data[
'cascadinglevels'],
'level' );
841 ApiResult::setIndexedTagName( $data[
'semiprotectedlevels'],
'level' );
843 return $this->
getResult()->addValue(
'query', $property, $data );
848 $langCode = $params[
'inlanguagecode'] ??
'';
849 $langNames = $this->languageNameUtils->getLanguageNames( $langCode );
853 foreach ( $langNames as $code => $name ) {
856 'bcp47' => LanguageCode::bcp47( $code ),
858 ApiResult::setContentValue( $lang,
'name', $name );
861 ApiResult::setIndexedTagName( $data,
'lang' );
863 return $this->
getResult()->addValue(
'query', $property, $data );
869 $langNames = LanguageConverter::$languagesWithVariants;
870 if ( $this->languageConverterFactory->isConversionDisabled() ) {
877 foreach ( $langNames as $langCode ) {
878 $lang = $this->languageFactory->getLanguage( $langCode );
879 $langConverter = $this->languageConverterFactory->getLanguageConverter( $lang );
880 if ( !$langConverter->hasVariants() ) {
884 $data[$langCode] = [];
885 ApiResult::setIndexedTagName( $data[$langCode],
'variant' );
886 ApiResult::setArrayType( $data[$langCode],
'kvp',
'code' );
888 $variants = $langConverter->getVariants();
890 foreach ( $variants as $v ) {
891 $fallbacks = $langConverter->getVariantFallbacks( $v );
892 if ( !is_array( $fallbacks ) ) {
893 $fallbacks = [ $fallbacks ];
895 $data[$langCode][$v] = [
896 'fallbacks' => $fallbacks,
898 ApiResult::setIndexedTagName(
899 $data[$langCode][$v][
'fallbacks'],
'variant'
903 ApiResult::setIndexedTagName( $data,
'lang' );
904 ApiResult::setArrayType( $data,
'kvp',
'code' );
906 return $this->
getResult()->addValue(
'query', $property, $data );
911 $allowed = $this->skinFactory->getAllowedSkins();
913 $skinNames = $this->skinFactory->getInstalledSkins();
915 foreach ( $skinNames as $name => $displayName ) {
916 $msg = $this->
msg(
"skinname-{$name}" );
918 if ( $code && $this->languageNameUtils->isValidCode( $code ) ) {
919 $msg->inLanguage( $code );
921 $msg->inContentLanguage();
923 if ( $msg->exists() ) {
924 $displayName = $msg->text();
926 $skin = [
'code' => $name ];
927 ApiResult::setContentValue( $skin,
'name', $displayName );
928 if ( !isset( $allowed[$name] ) ) {
929 $skin[
'unusable'] =
true;
931 if ( $name === $default ) {
932 $skin[
'default'] =
true;
936 ApiResult::setIndexedTagName( $data,
'skin' );
938 return $this->
getResult()->addValue(
'query', $property, $data );
943 static function ( $item ) {
946 $this->parserFactory->getMainInstance()->getTags()
948 ApiResult::setArrayType( $tags,
'BCarray' );
949 ApiResult::setIndexedTagName( $tags,
't' );
951 return $this->
getResult()->addValue(
'query', $property, $tags );
955 $hooks = $this->parserFactory->getMainInstance()->getFunctionHooks();
956 ApiResult::setArrayType( $hooks,
'BCarray' );
957 ApiResult::setIndexedTagName( $hooks,
'h' );
959 return $this->
getResult()->addValue(
'query', $property, $hooks );
963 $variables = $this->magicWordFactory->getVariableIDs();
964 ApiResult::setArrayType( $variables,
'BCarray' );
965 ApiResult::setIndexedTagName( $variables,
'v' );
967 return $this->
getResult()->addValue(
'query', $property, $variables );
972 $protocols = array_values( $this->
getConfig()->
get( MainConfigNames::UrlProtocols ) );
973 ApiResult::setArrayType( $protocols,
'BCarray' );
974 ApiResult::setIndexedTagName( $protocols,
'p' );
976 return $this->
getResult()->addValue(
'query', $property, $protocols );
980 $options = $this->userOptionsLookup->getDefaultOptions();
981 $options[ApiResult::META_BC_BOOLS] = array_keys( $options );
982 return $this->
getResult()->addValue(
'query', $property, $options );
986 $config = $this->
getConfig()->get( MainConfigNames::UploadDialog );
987 return $this->
getResult()->addValue(
'query', $property, $config );
991 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
992 $hookNames = $hookContainer->getHookNames();
996 foreach ( $hookNames as $name ) {
997 $subscribers = $hookContainer->getHandlerDescriptions( $name );
1001 'subscribers' => $subscribers,
1004 ApiResult::setArrayType( $arr[
'subscribers'],
'array' );
1005 ApiResult::setIndexedTagName( $arr[
'subscribers'],
's' );
1009 ApiResult::setIndexedTagName( $data,
'hook' );
1011 return $this->
getResult()->addValue(
'query', $property, $data );
1017 count( $this->
getConfig()->
get( MainConfigNames::ExtraInterlanguageLinkPrefixes ) ) &&
1018 $params[
'prop'] !==
null &&
1019 in_array(
'interwikimap', $params[
'prop'] )
1021 return 'anon-public-user-private';
1030 ParamValidator::PARAM_DEFAULT =>
'general',
1031 ParamValidator::PARAM_ISMULTI =>
true,
1032 ParamValidator::PARAM_TYPE => [
1036 'specialpagealiases',
1042 'autocreatetempuser',
1062 ParamValidator::PARAM_TYPE => [
1067 'showalldb' =>
false,
1068 'numberingroup' =>
false,
1069 'inlanguagecode' =>
null,
1075 'action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics'
1076 =>
'apihelp-query+siteinfo-example-simple',
1077 'action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local'
1078 =>
'apihelp-query+siteinfo-example-interwiki',
1079 'action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb='
1080 =>
'apihelp-query+siteinfo-example-replag',
1085 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.
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)
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)
__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)
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 getMinUploadChunkSize(Config $config)
Reads an installed.json file and provides accessors to get what is installed.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Base class for language-specific code.
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.
if(!is_readable( $file)) $ext