From bf161db7680d25b9e137ad30225a90547855de14 Mon Sep 17 00:00:00 2001 From: Kosta Harlan Date: Fri, 3 Jun 2022 12:46:16 +0200 Subject: [PATCH] TagHooks: Make static method for obtaining DiscussionTools tags Bug: T309839 Change-Id: I30697ca56d4aa346151c4d31850f545d32399305 --- includes/Hooks/TagHooks.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/includes/Hooks/TagHooks.php b/includes/Hooks/TagHooks.php index ccc2e8313..aabdd98fa 100644 --- a/includes/Hooks/TagHooks.php +++ b/includes/Hooks/TagHooks.php @@ -67,15 +67,23 @@ class TagHooks implements if ( !defined( 'MW_API' ) ) { return true; } - $request = RequestContext::getMain()->getRequest(); - $tags = explode( ',', $request->getText( 'dttags' ) ); - - $tags = array_values( array_intersect( $tags, static::TAGS ) ); + $tags = self::getDiscussionToolsTagsFromRequest(); if ( $tags ) { $recentChange->addTags( $tags ); } return true; } + + /** + * Get DT tags from the dttags param in the request, and validate against known tags. + * + * @return array + */ + public static function getDiscussionToolsTagsFromRequest(): array { + $request = RequestContext::getMain()->getRequest(); + $tags = explode( ',', $request->getText( 'dttags' ) ); + return array_values( array_intersect( $tags, static::TAGS ) ); + } }