From 8b9bcc1768c00ccbc3a6a6ff81b58659df925ce0 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 5 Oct 2024 15:20:04 +0100 Subject: [PATCH] Search: Fixed last commented filter when using table prefixes --- app/Search/SearchRunner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Search/SearchRunner.php b/app/Search/SearchRunner.php index 265b9eecc..9716f8053 100644 --- a/app/Search/SearchRunner.php +++ b/app/Search/SearchRunner.php @@ -463,7 +463,7 @@ class SearchRunner $morphClass = str_replace('\\', '\\\\', $model->getMorphClass()); $commentQuery = DB::raw('(SELECT c1.entity_id, c1.entity_type, c1.created_at as last_commented FROM ' . $commentsTable . ' c1 LEFT JOIN ' . $commentsTable . ' c2 ON (c1.entity_id = c2.entity_id AND c1.entity_type = c2.entity_type AND c1.created_at < c2.created_at) WHERE c1.entity_type = \'' . $morphClass . '\' AND c2.created_at IS NULL) as comments'); - $query->join($commentQuery, $model->getTable() . '.id', '=', 'comments.entity_id') + $query->join($commentQuery, $model->getTable() . '.id', '=', DB::raw('comments.entity_id')) ->orderBy('last_commented', $negated ? 'asc' : 'desc'); } }