From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/api/ApiQuerySiteinfo.php | 340 +++++++++++++++++++++++++++----------- 1 file changed, 248 insertions(+), 92 deletions(-) (limited to 'includes/api/ApiQuerySiteinfo.php') diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index a7767062..311438fd 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -31,7 +31,7 @@ */ class ApiQuerySiteinfo extends ApiQueryBase { - public function __construct( $query, $moduleName ) { + public function __construct( ApiQuery $query, $moduleName ) { parent::__construct( $query, $moduleName, 'si' ); } @@ -78,6 +78,9 @@ class ApiQuerySiteinfo extends ApiQueryBase { case 'rightsinfo': $fit = $this->appendRightsInfo( $p ); break; + case 'restrictions': + $fit = $this->appendRestrictions( $p ); + break; case 'languages': $fit = $this->appendLanguages( $p ); break; @@ -99,6 +102,9 @@ class ApiQuerySiteinfo extends ApiQueryBase { case 'protocols': $fit = $this->appendProtocols( $p ); break; + case 'defaultoptions': + $fit = $this->appendDefaultOptions( $p ); + break; default: ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" ); } @@ -106,7 +112,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { // Abuse siprop as a query-continue parameter // and set it to all unprocessed props $this->setContinueEnumParameter( 'prop', implode( '|', - array_diff( $params['prop'], $done ) ) ); + array_diff( $params['prop'], $done ) ) ); break; } $done[] = $p; @@ -114,29 +120,37 @@ class ApiQuerySiteinfo extends ApiQueryBase { } protected function appendGeneralInfo( $property ) { - global $wgContLang, - $wgDisableLangConversion, - $wgDisableTitleConversion; + global $wgContLang; + + $config = $this->getConfig(); $data = array(); $mainPage = Title::newMainPage(); $data['mainpage'] = $mainPage->getPrefixedText(); $data['base'] = wfExpandUrl( $mainPage->getFullURL(), PROTO_CURRENT ); - $data['sitename'] = $GLOBALS['wgSitename']; - $data['logo'] = $GLOBALS['wgLogo']; - $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}"; - $data['phpversion'] = phpversion(); + $data['sitename'] = $config->get( 'Sitename' ); + + // wgLogo can either be a relative or an absolute path + // make sure we always return an absolute path + $data['logo'] = wfExpandUrl( $config->get( 'Logo' ), PROTO_RELATIVE ); + + $data['generator'] = "MediaWiki {$config->get( 'Version' )}"; + + $data['phpversion'] = PHP_VERSION; $data['phpsapi'] = PHP_SAPI; - $data['dbtype'] = $GLOBALS['wgDBtype']; + if ( defined( 'HHVM_VERSION' ) ) { + $data['hhvmversion'] = HHVM_VERSION; + } + $data['dbtype'] = $config->get( 'DBtype' ); $data['dbversion'] = $this->getDB()->getServerVersion(); $allowFrom = array( '' ); $allowException = true; - if ( !$GLOBALS['wgAllowExternalImages'] ) { - if ( $GLOBALS['wgEnableImageWhitelist'] ) { + if ( !$config->get( 'AllowExternalImages' ) ) { + if ( $config->get( 'EnableImageWhitelist' ) ) { $data['imagewhitelistenabled'] = ''; } - $allowFrom = $GLOBALS['wgAllowExternalImagesFrom']; + $allowFrom = $config->get( 'AllowExternalImagesFrom' ); $allowException = !empty( $allowFrom ); } if ( $allowException ) { @@ -144,17 +158,21 @@ class ApiQuerySiteinfo extends ApiQueryBase { $this->getResult()->setIndexedTagName( $data['externalimages'], 'prefix' ); } - if ( !$wgDisableLangConversion ) { + if ( !$config->get( 'DisableLangConversion' ) ) { $data['langconversion'] = ''; } - if ( !$wgDisableTitleConversion ) { + if ( !$config->get( 'DisableTitleConversion' ) ) { $data['titleconversion'] = ''; } if ( $wgContLang->linkPrefixExtension() ) { - $data['linkprefix'] = wfMessage( 'linkprefix' )->inContentLanguage()->text(); + $linkPrefixCharset = $wgContLang->linkPrefixCharset(); + $data['linkprefixcharset'] = $linkPrefixCharset; + // For backwards compatibility + $data['linkprefix'] = "/^((?>.*[^$linkPrefixCharset]|))(.+)$/sDu"; } else { + $data['linkprefixcharset'] = ''; $data['linkprefix'] = ''; } @@ -165,24 +183,22 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data['linktrail'] = ''; } - $git = SpecialVersion::getGitHeadSha1( $GLOBALS['IP'] ); + global $IP; + $git = SpecialVersion::getGitHeadSha1( $IP ); if ( $git ) { $data['git-hash'] = $git; + $data['git-branch'] = + SpecialVersion::getGitCurrentBranch( $GLOBALS['IP'] ); } else { - $svn = SpecialVersion::getSvnRevision( $GLOBALS['IP'] ); + $svn = SpecialVersion::getSvnRevision( $IP ); if ( $svn ) { $data['rev'] = $svn; } } // 'case-insensitive' option is reserved for future - $data['case'] = $GLOBALS['wgCapitalLinks'] ? 'first-letter' : 'case-sensitive'; - - if ( isset( $GLOBALS['wgRightsCode'] ) ) { - $data['rightscode'] = $GLOBALS['wgRightsCode']; - } - $data['rights'] = $GLOBALS['wgRightsText']; - $data['lang'] = $GLOBALS['wgLanguageCode']; + $data['case'] = $config->get( 'CapitalLinks' ) ? 'first-letter' : 'case-sensitive'; + $data['lang'] = $config->get( 'LanguageCode' ); $fallbacks = array(); foreach ( $wgContLang->getFallbackLanguages() as $code ) { @@ -194,7 +210,10 @@ class ApiQuerySiteinfo extends ApiQueryBase { if ( $wgContLang->hasVariants() ) { $variants = array(); foreach ( $wgContLang->getVariants() as $code ) { - $variants[] = array( 'code' => $code ); + $variants[] = array( + 'code' => $code, + 'name' => $wgContLang->getVariantname( $code ), + ); } $data['variants'] = $variants; $this->getResult()->setIndexedTagName( $data['variants'], 'lang' ); @@ -209,12 +228,12 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data['readonly'] = ''; $data['readonlyreason'] = wfReadOnlyReason(); } - if ( $GLOBALS['wgEnableWriteAPI'] ) { + if ( $config->get( 'EnableWriteAPI' ) ) { $data['writeapi'] = ''; } - $tz = $GLOBALS['wgLocaltimezone']; - $offset = $GLOBALS['wgLocalTZoffset']; + $tz = $config->get( 'Localtimezone' ); + $offset = $config->get( 'LocalTZoffset' ); if ( is_null( $tz ) ) { $tz = 'UTC'; $offset = 0; @@ -223,20 +242,36 @@ class ApiQuerySiteinfo extends ApiQueryBase { } $data['timezone'] = $tz; $data['timeoffset'] = intval( $offset ); - $data['articlepath'] = $GLOBALS['wgArticlePath']; - $data['scriptpath'] = $GLOBALS['wgScriptPath']; - $data['script'] = $GLOBALS['wgScript']; - $data['variantarticlepath'] = $GLOBALS['wgVariantArticlePath']; - $data['server'] = $GLOBALS['wgServer']; + $data['articlepath'] = $config->get( 'ArticlePath' ); + $data['scriptpath'] = $config->get( 'ScriptPath' ); + $data['script'] = $config->get( 'Script' ); + $data['variantarticlepath'] = $config->get( 'VariantArticlePath' ); + $data['server'] = $config->get( 'Server' ); + $data['servername'] = $config->get( 'ServerName' ); $data['wikiid'] = wfWikiID(); $data['time'] = wfTimestamp( TS_ISO_8601, time() ); - if ( $GLOBALS['wgMiserMode'] ) { + if ( $config->get( 'MiserMode' ) ) { $data['misermode'] = ''; } $data['maxuploadsize'] = UploadBase::getMaxUploadSize(); + $data['thumblimits'] = $config->get( 'ThumbLimits' ); + $this->getResult()->setIndexedTagName( $data['thumblimits'], 'limit' ); + $data['imagelimits'] = array(); + $this->getResult()->setIndexedTagName( $data['imagelimits'], 'limit' ); + foreach ( $config->get( 'ImageLimits' ) as $k => $limit ) { + $data['imagelimits'][$k] = array( 'width' => $limit[0], 'height' => $limit[1] ); + } + + $favicon = $config->get( 'Favicon' ); + if ( !empty( $favicon ) ) { + // wgFavicon can either be a relative or an absolute path + // make sure we always return an absolute path + $data['favicon'] = wfExpandUrl( $favicon, PROTO_RELATIVE ); + } + wfRunHooks( 'APIQuerySiteInfoGeneralInfo', array( $this, &$data ) ); return $this->getResult()->addValue( 'query', $property, $data ); @@ -276,12 +311,14 @@ class ApiQuerySiteinfo extends ApiQueryBase { } $this->getResult()->setIndexedTagName( $data, 'ns' ); + return $this->getResult()->addValue( 'query', $property, $data ); } protected function appendNamespaceAliases( $property ) { - global $wgNamespaceAliases, $wgContLang; - $aliases = array_merge( $wgNamespaceAliases, $wgContLang->getNamespaceAliases() ); + global $wgContLang; + $aliases = array_merge( $this->getConfig()->get( 'NamespaceAliases' ), + $wgContLang->getNamespaceAliases() ); $namespaces = $wgContLang->getNamespaces(); $data = array(); foreach ( $aliases as $title => $ns ) { @@ -299,6 +336,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { sort( $data ); $this->getResult()->setIndexedTagName( $data, 'ns' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -306,7 +344,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { global $wgContLang; $data = array(); $aliases = $wgContLang->getSpecialPageAliases(); - foreach ( SpecialPageFactory::getList() as $specialpage => $stuff ) { + foreach ( SpecialPageFactory::getNames() as $specialpage ) { if ( isset( $aliases[$specialpage] ) ) { $arr = array( 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] ); $this->getResult()->setIndexedTagName( $arr['aliases'], 'alias' ); @@ -314,6 +352,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } } $this->getResult()->setIndexedTagName( $data, 'specialpage' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -330,6 +369,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data[] = $arr; } $this->getResult()->setIndexedTagName( $data, 'magicword' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -348,20 +388,45 @@ class ApiQuerySiteinfo extends ApiQueryBase { $langNames = Language::fetchLanguageNames( $langCode ); $getPrefixes = Interwiki::getAllPrefixes( $local ); + $extraLangPrefixes = $this->getConfig()->get( 'ExtraInterlanguageLinkPrefixes' ); + $localInterwikis = $this->getConfig()->get( 'LocalInterwikis' ); $data = array(); foreach ( $getPrefixes as $row ) { $prefix = $row['iw_prefix']; $val = array(); $val['prefix'] = $prefix; - if ( $row['iw_local'] == '1' ) { + if ( isset( $row['iw_local'] ) && $row['iw_local'] == '1' ) { $val['local'] = ''; } - // $val['trans'] = intval( $row['iw_trans'] ); // should this be exposed? + if ( isset( $row['iw_trans'] ) && $row['iw_trans'] == '1' ) { + $val['trans'] = ''; + } + if ( isset( $langNames[$prefix] ) ) { $val['language'] = $langNames[$prefix]; } + if ( in_array( $prefix, $localInterwikis ) ) { + $val['localinterwiki'] = ''; + } + if ( in_array( $prefix, $extraLangPrefixes ) ) { + $val['extralanglink'] = ''; + + $linktext = wfMessage( "interlanguage-link-$prefix" ); + if ( !$linktext->isDisabled() ) { + $val['linktext'] = $linktext->text(); + } + + $sitename = wfMessage( "interlanguage-link-sitename-$prefix" ); + if ( !$sitename->isDisabled() ) { + $val['sitename'] = $sitename->text(); + } + } + $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT ); + if ( substr( $row['iw_url'], 0, 2 ) == '//' ) { + $val['protorel'] = ''; + } if ( isset( $row['iw_wikiid'] ) ) { $val['wikiid'] = $row['iw_wikiid']; } @@ -373,16 +438,20 @@ class ApiQuerySiteinfo extends ApiQueryBase { } $this->getResult()->setIndexedTagName( $data, 'iw' ); + return $this->getResult()->addValue( 'query', $property, $data ); } protected function appendDbReplLagInfo( $property, $includeAll ) { - global $wgShowHostnames; $data = array(); $lb = wfGetLB(); + $showHostnames = $this->getConfig()->get( 'ShowHostnames' ); if ( $includeAll ) { - if ( !$wgShowHostnames ) { - $this->dieUsage( 'Cannot view all servers info unless $wgShowHostnames is true', 'includeAllDenied' ); + if ( !$showHostnames ) { + $this->dieUsage( + 'Cannot view all servers info unless $wgShowHostnames is true', + 'includeAllDenied' + ); } $lags = $lb->getLagTimes(); @@ -395,7 +464,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } else { list( , $lag, $index ) = $lb->getMaxLag(); $data[] = array( - 'host' => $wgShowHostnames + 'host' => $showHostnames ? $lb->getServerName( $index ) : '', 'lag' => intval( $lag ) @@ -404,15 +473,15 @@ class ApiQuerySiteinfo extends ApiQueryBase { $result = $this->getResult(); $result->setIndexedTagName( $data, 'db' ); + return $this->getResult()->addValue( 'query', $property, $data ); } protected function appendStatistics( $property ) { - global $wgDisableCounters; $data = array(); $data['pages'] = intval( SiteStats::pages() ); $data['articles'] = intval( SiteStats::articles() ); - if ( !$wgDisableCounters ) { + if ( !$this->getConfig()->get( 'DisableCounters' ) ) { $data['views'] = intval( SiteStats::views() ); } $data['edits'] = intval( SiteStats::edits() ); @@ -428,40 +497,42 @@ class ApiQuerySiteinfo extends ApiQueryBase { } protected function appendUserGroups( $property, $numberInGroup ) { - global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups; - global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf; + $config = $this->getConfig(); $data = array(); $result = $this->getResult(); - foreach ( $wgGroupPermissions as $group => $permissions ) { + $allGroups = User::getAllGroups(); + foreach ( $config->get( 'GroupPermissions' ) as $group => $permissions ) { $arr = array( 'name' => $group, 'rights' => array_keys( $permissions, true ), ); if ( $numberInGroup ) { - global $wgAutopromote; + $autopromote = $config->get( 'Autopromote' ); if ( $group == 'user' ) { $arr['number'] = SiteStats::users(); - // '*' and autopromote groups have no size - } elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) { + } elseif ( $group !== '*' && !isset( $autopromote[$group] ) ) { $arr['number'] = SiteStats::numberInGroup( $group ); } } $groupArr = array( - 'add' => $wgAddGroups, - 'remove' => $wgRemoveGroups, - 'add-self' => $wgGroupsAddToSelf, - 'remove-self' => $wgGroupsRemoveFromSelf + 'add' => $config->get( 'AddGroups' ), + 'remove' => $config->get( 'RemoveGroups' ), + 'add-self' => $config->get( 'GroupsAddToSelf' ), + 'remove-self' => $config->get( 'GroupsRemoveFromSelf' ) ); foreach ( $groupArr as $type => $rights ) { if ( isset( $rights[$group] ) ) { - $arr[$type] = $rights[$group]; - $result->setIndexedTagName( $arr[$type], 'group' ); + $groups = array_intersect( $rights[$group], $allGroups ); + if ( $groups ) { + $arr[$type] = $groups; + $result->setIndexedTagName( $arr[$type], 'group' ); + } } } @@ -470,30 +541,32 @@ class ApiQuerySiteinfo extends ApiQueryBase { } $result->setIndexedTagName( $data, 'group' ); + return $result->addValue( 'query', $property, $data ); } protected function appendFileExtensions( $property ) { - global $wgFileExtensions; - $data = array(); - foreach ( array_unique( $wgFileExtensions ) as $ext ) { + foreach ( array_unique( $this->getConfig()->get( 'FileExtensions' ) ) as $ext ) { $data[] = array( 'ext' => $ext ); } $this->getResult()->setIndexedTagName( $data, 'fe' ); + return $this->getResult()->addValue( 'query', $property, $data ); } protected function appendExtensions( $property ) { - global $wgExtensionCredits; $data = array(); - foreach ( $wgExtensionCredits as $type => $extensions ) { + foreach ( $this->getConfig()->get( 'ExtensionCredits' ) as $type => $extensions ) { foreach ( $extensions as $ext ) { $ret = array(); $ret['type'] = $type; if ( isset( $ext['name'] ) ) { $ret['name'] = $ext['name']; } + if ( isset( $ext['namemsg'] ) ) { + $ret['namemsg'] = $ext['namemsg']; + } if ( isset( $ext['description'] ) ) { $ret['description'] = $ext['description']; } @@ -515,26 +588,63 @@ class ApiQuerySiteinfo extends ApiQueryBase { $ret['url'] = $ext['url']; } if ( isset( $ext['version'] ) ) { - $ret['version'] = $ext['version']; + $ret['version'] = $ext['version']; } elseif ( isset( $ext['svn-revision'] ) && preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/', - $ext['svn-revision'], $m ) ) - { - $ret['version'] = 'r' . $m[1]; + $ext['svn-revision'], $m ) + ) { + $ret['version'] = 'r' . $m[1]; + } + if ( isset( $ext['path'] ) ) { + $extensionPath = dirname( $ext['path'] ); + $gitInfo = new GitInfo( $extensionPath ); + $vcsVersion = $gitInfo->getHeadSHA1(); + if ( $vcsVersion !== false ) { + $ret['vcs-system'] = 'git'; + $ret['vcs-version'] = $vcsVersion; + $ret['vcs-url'] = $gitInfo->getHeadViewUrl(); + $vcsDate = $gitInfo->getHeadCommitDate(); + if ( $vcsDate !== false ) { + $ret['vcs-date'] = wfTimestamp( TS_ISO_8601, $vcsDate ); + } + } else { + $svnInfo = SpecialVersion::getSvnInfo( $extensionPath ); + if ( $svnInfo !== false ) { + $ret['vcs-system'] = 'svn'; + $ret['vcs-version'] = $svnInfo['checkout-rev']; + $ret['vcs-url'] = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : ''; + } + } + + if ( SpecialVersion::getExtLicenseFileName( $extensionPath ) ) { + $ret['license-name'] = isset( $ext['license-name'] ) ? $ext['license-name'] : ''; + $ret['license'] = SpecialPage::getTitleFor( + 'Version', + "License/{$ext['name']}" + )->getLinkURL(); + } + + if ( SpecialVersion::getExtAuthorsFileName( $extensionPath ) ) { + $ret['credits'] = SpecialPage::getTitleFor( + 'Version', + "Credits/{$ext['name']}" + )->getLinkURL(); + } } $data[] = $ret; } } $this->getResult()->setIndexedTagName( $data, 'ext' ); + return $this->getResult()->addValue( 'query', $property, $data ); } protected function appendRightsInfo( $property ) { - global $wgRightsPage, $wgRightsUrl, $wgRightsText; - $title = Title::newFromText( $wgRightsPage ); - $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl; - $text = $wgRightsText; + $config = $this->getConfig(); + $title = Title::newFromText( $config->get( 'RightsPage' ) ); + $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $config->get( 'RightsUrl' ); + $text = $config->get( 'RightsText' ); if ( !$text && $title ) { $text = $title->getPrefixedText(); } @@ -547,6 +657,23 @@ class ApiQuerySiteinfo extends ApiQueryBase { return $this->getResult()->addValue( 'query', $property, $data ); } + protected function appendRestrictions( $property ) { + $config = $this->getConfig(); + $data = array( + 'types' => $config->get( 'RestrictionTypes' ), + 'levels' => $config->get( 'RestrictionLevels' ), + 'cascadinglevels' => $config->get( 'CascadingRestrictionLevels' ), + 'semiprotectedlevels' => $config->get( 'SemiprotectedRestrictionLevels' ), + ); + + $this->getResult()->setIndexedTagName( $data['types'], 'type' ); + $this->getResult()->setIndexedTagName( $data['levels'], 'level' ); + $this->getResult()->setIndexedTagName( $data['cascadinglevels'], 'level' ); + $this->getResult()->setIndexedTagName( $data['semiprotectedlevels'], 'level' ); + + return $this->getResult()->addValue( 'query', $property, $data ); + } + public function appendLanguages( $property ) { $params = $this->extractRequestParams(); $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : ''; @@ -560,17 +687,28 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data[] = $lang; } $this->getResult()->setIndexedTagName( $data, 'lang' ); + return $this->getResult()->addValue( 'query', $property, $data ); } public function appendSkins( $property ) { $data = array(); - $usable = Skin::getUsableSkins(); + $allowed = Skin::getAllowedSkins(); $default = Skin::normalizeKey( 'default' ); foreach ( Skin::getSkinNames() as $name => $displayName ) { + $msg = $this->msg( "skinname-{$name}" ); + $code = $this->getParameter( 'inlanguagecode' ); + if ( $code && Language::isValidCode( $code ) ) { + $msg->inLanguage( $code ); + } else { + $msg->inContentLanguage(); + } + if ( $msg->exists() ) { + $displayName = $msg->text(); + } $skin = array( 'code' => $name ); ApiResult::setContent( $skin, $displayName ); - if ( !isset( $usable[$name] ) ) { + if ( !isset( $allowed[$name] ) ) { $skin['unusable'] = ''; } if ( $name === $default ) { @@ -579,6 +717,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data[] = $skin; } $this->getResult()->setIndexedTagName( $data, 'skin' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -587,6 +726,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $wgParser->firstCallInit(); $tags = array_map( array( $this, 'formatParserTags' ), $wgParser->getTags() ); $this->getResult()->setIndexedTagName( $tags, 't' ); + return $this->getResult()->addValue( 'query', $property, $tags ); } @@ -595,37 +735,43 @@ class ApiQuerySiteinfo extends ApiQueryBase { $wgParser->firstCallInit(); $hooks = $wgParser->getFunctionHooks(); $this->getResult()->setIndexedTagName( $hooks, 'h' ); + return $this->getResult()->addValue( 'query', $property, $hooks ); } public function appendVariables( $property ) { $variables = MagicWord::getVariableIDs(); $this->getResult()->setIndexedTagName( $variables, 'v' ); + return $this->getResult()->addValue( 'query', $property, $variables ); } public function appendProtocols( $property ) { - global $wgUrlProtocols; // Make a copy of the global so we don't try to set the _element key of it - bug 45130 - $protocols = array_values( $wgUrlProtocols ); + $protocols = array_values( $this->getConfig()->get( 'UrlProtocols' ) ); $this->getResult()->setIndexedTagName( $protocols, 'p' ); + return $this->getResult()->addValue( 'query', $property, $protocols ); } + public function appendDefaultOptions( $property ) { + return $this->getResult()->addValue( 'query', $property, User::getDefaultOptions() ); + } + private function formatParserTags( $item ) { return "<{$item}>"; } public function appendSubscribedHooks( $property ) { - global $wgHooks; - $myWgHooks = $wgHooks; + $hooks = $this->getConfig()->get( 'Hooks' ); + $myWgHooks = $hooks; ksort( $myWgHooks ); $data = array(); - foreach ( $myWgHooks as $hook => $hooks ) { + foreach ( $myWgHooks as $name => $subscribers ) { $arr = array( - 'name' => $hook, - 'subscribers' => array_map( array( 'SpecialVersion', 'arrayToString' ), $hooks ), + 'name' => $name, + 'subscribers' => array_map( array( 'SpecialVersion', 'arrayToString' ), $subscribers ), ); $this->getResult()->setIndexedTagName( $arr['subscribers'], 's' ); @@ -633,10 +779,20 @@ class ApiQuerySiteinfo extends ApiQueryBase { } $this->getResult()->setIndexedTagName( $data, 'hook' ); + return $this->getResult()->addValue( 'query', $property, $data ); } public function getCacheMode( $params ) { + // Messages for $wgExtraInterlanguageLinkPrefixes depend on user language + if ( + count( $this->getConfig()->get( 'ExtraInterlanguageLinkPrefixes' ) ) && + !is_null( $params['prop'] ) && + in_array( 'interwikimap', $params['prop'] ) + ) { + return 'anon-public-user-private'; + } + return 'public'; } @@ -658,6 +814,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { 'extensions', 'fileextensions', 'rightsinfo', + 'restrictions', 'languages', 'skins', 'extensiontags', @@ -665,6 +822,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { 'showhooks', 'variables', 'protocols', + 'defaultoptions', ) ), 'filteriw' => array( @@ -681,6 +839,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { public function getParamDescription() { $p = $this->getModulePrefix(); + return array( 'prop' => array( 'Which sysinfo properties to get:', @@ -690,38 +849,35 @@ class ApiQuerySiteinfo extends ApiQueryBase { ' specialpagealiases - List of special page aliases', ' magicwords - List of magic words and their aliases', ' statistics - Returns site statistics', - " interwikimap - Returns interwiki map " . + ' interwikimap - Returns interwiki map ' . "(optionally filtered, (optionally localised by using {$p}inlanguagecode))", ' dbrepllag - Returns database server with the highest replication lag', ' usergroups - Returns user groups and the associated permissions', ' extensions - Returns extensions installed on the wiki', ' fileextensions - Returns list of file extensions allowed to be uploaded', ' rightsinfo - Returns wiki rights (license) information if available', - " languages - Returns a list of languages MediaWiki supports" . + ' restrictions - Returns information on available restriction (protection) types', + ' languages - Returns a list of languages MediaWiki supports ' . "(optionally localised by using {$p}inlanguagecode)", - ' skins - Returns a list of all enabled skins', + ' skins - Returns a list of all enabled skins ' . + "(optionally localised by using {$p}inlanguagecode, otherwise in content language)", ' extensiontags - Returns a list of parser extension tags', ' functionhooks - Returns a list of parser function hooks', ' showhooks - Returns a list of all subscribed hooks (contents of $wgHooks)', ' variables - Returns a list of variable IDs', ' protocols - Returns a list of protocols that are allowed in external links.', + ' defaultoptions - Returns the default values for user preferences.', ), 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map', 'showalldb' => 'List all database servers, not just the one lagging the most', 'numberingroup' => 'Lists the number of users in user groups', - 'inlanguagecode' => 'Language code for localised language names (best effort, use CLDR extension)', + 'inlanguagecode' => 'Language code for localised language names ' . + '(best effort, use CLDR extension) and skin names', ); } public function getDescription() { - return 'Return general information about the site'; - } - - public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( array( - 'code' => 'includeAllDenied', - 'info' => 'Cannot view all servers info unless $wgShowHostnames is true' - ), ) ); + return 'Return general information about the site.'; } public function getExamples() { -- cgit v1.2.3-54-g00ecf