From 18689b370a12115f5228e3251efc08488d626827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 7 Dec 2022 22:42:41 +0100 Subject: [PATCH] Add optional tracking category for comments in the lede section (before first heading) The tracking category is disabled by default and has to be enabled by overriding the localisation message 'MediaWiki:Discussiontools-comments-before-first-heading-category'. Bug: T324139 Change-Id: I6e4818e9421f76aec814444b2da9f5d8585c75fd --- extension.json | 3 +++ i18n/en.json | 2 ++ i18n/qqq.json | 2 ++ includes/CommentFormatter.php | 2 ++ 4 files changed, 9 insertions(+) diff --git a/extension.json b/extension.json index 2cecb326e..bcbd894b6 100644 --- a/extension.json +++ b/extension.json @@ -399,6 +399,9 @@ ] } }, + "TrackingCategories": [ + "discussiontools-comments-before-first-heading-category" + ], "Hooks": { "BeforeCreateEchoEvent": "\\MediaWiki\\Extension\\DiscussionTools\\Hooks\\EchoHooks::onBeforeCreateEchoEvent", "EchoGetBundleRules": "\\MediaWiki\\Extension\\DiscussionTools\\Hooks\\EchoHooks::onEchoGetBundleRules", diff --git a/i18n/en.json b/i18n/en.json index 3838b90c2..e22d6cd4c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -179,6 +179,8 @@ "echo-pref-tooltip-dt-subscription": "Notify me when someone posts a new comment in a topic I am subscribed to.", "echo-pref-tooltip-dt-subscription-archiving": "Notify me when a topic I am subscribed to is archived or removed from a page, or if notifications about new comments posted in that topic can't be sent for other reasons.", "minerva-talk-full-page": "Read as wiki page", + "discussiontools-comments-before-first-heading-category": "-", + "discussiontools-comments-before-first-heading-category-desc": "The discussion page contains comments in the lede section (before first heading). This may cause the lede or the comments to be displayed incorrectly, especially in the mobile version and in mobile apps.", "tag-discussiontools": "-", "tag-discussiontools-added-comment": "-", "tag-discussiontools-added-comment-description": "A talk page comment was added in this edit", diff --git a/i18n/qqq.json b/i18n/qqq.json index e0092df6b..3bc8e79a0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -193,6 +193,8 @@ "echo-pref-tooltip-dt-subscription": "{{doc-echo-pref-tooltip|title=Echo-category-title-dt-subscription}}", "echo-pref-tooltip-dt-subscription-archiving": "{{doc-echo-pref-tooltip|title=Echo-category-title-dt-subscription-archiving}}", "minerva-talk-full-page": "Used as label for link to show the full talk page.", + "discussiontools-comments-before-first-heading-category": "{{ignored}}\n{{tracking category name}}", + "discussiontools-comments-before-first-heading-category-desc": "Tracking category description.", "tag-discussiontools": "{{ignored}}Short description of the discussiontools tag.\n\nShown on lists of changes (history, recentchanges, etc.) for each edit made using DiscussionTools.\n\nSee also:\n* {{msg-mw|Tag-discussiontools-description}}\n{{Related|tag-discussiontools}}", "tag-discussiontools-added-comment": "{{ignored}}\nShort description of the discussiontools-added-comment tag.\n\nShown on lists of changes (history, recentchanges, etc.) for each edit that adds a talk page comment (or comments), even if it wasn't made using DiscussionTools.\n\nSee also:\n* {{msg-mw|Tag-discussiontools-added-comment-description}}\n{{Related|tag-discussiontools}}", "tag-discussiontools-added-comment-description": "Long description of the discussiontools-added-comment tag ({{msg-mw|Tag-discussiontools-added-comment}}).\n\nShown on [[Special:Tags]].\n\nSee also:\n* {{msg-mw|Tag-discussiontools-added-comment}}\n{{Related|tag-discussiontools}}", diff --git a/includes/CommentFormatter.php b/includes/CommentFormatter.php index 705b79ef6..00ae66a7e 100644 --- a/includes/CommentFormatter.php +++ b/includes/CommentFormatter.php @@ -314,6 +314,8 @@ class CommentFormatter { $threadItems[0]->isPlaceholderHeading() ) { $pout->setExtensionData( 'DiscussionTools-hasCommentsInLedeContent', true ); + MediaWikiServices::getInstance()->getTrackingCategories() + ->addTrackingCategory( $pout, 'discussiontools-comments-before-first-heading-category', $title ); } if ( count( $threadItems ) === 0 ) {