From dacef1a97acac2d39b0244473c8cf616e08a3a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 8 Mar 2024 20:44:54 +0100 Subject: [PATCH] Clean up subscribe links/buttons * Don't generate `` placeholder comments (follow-up to Idb23b0f5e438d35ed74569ff50302c7fad5ba688) * Remove unused method parameter * Remove unnecessary pass-by-reference (only $tocInfo needs it) Change-Id: Ie3348671c486de5bbd9f286772a8d145e3609bd5 --- includes/CommentFormatter.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/includes/CommentFormatter.php b/includes/CommentFormatter.php index e5c34f4ba..69ad09ad5 100644 --- a/includes/CommentFormatter.php +++ b/includes/CommentFormatter.php @@ -151,7 +151,7 @@ class CommentFormatter { ); self::addSubscribeLink( - $headingItem, $doc, $headingElement, $wrapperNode, $latestReplyItem, $bar + $headingItem, $doc, $wrapperNode, $latestReplyItem, $bar ); if ( $latestReplyItem ) { @@ -171,11 +171,11 @@ class CommentFormatter { * of comments, and number of editors in the discussion. */ protected static function addTopicContainer( - Element &$wrapperNode, + Element $wrapperNode, ?ContentCommentItem $latestReplyItem, - Document &$doc, - ContentHeadingItem &$headingItem, - ?Element &$bar, + Document $doc, + ContentHeadingItem $headingItem, + ?Element $bar, array &$tocInfo ) { if ( !DOMCompat::getClassList( $wrapperNode )->contains( 'mw-heading' ) ) { @@ -223,10 +223,9 @@ class CommentFormatter { protected static function addSubscribeLink( ContentHeadingItem $headingItem, Document $doc, - Element $headingElement, - Element &$wrapperNode, + Element $wrapperNode, ?ContentCommentItem $latestReplyItem, - ?Element &$bar + ?Element $bar ) { $headingJSONEscaped = htmlspecialchars( json_encode( static::getJsonForHeadingMarker( $headingItem ) ) @@ -234,9 +233,6 @@ class CommentFormatter { // Replaced in ::postprocessTopicSubscription() as the text depends on user state if ( $headingItem->isSubscribable() ) { - $subscribeLink = $doc->createComment( '__DTSUBSCRIBELINK__' . $headingJSONEscaped ); - $headingElement->insertBefore( $subscribeLink, $headingElement->firstChild ); - $subscribeButton = $doc->createComment( '__DTSUBSCRIBEBUTTONDESKTOP__' . $headingJSONEscaped ); $wrapperNode->insertBefore( $subscribeButton, $wrapperNode->firstChild ); } @@ -459,6 +455,7 @@ class CommentFormatter { ] ); $text = preg_replace( '//', '', $text ); + // No longer used, this can be removed once parser cache expires: $text = preg_replace( '//', '', $text ); $text = preg_replace( '//', '', $text ); @@ -474,6 +471,7 @@ class CommentFormatter { ): string { $doc = DOMCompat::newDocument( true ); + // No longer used, this can be removed once parser cache expires: $text = preg_replace( '//', '', $text ); $matches = [];