r45810 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45809‎ | r45810 | r45811 >
Date:21:03, 16 January 2009
Author:catrope
Status:reverted (Comments)
Tags:
Comment:
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).
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php
@@ -79,6 +79,10 @@
8080 case 'fileextensions':
8181 $this->appendFileExtensions( $p );
8282 break;
 83+ case 'configvars':
 84+ global $wgAPIReadableConfigVars;
 85+ $this->appendConfigvars( $p, $params['configvars'] );
 86+ break;
8387 default :
8488 ApiBase :: dieDebug( __METHOD__, "Unknown prop=$p" );
8589 }
@@ -333,9 +337,39 @@
334338 $this->getResult()->setIndexedTagName( $data, 'ext' );
335339 $this->getResult()->addValue( 'query', $property, $data );
336340 }
 341+
 342+ protected function appendConfigvars( $property, $vars ) {
 343+ global $wgAPIReadableConfigVars;
 344+ if(empty($vars))
 345+ $vars = $wgAPIReadableConfigVars;
 346+ $data = array();
 347+ foreach((array)$vars as $var)
 348+ {
 349+ $value = $GLOBALS[$var];
 350+ $r = array();
 351+ $r['name'] = $var;
 352+ $r['type'] = gettype($value);
 353+ if(is_object($value))
 354+ $r['class'] = get_class($value);
 355+ elseif(is_bool($value))
 356+ $r['value'] = ($value ? 'true' : 'false');
 357+ elseif(!is_null($value))
 358+ {
 359+ $r['value'] = $value;
 360+ if(is_array($value))
 361+ {
 362+ $this->getResult()->setIndexedTagName($r['value'], 'elem');
 363+ $this->getResult()->setIndexedTagName_recursive($r['value'], 'elem');
 364+ }
 365+ }
 366+ $data[] = $r;
 367+ }
 368+ $this->getResult()->setIndexedTagName($data, 'config');
 369+ $this->getResult()->addValue('query', $property, $data);
 370+ }
337371
338 -
339372 public function getAllowedParams() {
 373+ global $wgAPIReadableConfigVars;
340374 return array(
341375 'prop' => array(
342376 ApiBase :: PARAM_DFLT => 'general',
@@ -352,6 +386,7 @@
353387 'usergroups',
354388 'extensions',
355389 'fileextensions',
 390+ 'configvars',
356391 )
357392 ),
358393 'filteriw' => array(
@@ -361,6 +396,10 @@
362397 )
363398 ),
364399 'showalldb' => false,
 400+ 'configvars' => array(
 401+ ApiBase :: PARAM_ISMULTI => true,
 402+ ApiBase :: PARAM_TYPE => $wgAPIReadableConfigVars,
 403+ ),
365404 );
366405 }
367406
@@ -379,9 +418,11 @@
380419 ' "usergroups" - Returns user groups and the associated permissions',
381420 ' "extensions" - Returns extensions installed on the wiki',
382421 ' "fileextensions" - Returns list of file extensions allowed to be uploaded',
 422+ ' "configvars" - Returns the value of certain configuration variables',
383423 ),
384424 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
385425 'showalldb' => 'List all database servers, not just the one lagging the most',
 426+ 'configvars' => 'Configuration variables to get. If empty, all configuration variables will be listed.',
386427 );
387428 }
388429
@@ -394,7 +435,7 @@
395436 'api.php?action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics',
396437 'api.php?action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local',
397438 'api.php?action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb',
398 - );
 439+ );
