diff --git a/extension.json b/extension.json index a9d4a4abb..d445b6709 100644 --- a/extension.json +++ b/extension.json @@ -454,6 +454,10 @@ "value": true, "description": "Allow DiscussionTools to use the parser cache." }, + "DiscussionToolsEnableTopicSubscriptionBackend": { + "value": true, + "description": "Enable the topic subscription backend. This controls whether the feature can be tried out using the query parameter, and whether the Echo events will be created. Do not enable this unless the database tables exist. Do enable it before making the 'topicsubscription' feature available." + }, "DiscussionToolsTalkPageParserCacheExpiry": { "value": 0, "description": "Override $wgParserCacheExpireTime for discussion pages, regardless of DiscussionTools enablement." diff --git a/includes/ApiDiscussionToolsSubscribe.php b/includes/ApiDiscussionToolsSubscribe.php index 3bec69dcc..e4e831735 100644 --- a/includes/ApiDiscussionToolsSubscribe.php +++ b/includes/ApiDiscussionToolsSubscribe.php @@ -4,7 +4,6 @@ namespace MediaWiki\Extension\DiscussionTools; use ApiBase; use ApiMain; -use MediaWiki\Extension\DiscussionTools\Hooks\HookUtils; use MediaWiki\MediaWikiServices; use Title; use User; @@ -33,7 +32,7 @@ class ApiDiscussionToolsSubscribe extends ApiBase { // This should probably use dependency injection, but the check is only temporary $services = MediaWikiServices::getInstance(); $dtConfig = $services->getConfigFactory()->makeConfig( 'discussiontools' ); - if ( $dtConfig->get( 'DiscussionTools_' . HookUtils::TOPICSUBSCRIPTION ) === 'unavailable' ) { + if ( !$dtConfig->get( 'DiscussionToolsEnableTopicSubscriptionBackend' ) ) { $this->dieWithError( [ 'apierror-moduledisabled', $this->getModuleName() ] ); } diff --git a/includes/Hooks/EchoHooks.php b/includes/Hooks/EchoHooks.php index 4ec6cc999..2009d2277 100644 --- a/includes/Hooks/EchoHooks.php +++ b/includes/Hooks/EchoHooks.php @@ -29,7 +29,7 @@ class EchoHooks { ) { $services = MediaWikiServices::getInstance(); $dtConfig = $services->getConfigFactory()->makeConfig( 'discussiontools' ); - if ( $dtConfig->get( 'DiscussionTools_' . HookUtils::TOPICSUBSCRIPTION ) === 'unavailable' ) { + if ( !$dtConfig->get( 'DiscussionToolsEnableTopicSubscriptionBackend' ) ) { // Topic subscriptions not available on wiki. return; } diff --git a/includes/Hooks/HookUtils.php b/includes/Hooks/HookUtils.php index 4e4dbcfc7..3b26f5cb8 100644 --- a/includes/Hooks/HookUtils.php +++ b/includes/Hooks/HookUtils.php @@ -235,7 +235,11 @@ class HookUtils { // Extra hack for parses from API, where this parameter isn't passed to derivative requests RequestContext::getMain()->getRequest()->getRawVal( 'dtenable' ); - if ( $feature === self::TOPICSUBSCRIPTION ) { + $dtConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'discussiontools' ); + if ( + $feature === self::TOPICSUBSCRIPTION && + !$dtConfig->get( 'DiscussionToolsEnableTopicSubscriptionBackend' ) + ) { // Can't be enabled via query, because the tables may not exist yet (T280082) $queryEnable = false; } diff --git a/includes/Notifications/EventDispatcher.php b/includes/Notifications/EventDispatcher.php index 610b0fce3..3c9139563 100644 --- a/includes/Notifications/EventDispatcher.php +++ b/includes/Notifications/EventDispatcher.php @@ -61,7 +61,7 @@ class EventDispatcher { $services = MediaWikiServices::getInstance(); $dtConfig = $services->getConfigFactory()->makeConfig( 'discussiontools' ); - if ( $dtConfig->get( 'DiscussionTools_' . HookUtils::TOPICSUBSCRIPTION ) === 'unavailable' ) { + if ( !$dtConfig->get( 'DiscussionToolsEnableTopicSubscriptionBackend' ) ) { // Feature disabled for all users return; }