32 parent::__construct(
$query, $moduleName,
'si' );
39 foreach (
$params[
'prop'] as $p ) {
47 case 'namespacealiases':
50 case 'specialpagealiases':
57 $filteriw = isset(
$params[
'filteriw'] ) ?
$params[
'filteriw'] :
false;
75 case 'fileextensions':
87 case 'languagevariants':
108 case 'defaultoptions':
121 array_diff(
$params[
'prop'], $done ) ) );
134 $mainPage = Title::newMainPage();
135 $data[
'mainpage'] = $mainPage->getPrefixedText();
137 $data[
'sitename'] = $config->get(
'Sitename' );
143 $data[
'generator'] =
"MediaWiki {$config->get( 'Version' )}";
145 $data[
'phpversion'] = PHP_VERSION;
146 $data[
'phpsapi'] = PHP_SAPI;
147 if ( defined(
'HHVM_VERSION' ) ) {
148 $data[
'hhvmversion'] = HHVM_VERSION;
150 $data[
'dbtype'] = $config->get(
'DBtype' );
151 $data[
'dbversion'] = $this->
getDB()->getServerVersion();
154 $allowException =
true;
155 if ( !$config->get(
'AllowExternalImages' ) ) {
156 $data[
'imagewhitelistenabled'] = (bool)$config->get(
'EnableImageWhitelist' );
157 $allowFrom = $config->get(
'AllowExternalImagesFrom' );
158 $allowException = !empty( $allowFrom );
160 if ( $allowException ) {
161 $data[
'externalimages'] = (
array)$allowFrom;
165 $data[
'langconversion'] = !$config->get(
'DisableLangConversion' );
166 $data[
'titleconversion'] = !$config->get(
'DisableTitleConversion' );
172 $data[
'linkprefix'] =
"/^((?>.*[^$linkPrefixCharset]|))(.+)$/sDu";
174 $data[
'linkprefixcharset'] =
'';
175 $data[
'linkprefix'] =
'';
179 $data[
'linktrail'] = $linktrail ?:
'';
181 $data[
'legaltitlechars'] = Title::legalChars();
182 $data[
'invalidusernamechars'] = $config->get(
'InvalidUsernameCharacters' );
184 $data[
'allunicodefixes'] = (bool)$config->get(
'AllUnicodeFixes' );
185 $data[
'fixarabicunicode'] = (bool)$config->get(
'FixArabicUnicode' );
186 $data[
'fixmalayalamunicode'] = (bool)$config->get(
'FixMalayalamUnicode' );
191 $data[
'git-hash'] = $git;
192 $data[
'git-branch'] =
197 $data[
'case'] = $config->get(
'CapitalLinks' ) ?
'first-letter' :
'case-sensitive';
198 $data[
'lang'] = $config->get(
'LanguageCode' );
202 $fallbacks[] = [
'code' =>
$code ];
204 $data[
'fallback'] = $fallbacks;
215 $data[
'variants'] = $variants;
220 $data[
'fallback8bitEncoding'] =
$wgContLang->fallback8bitEncoding();
223 if ( $data[
'readonly'] ) {
226 $data[
'writeapi'] = (bool)$config->get(
'EnableWriteAPI' );
228 $data[
'maxarticlesize'] = $config->get(
'MaxArticleSize' ) * 1024;
230 $tz = $config->get(
'Localtimezone' );
231 $offset = $config->get(
'LocalTZoffset' );
232 if ( is_null( $tz ) ) {
235 } elseif ( is_null( $offset ) ) {
238 $data[
'timezone'] = $tz;
239 $data[
'timeoffset'] = intval( $offset );
240 $data[
'articlepath'] = $config->get(
'ArticlePath' );
241 $data[
'scriptpath'] = $config->get(
'ScriptPath' );
242 $data[
'script'] = $config->get(
'Script' );
243 $data[
'variantarticlepath'] = $config->get(
'VariantArticlePath' );
245 $data[
'server'] = $config->get(
'Server' );
246 $data[
'servername'] = $config->get(
'ServerName' );
248 $data[
'time'] =
wfTimestamp( TS_ISO_8601, time() );
250 $data[
'misermode'] = (bool)$config->get(
'MiserMode' );
254 $data[
'minuploadchunksize'] = (int)$config->get(
'MinUploadChunkSize' );
256 $data[
'galleryoptions'] = $config->get(
'GalleryOptions' );
258 $data[
'thumblimits'] = $config->get(
'ThumbLimits' );
261 $data[
'imagelimits'] = [];
264 foreach ( $config->get(
'ImageLimits' ) as $k => $limit ) {
265 $data[
'imagelimits'][$k] = [
'width' => $limit[0],
'height' => $limit[1] ];
268 $favicon = $config->get(
'Favicon' );
269 if ( !empty( $favicon ) ) {
275 $data[
'centralidlookupprovider'] = $config->get(
'CentralIdLookupProvider' );
276 $providerIds = array_keys( $config->get(
'CentralIdLookupProviders' ) );
277 $data[
'allcentralidlookupproviders'] = $providerIds;
279 $data[
'interwikimagic'] = (bool)$config->get(
'InterwikiMagic' );
280 $data[
'magiclinks'] = $config->get(
'EnableMagicLinks' );
282 $data[
'categorycollation'] = $config->get(
'CategoryCollation' );
284 Hooks::run(
'APIQuerySiteInfoGeneralInfo', [ $this, &$data ] );
294 foreach (
$wgContLang->getFormattedNamespaces() as $ns => $title ) {
296 'id' => intval( $ns ),
297 'case' => MWNamespace::isCapitalized( $ns ) ?
'first-letter' :
'case-sensitive',
300 $canonical = MWNamespace::getCanonicalName( $ns );
302 $data[$ns][
'subpages'] = MWNamespace::hasSubpages( $ns );
305 $data[$ns][
'canonical'] = strtr( $canonical,
'_',
' ' );
308 $data[$ns][
'content'] = MWNamespace::isContent( $ns );
309 $data[$ns][
'nonincludable'] = MWNamespace::isNonincludable( $ns );
311 $contentmodel = MWNamespace::getNamespaceContentModel( $ns );
312 if ( $contentmodel ) {
313 $data[$ns][
'defaultcontentmodel'] = $contentmodel;
325 $aliases = array_merge( $this->
getConfig()->
get(
'NamespaceAliases' ),
326 $wgContLang->getNamespaceAliases() );
329 foreach ( $aliases as $title => $ns ) {
335 'id' => intval( $ns )
353 if ( isset( $aliases[$specialpage] ) ) {
354 $arr = [
'realname' => $specialpage,
'aliases' => $aliases[$specialpage] ];
367 foreach (
$wgContLang->getMagicWords() as $magicword => $aliases ) {
368 $caseSensitive = array_shift( $aliases );
369 $arr = [
'name' => $magicword,
'aliases' => $aliases ];
370 $arr[
'case-sensitive'] = (bool)$caseSensitive;
381 if ( $filter ===
'local' ) {
383 } elseif ( $filter ===
'!local' ) {
385 } elseif ( $filter ) {
390 $langCode = isset(
$params[
'inlanguagecode'] ) ?
$params[
'inlanguagecode'] :
'';
391 $langNames = Language::fetchLanguageNames( $langCode );
393 $getPrefixes = MediaWikiServices::getInstance()->getInterwikiLookup()->getAllPrefixes( $local );
394 $extraLangPrefixes = $this->
getConfig()->get(
'ExtraInterlanguageLinkPrefixes' );
395 $localInterwikis = $this->
getConfig()->get(
'LocalInterwikis' );
398 foreach ( $getPrefixes as $row ) {
399 $prefix = $row[
'iw_prefix'];
401 $val[
'prefix'] = $prefix;
402 if ( isset( $row[
'iw_local'] ) && $row[
'iw_local'] ==
'1' ) {
403 $val[
'local'] =
true;
405 if ( isset( $row[
'iw_trans'] ) && $row[
'iw_trans'] ==
'1' ) {
406 $val[
'trans'] =
true;
409 if ( isset( $langNames[$prefix] ) ) {
410 $val[
'language'] = $langNames[$prefix];
412 if ( in_array( $prefix, $localInterwikis ) ) {
413 $val[
'localinterwiki'] =
true;
415 if ( in_array( $prefix, $extraLangPrefixes ) ) {
416 $val[
'extralanglink'] =
true;
418 $linktext =
wfMessage(
"interlanguage-link-$prefix" );
419 if ( !$linktext->isDisabled() ) {
420 $val[
'linktext'] = $linktext->text();
423 $sitename =
wfMessage(
"interlanguage-link-sitename-$prefix" );
424 if ( !$sitename->isDisabled() ) {
425 $val[
'sitename'] = $sitename->text();
430 $val[
'protorel'] = substr( $row[
'iw_url'], 0, 2 ) ==
'//';
431 if ( isset( $row[
'iw_wikiid'] ) && $row[
'iw_wikiid'] !==
'' ) {
432 $val[
'wikiid'] = $row[
'iw_wikiid'];
434 if ( isset( $row[
'iw_api'] ) && $row[
'iw_api'] !==
'' ) {
435 $val[
'api'] = $row[
'iw_api'];
448 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
449 $showHostnames = $this->
getConfig()->get(
'ShowHostnames' );
451 if ( !$showHostnames ) {
452 $this->
dieWithError(
'apierror-siteinfo-includealldenied',
'includeAllDenied' );
455 $lags = $lb->getLagTimes();
456 foreach ( $lags as $i => $lag ) {
458 'host' => $lb->getServerName( $i ),
463 list( , $lag, $index ) = $lb->getMaxLag();
465 'host' => $showHostnames
466 ? $lb->getServerName( $index )
488 Hooks::run(
'APIQuerySiteInfoStatisticsInfo', [ &$data ] );
499 foreach ( $config->get(
'GroupPermissions' ) as $group => $permissions ) {
502 'rights' => array_keys( $permissions,
true ),
505 if ( $numberInGroup ) {
506 $autopromote = $config->get(
'Autopromote' );
508 if ( $group ==
'user' ) {
511 } elseif ( $group !==
'*' && !isset( $autopromote[$group] ) ) {
517 'add' => $config->get(
'AddGroups' ),
518 'remove' => $config->get(
'RemoveGroups' ),
519 'add-self' => $config->get(
'GroupsAddToSelf' ),
520 'remove-self' => $config->get(
'GroupsRemoveFromSelf' )
523 foreach ( $groupArr as
$type => $rights ) {
524 if ( isset( $rights[$group] ) ) {
525 if ( $rights[$group] ===
true ) {
526 $groups = $allGroups;
528 $groups = array_intersect( $rights[$group], $allGroups );
531 $arr[
$type] = $groups;
544 return $result->addValue(
'query',
$property, $data );
549 foreach ( array_unique( $this->
getConfig()->
get(
'FileExtensions' ) ) as
$ext ) {
550 $data[] = [
'ext' =>
$ext ];
559 $path =
"$IP/vendor/composer/installed.json";
560 if ( !file_exists( $path ) ) {
566 foreach ( $installed->getInstalledDependencies() as $name => $info ) {
567 if ( strpos( $info[
'type'],
'mediawiki-' ) === 0 ) {
574 'version' => $info[
'version'],
584 foreach ( $this->
getConfig()->
get(
'ExtensionCredits' ) as
$type => $extensions ) {
585 foreach ( $extensions as
$ext ) {
588 if ( isset(
$ext[
'name'] ) ) {
591 if ( isset(
$ext[
'namemsg'] ) ) {
594 if ( isset(
$ext[
'description'] ) ) {
595 $ret[
'description'] =
$ext[
'description'];
597 if ( isset(
$ext[
'descriptionmsg'] ) ) {
599 if ( is_array(
$ext[
'descriptionmsg'] ) ) {
600 $ret[
'descriptionmsg'] =
$ext[
'descriptionmsg'][0];
601 $ret[
'descriptionmsgparams'] = array_slice(
$ext[
'descriptionmsg'], 1 );
604 $ret[
'descriptionmsg'] =
$ext[
'descriptionmsg'];
607 if ( isset(
$ext[
'author'] ) ) {
608 $ret[
'author'] = is_array(
$ext[
'author'] ) ?
609 implode(
', ',
$ext[
'author'] ) :
$ext[
'author'];
611 if ( isset(
$ext[
'url'] ) ) {
614 if ( isset(
$ext[
'version'] ) ) {
617 if ( isset(
$ext[
'path'] ) ) {
618 $extensionPath = dirname(
$ext[
'path'] );
619 $gitInfo =
new GitInfo( $extensionPath );
620 $vcsVersion = $gitInfo->getHeadSHA1();
621 if ( $vcsVersion !==
false ) {
622 $ret[
'vcs-system'] =
'git';
623 $ret[
'vcs-version'] = $vcsVersion;
624 $ret[
'vcs-url'] = $gitInfo->getHeadViewUrl();
625 $vcsDate = $gitInfo->getHeadCommitDate();
626 if ( $vcsDate !==
false ) {
632 $ret[
'license-name'] = isset(
$ext[
'license-name'] ) ?
$ext[
'license-name'] :
'';
633 $ret[
'license'] = SpecialPage::getTitleFor(
635 "License/{$ext['name']}"
640 $ret[
'credits'] = SpecialPage::getTitleFor(
642 "Credits/{$ext['name']}"
657 $rightsPage = $config->get(
'RightsPage' );
658 if ( is_string( $rightsPage ) ) {
659 $title = Title::newFromText( $rightsPage );
663 $url = $config->get(
'RightsUrl' );
665 $text = $config->get(
'RightsText' );
666 if ( !$text && $title ) {
667 $text = $title->getPrefixedText();
672 'text' => $text ?:
''
681 'types' => $config->get(
'RestrictionTypes' ),
682 'levels' => $config->get(
'RestrictionLevels' ),
683 'cascadinglevels' => $config->get(
'CascadingRestrictionLevels' ),
684 'semiprotectedlevels' => $config->get(
'SemiprotectedRestrictionLevels' ),
702 $langCode = isset(
$params[
'inlanguagecode'] ) ?
$params[
'inlanguagecode'] :
'';
703 $langNames = Language::fetchLanguageNames( $langCode );
707 foreach ( $langNames as
$code => $name ) {
720 $langNames = LanguageConverter::$languagesWithVariants;
721 if ( $this->
getConfig()->
get(
'DisableLangConversion' ) ) {
728 foreach ( $langNames as $langCode ) {
729 $lang = Language::factory( $langCode );
735 $data[$langCode] = [];
739 $variants =
$lang->getVariants();
741 foreach ( $variants as $v ) {
742 $fallbacks =
$lang->getConverter()->getVariantFallbacks( $v );
743 if ( !is_array( $fallbacks ) ) {
744 $fallbacks = [ $fallbacks ];
746 $data[$langCode][$v] = [
747 'fallbacks' => $fallbacks,
750 $data[$langCode][$v][
'fallbacks'],
'variant'
762 $allowed = Skin::getAllowedSkins();
763 $default = Skin::normalizeKey(
'default' );
764 foreach ( Skin::getSkinNames() as $name => $displayName ) {
765 $msg = $this->
msg(
"skinname-{$name}" );
767 if (
$code && Language::isValidCode(
$code ) ) {
768 $msg->inLanguage(
$code );
770 $msg->inContentLanguage();
772 if ( $msg->exists() ) {
773 $displayName = $msg->text();
775 $skin = [
'code' =>
$name ];
777 if ( !isset( $allowed[$name] ) ) {
778 $skin[
'unusable'] =
true;
780 if ( $name === $default ) {
781 $skin[
'default'] =
true;
793 $tags = array_map( [ $this,
'formatParserTags' ],
$wgParser->getTags() );
820 $protocols = array_values( $this->
getConfig()->
get(
'UrlProtocols' ) );
834 $config = $this->
getConfig()->get(
'UploadDialog' );
843 $hooks = $this->
getConfig()->get(
'Hooks' );
848 foreach ( $myWgHooks as $name => $subscribers ) {
851 'subscribers' => array_map( [ SpecialVersion::class,
'arrayToString' ], $subscribers ),
867 count( $this->
getConfig()->
get(
'ExtraInterlanguageLinkPrefixes' ) ) &&
869 in_array(
'interwikimap',
$params[
'prop'] )
871 return 'anon-public-user-private';
886 'specialpagealiases',
916 'showalldb' =>
false,
917 'numberingroup' =>
false,
918 'inlanguagecode' =>
null,
924 'action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics'
925 =>
'apihelp-query+siteinfo-example-simple',
926 'action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local'
927 =>
'apihelp-query+siteinfo-example-interwiki',
928 'action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb='
929 =>
'apihelp-query+siteinfo-example-replag',
934 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Siteinfo';
wfReadOnly()
Check whether the wiki is in read-only mode.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
getResult()
Get the result object.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
getDB()
Get the Query database connection (read-only)
A query action to return meta information about the wiki site.
appendLanguageVariants( $property)
appendLanguages( $property)
appendInterwikiMap( $property, $filter)
appendGeneralInfo( $property)
__construct(ApiQuery $query, $moduleName)
appendRightsInfo( $property)
getExamplesMessages()
Returns usage examples for this module.
appendInstalledLibraries( $property)
appendVariables( $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)
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.
const META_TYPE
Key for the 'type' metadata item.
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
const META_BC_BOOLS
Key for the 'BC bools' metadata item.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
Reads an installed.json file and provides accessors to get what is installed.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
A fake language variant converter.
static getVariableIDs()
Get an array of parser variable IDs.
static jobs()
Total number of jobs in the job queue.
static numberingroup( $group)
Find the number of users in a given user group.
static getNames()
Returns a list of canonical special page names.
static getGitHeadSha1( $dir)
static getExtLicenseFileName( $extDir)
Obtains the full path of an extensions copying or license file if one exists.
static getExtAuthorsFileName( $extDir)
Obtains the full path of an extensions authors or credits file if one exists.
static getGitCurrentBranch( $dir)
static isEnabled()
Returns true if uploads are enabled.
static getMaxUploadSize( $forType=null)
Get the MediaWiki maximum uploaded file size for given type of upload, based on $wgMaxUploadSize.
static getAllGroups()
Return the set of defined explicit groups.
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace and then decline to actually register it & $namespaces
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Allows to change the fields on the form that will be generated $name
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
if(!is_readable( $file)) $ext
if(!isset( $args[0])) $lang