From fcdd6b0ed566c5a9bd30510fc744a371afd24ac6 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 28 Jul 2022 14:30:54 +0100 Subject: [PATCH] Don't show empty page state on redirect pages Add the redirect check to shouldShowNewSectionTab. Try to run cheaper checks before more expensive ones. Depends-On: I5755863243d8ad336ad20626f439d70eb3b31f32 Bug: T312599 Change-Id: I6848e529a2537d4058613db0c3b900bc9f4f59f8 --- includes/Hooks/HookUtils.php | 4 ++-- includes/Hooks/PageHooks.php | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/includes/Hooks/HookUtils.php b/includes/Hooks/HookUtils.php index a65ec27fd..bf694521f 100644 --- a/includes/Hooks/HookUtils.php +++ b/includes/Hooks/HookUtils.php @@ -316,11 +316,11 @@ class HookUtils { // Match the logic in MediaWiki core (as defined in SkinTemplate::buildContentNavigationUrlsInternal): // https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/add6d0a0e38167a710fb47fac97ff3004451494c/includes/skins/SkinTemplate.php#1317 // * __NONEWSECTIONLINK__ is not present (OutputPage::forceHideNewSectionLink) and... - // - This is the current revision in a talk namespace (Title::isTalkPage) or... + // - This is the current revision of a non-redirect in a talk namespace or... // - __NEWSECTIONLINK__ is present (OutputPage::showNewSectionLink) return ( !static::hasPagePropCached( $title, 'nonewsectionlink' ) && - ( ( $title->isTalkPage() && $output->isRevisionCurrent() ) || + ( ( $title->isTalkPage() && !$title->isRedirect() && $output->isRevisionCurrent() ) || static::hasPagePropCached( $title, 'newsectionlink' ) ) ); } diff --git a/includes/Hooks/PageHooks.php b/includes/Hooks/PageHooks.php index f90598d4e..5b0719ea7 100644 --- a/includes/Hooks/PageHooks.php +++ b/includes/Hooks/PageHooks.php @@ -204,14 +204,15 @@ class PageHooks implements $text, $lang ); } - if ( HookUtils::shouldDisplayEmptyState( $output->getContext() ) ) { - if ( CommentFormatter::isEmptyTalkPage( $text ) ) { - $output->enableOOUI(); - $text = CommentFormatter::appendToEmptyTalkPage( - $text, $this->getEmptyStateHtml( $output->getContext() ) - ); - $output->addBodyClasses( 'ext-discussiontools-emptystate-shown' ); - } + if ( + CommentFormatter::isEmptyTalkPage( $text ) && + HookUtils::shouldDisplayEmptyState( $output->getContext() ) + ) { + $output->enableOOUI(); + $text = CommentFormatter::appendToEmptyTalkPage( + $text, $this->getEmptyStateHtml( $output->getContext() ) + ); + $output->addBodyClasses( 'ext-discussiontools-emptystate-shown' ); } if ( HookUtils::isFeatureEnabledForOutput( $output, HookUtils::VISUALENHANCEMENTS ) ) { $output->enableOOUI();