From 12e8d1a17dfb47992639c7f7490165722b73aaa1 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 9 Mar 2023 16:10:38 +0000 Subject: [PATCH] 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 --- extension.json | 4 ++++ includes/Hooks/HookUtils.php | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/extension.json b/extension.json index dcf95aca9..6737db2ff 100644 --- a/extension.json +++ b/extension.json @@ -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." diff --git a/includes/Hooks/HookUtils.php b/includes/Hooks/HookUtils.php index 6a40331b0..25b9ac238 100644 --- a/includes/Hooks/HookUtils.php +++ b/includes/Hooks/HookUtils.php @@ -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.