From: Roan Kattouw Date: Fri, 16 Jan 2009 21:03:13 +0000 (+0000) Subject: API: (bug 17027) Allow all configuration variables in $wgAPIReadableConfigVars to... X-Git-Tag: 1.31.0-rc.0~43392 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=d16183122324d9a765d694574083a7bee40d2fea;p=lhc%2Fweb%2Fwiklou.git API: (bug 17027) Allow all configuration variables in $wgAPIReadableConfigVars to be read through meta=siteinfo&siprop=configvars. I tried my best to only make useful stuff readable and skip stuff that's sensitive (like $wgDBpassword), available already (like $wgExtraNamespaces) or useless (like $wgUpdateRowsPerJob). --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4dc2fc0433..c2a79c5eef 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -48,7 +48,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions and listing all deleted pages possible * (bug 16844) Added clcategories parameter to prop=categories -* (bug 17025) Add "fileextension" parameter to meta=siteinfo&siprop= +* (bug 17025) Added siprop=fileextension to meta=siteinfo +* (bug 17027) Added siprop=configvars to meta=siteinfo === Languages updated in 1.15 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d849910d78..ca26e666f2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3647,3 +3647,192 @@ $wgUniversalEditButton = true; * and the functionality will be enabled universally. */ $wgEnforceHtmlIds = true; + +/** + * Allow the variables in this array to be retrieved through the API + * (meta=siteinfo&siprop=configvars). + * WARNING: DO NOT put sensitive stuff like $wgDBpassword in here + */ + +$wgAPIReadableConfigVars = array( + 'wgVersion', + 'wgSitename', + 'wgMetaNamespace', + 'wgMetaNamespaceTalk', + 'wgServer', + 'wgServerName', + 'wgProto', + 'wgScriptPath', + 'wgUsePathInfo', + 'wgScriptExtension', + 'wgScript', + 'wgRedirectScript', + 'wgStylePath', + 'wgArticlePath', + 'wgVariantArticlePath', + 'wgUploadPath', + 'wgLogo', + 'wgFavicon', + 'wgAppleTouchIcon', + 'wgMathPath', + 'wgUploadBaseUrl', + 'wgLegalTitleChars', + 'wgUrlProtocols', + 'wgVerifyMimeType', + 'wgLoadFileinfoExtension', + 'wgTrivialMimeDetection', + 'wgActionPaths', + 'wgUseSharedUploads', + 'wgSharedUploadPath', + 'wgFetchCommonsDescriptions', + 'wgCacheSharedUploads', + 'wgAllowCopyUploads', + 'wgMaxUploadSize', + 'wgUploadNavigationUrl', + 'wgRepositoryBaseUrl', + 'wgEmergencyContact', + 'wgPasswordSender', + 'wgNoReplyAddress', + 'wgEnableEmail', + 'wgEnableUserEmail', + 'wgUserEmailUseReplyTo', + 'wgPasswordReminderResendTime', + 'wgNewPasswordExpiry', + 'wgSearchType', + 'wgLanguageCode', + 'wgGrammarForms', + 'wgInterwikiMagic', + 'wgHideInterlanguageLinks', + 'wgExtraLanguageNames', + 'wgUseDynamicDates', + 'wgAmericanDates', + 'wgTranslateNumerals', + 'wgDisableLangConversion', + 'wgDisableTitleConversion', + 'wgDefaultLanguageVariant', + 'wgLoginLanguageSelector', + 'wgLocalInterwiki', + 'wgRedirectSources', + 'wgShowIPinHeader', + 'wgMaxSigChars', + 'wgMaxArticleSize', + 'wgMaxNameChars', + 'wgMaxPPNodeCount', + 'wgMaxTemplateDepth', + 'wgMaxPPExpandDepth', + 'wgCleanSignatures', + 'wgExtraSubtitle', + 'wgSiteSupportPage', + 'wgReadOnly', + 'wgSpecialVersionShowHooks', + 'wgColorErrors', + 'wgShowHostnames', + 'wgUseCategoryBrowser', + 'wgUseCommaCount', + 'wgSysopUserBans', + 'wgSysopRangeBans', + 'wgAutoblockExpiry', + 'wgBlockAllowsUTEdit', + 'wgSysopEmailBans', + 'wgWhitelistRead', + 'wgEmailConfirmToEdit', + 'wgRestrictionTypes', + 'wgRestrictionLevels', + 'wgNamespaceProtection', + 'wgNonincludableNamespaces', + 'wgAutoConfirmAge', + 'wgAutoConfirmCount', + 'wgAutopromote', + 'wgAddGroups', + 'wgRemoveGroups', + 'wgAvailableRights', + 'wgDeleteRevisionsLimit', + 'wgActiveUserEditCount', + 'wgActiveUserDays', + 'wgEnotifFromEditor', + 'wgEmailAuthentication', + 'wgEnotifWatchlist', + 'wgEnotifUserTalk', + 'wgEnotifRevealEditorAddress', + 'wgEnotifMinorEdits', + 'wgEnotifImpersonal', + 'wgEnotifMaxRecips', + 'wgEnotifUseJobQ', + 'wgEnotifUseRealName', + 'wgUsersNotifiedOnAllChanges', + 'wgRCShowWatchingUsers', + 'wgPageShowWatchingUsers', + 'wgRCShowChangedSize', + 'wgRCChangedSizeThreshold', + 'wgShowUpdatedMarker', + 'wgCookieExpiration', + 'wgCookieDomain', + 'wgCookiePath', + 'wgCookieSecure', + 'wgDisableCookieCheck', + 'wgCookiePrefix', + 'wgSessionName', + 'wgAllowExternalImages', + 'wgAllowExternalImagesFrom', + 'wgEnableImageWhitelist', + 'wgAllowImageMoving', + 'wgUseTeX', + 'wgDisableCounters', + 'wgDisableTextSearch', + 'wgDisableSearchContext', + 'wgEnableMWSuggest', + 'wgEnableUploads', + 'wgShowEXIF', + 'wgRemoteUploads', + 'wgDisableAnonTalk', + 'wgFileBlacklist', + 'wgMimeTypeBlacklist', + 'wgCheckFileExtensions', + 'wgStrictFileExtensions', + 'wgUploadSizeWarning', + 'wgNamespacesToBeSearchedDefault', + 'wgNamespacesToBeSearchedProject', + 'wgSiteNotice', + 'wgRCMaxAge', + 'wgUseMetadataEdit', + 'wgMetadataWhitelist', + 'wgUseCopyrightUpload', + 'wgCheckCopyrightUpload', + 'wgCapitalLinks', + 'wgImportSources', + 'wgImportTargetNamespace', + 'wgExportAllowHistory', + 'wgExportMaxHistory', + 'wgExportAllowListContributors', + 'wgUseTidy', + 'wgAlwaysUseTidy', + 'wgValidateAllHtml', + 'wgDefaultSkin', + 'wgAllowUserSkin', + 'wgDefaultUserOptions', + 'wgAllowRealName', + 'wgValidSkinNames', + 'wgAllowUserJs', + 'wgAllowUserCss', + 'wgUseSiteJs', + 'wgUseSiteCss', + 'wgAllowPageInfo', + 'wgEnableHtmlDiff', + 'wgUseRCPatrol', + 'wgUseNPPatrol', + 'wgCategoryPrefixedDefaultSortkey', + 'wgLocaltimezone', + 'wgLocalTZoffset', + 'wgAllowSpecialInclusion', + 'wgEnableScaryTranscluding', + 'wgUseTrackbacks', + 'wgAllowDisplayTitle', + 'wgRestrictDisplayTitle', + 'wgContentNamespaces', + 'wgEnableAPI', + 'wgEnableWriteAPI', + 'wgExpensiveParserFunctionLimit', + 'wgMaximumMovedPages', + 'wgFixDoubleRedirects', + 'wgUseAutomaticEditSummaries', +); diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index b4f7445769..c7a250c305 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -79,6 +79,10 @@ class ApiQuerySiteinfo extends ApiQueryBase { case 'fileextensions': $this->appendFileExtensions( $p ); break; + case 'configvars': + global $wgAPIReadableConfigVars; + $this->appendConfigvars( $p, $params['configvars'] ); + break; default : ApiBase :: dieDebug( __METHOD__, "Unknown prop=$p" ); } @@ -333,9 +337,39 @@ class ApiQuerySiteinfo extends ApiQueryBase { $this->getResult()->setIndexedTagName( $data, 'ext' ); $this->getResult()->addValue( 'query', $property, $data ); } - + + protected function appendConfigvars( $property, $vars ) { + global $wgAPIReadableConfigVars; + if(empty($vars)) + $vars = $wgAPIReadableConfigVars; + $data = array(); + foreach((array)$vars as $var) + { + $value = $GLOBALS[$var]; + $r = array(); + $r['name'] = $var; + $r['type'] = gettype($value); + if(is_object($value)) + $r['class'] = get_class($value); + elseif(is_bool($value)) + $r['value'] = ($value ? 'true' : 'false'); + elseif(!is_null($value)) + { + $r['value'] = $value; + if(is_array($value)) + { + $this->getResult()->setIndexedTagName($r['value'], 'elem'); + $this->getResult()->setIndexedTagName_recursive($r['value'], 'elem'); + } + } + $data[] = $r; + } + $this->getResult()->setIndexedTagName($data, 'config'); + $this->getResult()->addValue('query', $property, $data); + } public function getAllowedParams() { + global $wgAPIReadableConfigVars; return array( 'prop' => array( ApiBase :: PARAM_DFLT => 'general', @@ -352,6 +386,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { 'usergroups', 'extensions', 'fileextensions', + 'configvars', ) ), 'filteriw' => array( @@ -361,6 +396,10 @@ class ApiQuerySiteinfo extends ApiQueryBase { ) ), 'showalldb' => false, + 'configvars' => array( + ApiBase :: PARAM_ISMULTI => true, + ApiBase :: PARAM_TYPE => $wgAPIReadableConfigVars, + ), ); } @@ -379,9 +418,11 @@ class ApiQuerySiteinfo extends ApiQueryBase { ' "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', + ' "configvars" - Returns the value of certain configuration variables', ), 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map', 'showalldb' => 'List all database servers, not just the one lagging the most', + 'configvars' => 'Configuration variables to get. If empty, all configuration variables will be listed.', ); } @@ -394,7 +435,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { 'api.php?action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics', 'api.php?action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local', 'api.php?action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb', - ); + ); } public function getVersion() {