From 91a041c2914f0efb81039f1c9447b182ec8793e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 14 Feb 2023 14:43:39 +0100 Subject: [PATCH] persistRevisionThreadItems: Avoid listing non-discussion pages Bug: T329627 Change-Id: I52a9f5dfa583d8dc2e0a315844a2a40e538f6a8c (cherry picked from commit 445b8caca07f47acddaab42dbf8376ef18239865) --- includes/Hooks/HookUtils.php | 2 ++ maintenance/persistRevisionThreadItems.php | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/includes/Hooks/HookUtils.php b/includes/Hooks/HookUtils.php index 1ada63145..3a0615c5c 100644 --- a/includes/Hooks/HookUtils.php +++ b/includes/Hooks/HookUtils.php @@ -327,6 +327,8 @@ class HookUtils { /** * Check if the tools are available for a given title * + * Keep in sync with SQL conditions in persistRevisionThreadItems.php. + * * @param Title $title * @param string|null $feature Feature to check for (one of static::FEATURES) * Null will check for any DT feature. diff --git a/maintenance/persistRevisionThreadItems.php b/maintenance/persistRevisionThreadItems.php index d9b718d14..a59a63da1 100644 --- a/maintenance/persistRevisionThreadItems.php +++ b/maintenance/persistRevisionThreadItems.php @@ -75,6 +75,21 @@ class PersistRevisionThreadItems extends Maintenance { return; } + // Add conditions from HookUtils::isAvailableForTitle(). + // Keep this in sync with that method. + $nsInfo = $services->getNamespaceInfo(); + $qb->leftJoin( 'page_props', null, [ + 'pp_propname' => 'newsectionlink', + 'pp_page = page_id', + ] ); + $qb->where( $this->dbr->makeList( [ + 'page_namespace' => array_values( array_filter( + $nsInfo->getValidNamespaces(), + [ $nsInfo, 'wantSignatures' ] + ) ), + 'pp_propname IS NOT NULL', + ], IDatabase::LIST_OR ) ); + if ( $this->getOption( 'current' ) ) { $qb->where( 'rev_id = page_latest' ); $index = [ 'page_id' ];