API: (bug 17027) Allow all configuration variables in $wgAPIReadableConfigVars to...
authorRoan Kattouw <catrope@users.mediawiki.org>
Fri, 16 Jan 2009 21:03:13 +0000 (21:03 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Fri, 16 Jan 2009 21:03:13 +0000 (21:03 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/api/ApiQuerySiteinfo.php

index 4dc2fc0..c2a79c5 100644 (file)
@@ -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 ===
 
index d849910..ca26e66 100644 (file)
@@ -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',
+);
index b4f7445..c7a250c 100644 (file)
@@ -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() {