Config option to enable topic subscriptions backend and dtenable=1 URL parameter

…without making the topic subscriptions feature available in user preferences.

Follow-up to these commits, which added these checks in ad-hoc ways:
* 9420f22e9d
* f3422f40a6
* 23a490deca
* a555db7892

Bug: T284491
Change-Id: If2e3fb1e06d1cc489fbca14796ed77c83bb52991
This commit is contained in:
Bartosz Dziewoński 2021-06-07 22:45:54 +02:00
parent d18315f850
commit 067f0c36de
5 changed files with 12 additions and 5 deletions

View file

@ -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."

View file

@ -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() ] );
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}