From e52ac37a9efcd458ae4ae8392ce8b818e125c461 Mon Sep 17 00:00:00 2001 From: Shawn Bulen Date: Thu, 24 Oct 2024 21:30:04 -0700 Subject: [PATCH 1/2] Use real topic id Signed by Shawn Bulen, bulens@pacbell.net --- Sources/Search.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/Search.php b/Sources/Search.php index 028bf80c15..9fce02eea4 100644 --- a/Sources/Search.php +++ b/Sources/Search.php @@ -1851,7 +1851,8 @@ function PlushSearch2() $request = $smcFunc['db_search_query']('', ' SELECT ' . (empty($search_params['topic']) ? 'lsr.id_topic' : $search_params['topic'] . ' AS id_topic') . ', lsr.id_msg, lsr.relevance, lsr.num_matches FROM {db_prefix}log_search_results AS lsr' . ($search_params['sort'] == 'num_replies' || !empty($approve_query) ? ' - INNER JOIN {db_prefix}topics AS t ON (t.id_topic = lsr.id_topic)' : '') . ' + INNER JOIN {db_prefix}messages AS m ON (m.id_msg = lsr.id_msg) + INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)' : '') . ' WHERE lsr.id_search = {int:id_search}' . $approve_query . ' ORDER BY {raw:sort} {raw:sort_dir} LIMIT {int:start}, {int:max}', From 998d43a6f79c2a9e2dfd1f03e28296f62814142d Mon Sep 17 00:00:00 2001 From: Shawn Bulen Date: Fri, 25 Oct 2024 08:55:06 -0700 Subject: [PATCH 2/2] Use real topic id Signed by Shawn Bulen, bulens@pacbell.net --- Sources/Search.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/Search.php b/Sources/Search.php index 9fce02eea4..c200c1834f 100644 --- a/Sources/Search.php +++ b/Sources/Search.php @@ -1304,6 +1304,9 @@ function PlushSearch2() ), ); + // Most searches are at the topic-level, and do not list message-level results. + // Message-level results are displayed when doing searches within topics + // and when showing complete results ("Show results as messages" option). if (empty($search_params['topic']) && empty($search_params['show_complete'])) { $main_query['select']['id_topic'] = 't.id_topic'; @@ -1317,6 +1320,7 @@ function PlushSearch2() else { // This is outrageous! + // Note we're stuffing id_msg in an id_topic column to get past the db contraint. $main_query['select']['id_topic'] = 'm.id_msg AS id_topic'; $main_query['select']['id_msg'] = 'm.id_msg'; $main_query['select']['num_matches'] = '1 AS num_matches';