From 71c8d8d365f62ecacceaee9f5fe70c344a18dd4b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 8 Dec 2020 16:59:58 +0300 Subject: [PATCH] queryFeedHeadlines: - there should be no need for DISTINCT query when checking for first id - fix DISTINCT query part being undefined when browsing by tags - add query debugging for tags --- classes/feeds.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/classes/feeds.php b/classes/feeds.php index c66fe0207..b8c5227aa 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -1785,7 +1785,7 @@ class Feeds extends Handler_Protected { if (!$search && !$skip_first_id_check) { // if previous topmost article id changed that means our current pagination is no longer valid - $query = "SELECT $distinct_qpart + $query = "SELECT ttrss_entries.id, date_entered, $yyiw_qpart, @@ -1871,6 +1871,13 @@ class Feeds extends Handler_Protected { } else { // browsing by tag + if (DB_TYPE == "pgsql") { + $distinct_columns = str_replace("desc", "", strtolower($order_by)); + $distinct_qpart = "DISTINCT ON (id, $distinct_columns)"; + } else { + $distinct_qpart = "DISTINCT"; //fallback + } + $query = "SELECT $distinct_qpart date_entered, guid, @@ -1912,6 +1919,10 @@ class Feeds extends Handler_Protected { //if ($_REQUEST["debug"]) print $query; + if ($_REQUEST["debug"]) { + print "\n*** TAGS QUERY ***\n$query\n"; + } + $res = $pdo->query($query); }