From f96eba7e6e088da192e3191ffa9e9bc0167b0263 Mon Sep 17 00:00:00 2001 From: DLynch Date: Thu, 22 Aug 2024 15:32:32 +0000 Subject: [PATCH] Revert "Invert logic on empty talk page" This reverts commit 7e5f9b59a2303e95d120b8c9a3ca3ec7c83f3a45. Reason for revert: Causes empty state to always appear on wikis using Talkpageheader Bug: T373100 Change-Id: I23a3f937201d93c7c7645a09c4fccfcf1c14008a --- includes/CommentFormatter.php | 6 +++--- includes/Hooks/ParserHooks.php | 2 +- tests/phpunit/CommentFormatterTest.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/CommentFormatter.php b/includes/CommentFormatter.php index aada1fa7f..feac80451 100644 --- a/includes/CommentFormatter.php +++ b/includes/CommentFormatter.php @@ -406,8 +406,8 @@ class CommentFormatter { ->addTrackingCategory( $pout, 'discussiontools-comments-before-first-heading-category', $title ); } - if ( count( $threadItems ) > 0 ) { - $pout->setExtensionData( 'DiscussionTools-isNotEmptyTalkPage', true ); + if ( count( $threadItems ) === 0 ) { + $pout->setExtensionData( 'DiscussionTools-isEmptyTalkPage', true ); } $threadsJSON = array_map( static function ( ContentThreadItem $item ) { @@ -914,7 +914,7 @@ class CommentFormatter { * Check if the talk page had no comments or headings. */ public static function isEmptyTalkPage( ParserOutput $pout ): bool { - return $pout->getExtensionData( 'DiscussionTools-isNotEmptyTalkPage' ) !== true; + return $pout->getExtensionData( 'DiscussionTools-isEmptyTalkPage' ) === true; } /** diff --git a/includes/Hooks/ParserHooks.php b/includes/Hooks/ParserHooks.php index b119420a9..64c4c6bdb 100644 --- a/includes/Hooks/ParserHooks.php +++ b/includes/Hooks/ParserHooks.php @@ -72,7 +72,7 @@ class ParserHooks implements if ( $isPreview ) { $html = CommentFormatter::removeInteractiveTools( $html ); // Suppress the empty state - $pout->setExtensionData( 'DiscussionTools-isNotEmptyTalkPage', true ); + $pout->setExtensionData( 'DiscussionTools-isEmptyTalkPage', null ); } $pout->addModuleStyles( [ 'ext.discussionTools.init.styles' ] ); diff --git a/tests/phpunit/CommentFormatterTest.php b/tests/phpunit/CommentFormatterTest.php index 446d9fe59..1bedd7c21 100644 --- a/tests/phpunit/CommentFormatterTest.php +++ b/tests/phpunit/CommentFormatterTest.php @@ -95,8 +95,8 @@ class CommentFormatterTest extends IntegrationTestCase { "hasLedeContent\n" : '' ) . ( $pout->getExtensionData( 'DiscussionTools-hasCommentsInLedeContent' ) ? "hasCommentsInLedeContent\n" : '' ) . - ( $pout->getExtensionData( 'DiscussionTools-isNotEmptyTalkPage' ) ? - '' : "isEmptyTalkPage\n" ) . + ( $pout->getExtensionData( 'DiscussionTools-isEmptyTalkPage' ) ? + "isEmptyTalkPage\n" : '' ) . FormatJson::encode( $pout->getJsConfigVars(), "\t", FormatJson::ALL_OK ) . "\n";