399440 }
400441
401442 public function getVersion() {
Index: trunk/phase3/includes/DefaultSettings.php
@@ -3647,3 +3647,192 @@
36483648 * and the functionality will be enabled universally.
36493649 */
36503650 $wgEnforceHtmlIds = true;
 3651+
 3652+/**
 3653+ * Allow the variables in this array to be retrieved through the API
 3654+ * (meta=siteinfo&siprop=configvars).
 3655+ * WARNING: DO NOT put sensitive stuff like $wgDBpassword in here
 3656+ */
 3657+
 3658+$wgAPIReadableConfigVars = array(
 3659+ 'wgVersion',
 3660+ 'wgSitename',
 3661+ 'wgMetaNamespace',
 3662+ 'wgMetaNamespaceTalk',
 3663+ 'wgServer',
 3664+ 'wgServerName',
 3665+ 'wgProto',
 3666+ 'wgScriptPath',
 3667+ 'wgUsePathInfo',
 3668+ 'wgScriptExtension',
 3669+ 'wgScript',
 3670+ 'wgRedirectScript',
 3671+ 'wgStylePath',
 3672+ 'wgArticlePath',
 3673+ 'wgVariantArticlePath',
 3674+ 'wgUploadPath',
 3675+ 'wgLogo',
 3676+ 'wgFavicon',
 3677+ 'wgAppleTouchIcon',
 3678+ 'wgMathPath',
 3679+ 'wgUploadBaseUrl',
 3680+ 'wgLegalTitleChars',
 3681+ 'wgUrlProtocols',
 3682+ 'wgVerifyMimeType',
 3683+ 'wgLoadFileinfoExtension',
 3684+ 'wgTrivialMimeDetection',
 3685+ 'wgActionPaths',
 3686+ 'wgUseSharedUploads',
 3687+ 'wgSharedUploadPath',
 3688+ 'wgFetchCommonsDescriptions',
 3689+ 'wgCacheSharedUploads',
 3690+ 'wgAllowCopyUploads',
 3691+ 'wgMaxUploadSize',
 3692+ 'wgUploadNavigationUrl',
 3693+ 'wgRepositoryBaseUrl',
 3694+ 'wgEmergencyContact',
 3695+ 'wgPasswordSender',
 3696+ 'wgNoReplyAddress',
 3697+ 'wgEnableEmail',
 3698+ 'wgEnableUserEmail',
 3699+ 'wgUserEmailUseReplyTo',
 3700+ 'wgPasswordReminderResendTime',
 3701+ 'wgNewPasswordExpiry',
 3702+ 'wgSearchType',
 3703+ 'wgLanguageCode',
 3704+ 'wgGrammarForms',
 3705+ 'wgInterwikiMagic',
 3706+ 'wgHideInterlanguageLinks',
 3707+ 'wgExtraLanguageNames',
 3708+ 'wgUseDynamicDates',
 3709+ 'wgAmericanDates',
 3710+ 'wgTranslateNumerals',
 3711+ 'wgDisableLangConversion',
 3712+ 'wgDisableTitleConversion',
 3713+ 'wgDefaultLanguageVariant',
 3714+ 'wgLoginLanguageSelector',
 3715+ 'wgLocalInterwiki',
 3716+ 'wgRedirectSources',
 3717+ 'wgShowIPinHeader',
 3718+ 'wgMaxSigChars',
 3719+ 'wgMaxArticleSize',
 3720+ 'wgMaxNameChars',
 3721+ 'wgMaxPPNodeCount',
 3722+ 'wgMaxTemplateDepth',
 3723+ 'wgMaxPPExpandDepth',
 3724+ 'wgCleanSignatures',
 3725+ 'wgExtraSubtitle',
 3726+ 'wgSiteSupportPage',
 3727+ 'wgReadOnly',
 3728+ 'wgSpecialVersionShowHooks',
 3729+ 'wgColorErrors',
 3730+ 'wgShowHostnames',
 3731+ 'wgUseCategoryBrowser',
 3732+ 'wgUseCommaCount',
 3733+ 'wgSysopUserBans',
 3734+ 'wgSysopRangeBans',
 3735+ 'wgAutoblockExpiry',
 3736+ 'wgBlockAllowsUTEdit',
 3737+ 'wgSysopEmailBans',
 3738+ 'wgWhitelistRead',
 3739+ 'wgEmailConfirmToEdit',
 3740+ 'wgRestrictionTypes',
 3741+ 'wgRestrictionLevels',
 3742+ 'wgNamespaceProtection',
 3743+ 'wgNonincludableNamespaces',
 3744+ 'wgAutoConfirmAge',
 3745+ 'wgAutoConfirmCount',
 3746+ 'wgAutopromote',
 3747+ 'wgAddGroups',
 3748+ 'wgRemoveGroups',
 3749+ 'wgAvailableRights',
 3750+ 'wgDeleteRevisionsLimit',
 3751+ 'wgActiveUserEditCount',
 3752+ 'wgActiveUserDays',
 3753+ 'wgEnotifFromEditor',
 3754+ 'wgEmailAuthentication',
 3755+ 'wgEnotifWatchlist',
 3756+ 'wgEnotifUserTalk',
 3757+ 'wgEnotifRevealEditorAddress',
 3758+ 'wgEnotifMinorEdits',
 3759+ 'wgEnotifImpersonal',
 3760+ 'wgEnotifMaxRecips',
 3761+ 'wgEnotifUseJobQ',
 3762+ 'wgEnotifUseRealName',
 3763+ 'wgUsersNotifiedOnAllChanges',
 3764+ 'wgRCShowWatchingUsers',
 3765+ 'wgPageShowWatchingUsers',
 3766+ 'wgRCShowChangedSize',
 3767+ 'wgRCChangedSizeThreshold',
 3768+ 'wgShowUpdatedMarker',
 3769+ 'wgCookieExpiration',
 3770+ 'wgCookieDomain',
 3771+ 'wgCookiePath',
 3772+ 'wgCookieSecure',
 3773+ 'wgDisableCookieCheck',
 3774+ 'wgCookiePrefix',
 3775+ 'wgSessionName',
 3776+ 'wgAllowExternalImages',
 3777+ 'wgAllowExternalImagesFrom',
 3778+ 'wgEnableImageWhitelist',
 3779+ 'wgAllowImageMoving',
 3780+ 'wgUseTeX',
 3781+ 'wgDisableCounters',
 3782+ 'wgDisableTextSearch',
 3783+ 'wgDisableSearchContext',
 3784+ 'wgEnableMWSuggest',
 3785+ 'wgEnableUploads',
 3786+ 'wgShowEXIF',
 3787+ 'wgRemoteUploads',
 3788+ 'wgDisableAnonTalk',
 3789+ 'wgFileBlacklist',
 3790+ 'wgMimeTypeBlacklist',
 3791+ 'wgCheckFileExtensions',
 3792+ 'wgStrictFileExtensions',
 3793+ 'wgUploadSizeWarning',
 3794+ 'wgNamespacesToBeSearchedDefault',
 3795+ 'wgNamespacesToBeSearchedProject',
 3796+ 'wgSiteNotice',
 3797+ 'wgRCMaxAge',
 3798+ 'wgUseMetadataEdit',
 3799+ 'wgMetadataWhitelist',
 3800+ 'wgUseCopyrightUpload',
 3801+ 'wgCheckCopyrightUpload',
 3802+ 'wgCapitalLinks',
 3803+ 'wgImportSources',
 3804+ 'wgImportTargetNamespace',
 3805+ 'wgExportAllowHistory',
 3806+ 'wgExportMaxHistory',
 3807+ 'wgExportAllowListContributors',
 3808+ 'wgUseTidy',
 3809+ 'wgAlwaysUseTidy',
 3810+ 'wgValidateAllHtml',
 3811+ 'wgDefaultSkin',
 3812+ 'wgAllowUserSkin',
 3813+ 'wgDefaultUserOptions',
 3814+ 'wgAllowRealName',
 3815+ 'wgValidSkinNames',
 3816+ 'wgAllowUserJs',
 3817+ 'wgAllowUserCss',
 3818+ 'wgUseSiteJs',
 3819+ 'wgUseSiteCss',
 3820+ 'wgAllowPageInfo',
 3821+ 'wgEnableHtmlDiff',
 3822+ 'wgUseRCPatrol',
 3823+ 'wgUseNPPatrol',
 3824+ 'wgCategoryPrefixedDefaultSortkey',
 3825+ 'wgLocaltimezone',
 3826+ 'wgLocalTZoffset',
 3827+ 'wgAllowSpecialInclusion',
 3828+ 'wgEnableScaryTranscluding',
 3829+ 'wgUseTrackbacks',
 3830+ 'wgAllowDisplayTitle',
 3831+ 'wgRestrictDisplayTitle',
 3832+ 'wgContentNamespaces',
 3833+ 'wgEnableAPI',
 3834+ 'wgEnableWriteAPI',
 3835+ 'wgExpensiveParserFunctionLimit',
 3836+ 'wgMaximumMovedPages',
 3837+ 'wgFixDoubleRedirects',
 3838+ 'wgUseAutomaticEditSummaries',
 3839+);
Index: trunk/phase3/RELEASE-NOTES
@@ -48,7 +48,8 @@
4949 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions
5050 and listing all deleted pages possible
5151 * (bug 16844) Added clcategories parameter to prop=categories
52 -* (bug 17025) Add "fileextension" parameter to meta=siteinfo&siprop=
 52+* (bug 17025) Added siprop=fileextension to meta=siteinfo
 53+* (bug 17027) Added siprop=configvars to meta=siteinfo
5354
5455 === Languages updated in 1.15 ===
5556

Follow-up revisions

RevisionCommit summaryAuthorDate
r45811Followup to r45810: remove unused global declarationcatrope21:10, 16 January 2009
r45940Revert r45810 "API: (bug 17027) Allow all configuration variables in $wgAPIRe...brion22:57, 20 January 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   22:57, 20 January 2009

Reverted in r45940 -- this is much too tight coupling between internal implementation details and the external "stable" API.

Status & tagging log