Allow visualenhancements on pages with __NEWSECTIONLINK__

Exclude the main namespace unless it allows signatures.

Allow this feature to be disabled via config so
we can do a slow rollout.

Bug: T331635
Change-Id: If46bff5620c5245d5b82653ee96282532fd00c28
This commit is contained in:
Ed Sanders 2023-03-09 16:10:38 +00:00
parent d6ba810891
commit 12e8d1a17d
2 changed files with 16 additions and 2 deletions

View file

@ -534,6 +534,10 @@
"description": "A list of language codes which will receive an icon in their enhanced reply-button treatment",
"merge_strategy": "provide_default"
},
"DiscussionTools_visualenhancements_newsectionlink_enable": {
"value": true,
"description": "Enable visual enhancements on non-talk, non-article namespaces if they have __NEWSECTIONLINK__ magic word. Temporary config for phased rollout (T331635)"
},
"DiscussionToolsEnablePermalinksBackend": {
"value": true,
"description": "Enable the permalinks backend. Do not enable this unless the database tables exist."

View file

@ -352,8 +352,18 @@ class HookUtils {
$services = MediaWikiServices::getInstance();
if ( $feature === static::VISUALENHANCEMENTS ) {
// Visual enhancements are only enabled on talk namespaces (T325417)
return $title->isTalkPage();
$dtConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'discussiontools' );
// Visual enhancements are only enabled on talk namespaces (T325417) ...
return $title->isTalkPage() || (
$dtConfig->get( 'DiscussionTools_visualenhancements_newsectionlink_enable' ) &&
// ... or __NEWSECTIONLINK__ pages (T331635)
static::hasPagePropCached( $title, 'newsectionlink' ) &&
// excluding the main namespace, unless it has been configured for signatures
(
$title->getNamespace() !== NS_MAIN ||
$services->getNamespaceInfo()->wantSignatures( $title->getNamespace() )
)
);
}
// Check that the page supports discussions.