From 951791990ab1d12cdcf3e5e0daa7cb27b391d82c Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 22 Sep 2010 08:14:19 +0000 Subject: [PATCH] Allow API modules to be disabled in configuration. To replace WMF live hack (see bug 25238). --- RELEASE-NOTES | 1 + includes/DefaultSettings.php | 7 +++++++ includes/api/ApiMain.php | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6a4c143253..61bebd5b81 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -160,6 +160,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Added new hook GetIP * (bug 16574) Allow administrators to temporarily disable the account creation limit for IP addresses: [[MediaWiki:Ratelimit-excluded-ips]] +* API modules can be disabled in configuration using $wgAPIDisabledActions. === Bug fixes in 1.17 === * (bug 17560) Half-broken deletion moved image files to deletion archive diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 65276e9291..464e5d7394 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4832,6 +4832,13 @@ $wgAPIMetaModules = array(); $wgAPIPropModules = array(); $wgAPIListModules = array(); +/** + * Disabled API actions. To disable an API action, add its name here, for + * example: + * $wgAPIDisabledActions[] = 'parse'; + */ +$wgAPIDisabledActions = array(); + /** * Maximum amount of rows to scan in a DB query in the API * The default value is generally fine diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index d837f454e0..e227a06a8d 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -158,6 +158,11 @@ class ApiMain extends ApiBase { global $wgAPIModules; // extension modules $this->mModules = $wgAPIModules + self::$Modules; + global $wgAPIDisabledActions; + foreach ( $wgAPIDisabledActions as $action ) { + unset( $this->mModules[$action] ); + } + $this->mModuleNames = array_keys( $this->mModules ); $this->mFormats = self::$Formats; $this->mFormatNames = array_keys( $this->mFormats ); -- 2.20.1