Commit d92dd69a authored by Eli Schwartz's avatar Eli Schwartz Committed by Lukas Fleischer
Browse files

fix broken SQL query that always failed

Due to missing whitespace at the end of strings during joining, we ended
up with the query fragment


which should be


So the check for pinned comments > 5 likely always failed.

In php 7, a completely broken query that raises exceptions in the
database engine was silently ignored... in php 8, it raises

Uncaught PDOException: SQLSTATE[HY000]: General error: 1 near "PinnedTS": syntax error in <file>

and aborts the page building. End result: users with permission to pin
comments cannot see any comments, or indeed page content below the first
comment header
Signed-off-by: Eli Schwartz's avatarEli Schwartz <>
Signed-off-by: Lukas Fleischer's avatarLukas Fleischer <>
parent d5e30855
...@@ -21,7 +21,7 @@ function pkgbase_comments_count($base_id, $include_deleted, $only_pinned=false) ...@@ -21,7 +21,7 @@ function pkgbase_comments_count($base_id, $include_deleted, $only_pinned=false)
$q = "SELECT COUNT(*) FROM PackageComments "; $q = "SELECT COUNT(*) FROM PackageComments ";
$q.= "WHERE PackageBaseID = " . $base_id . " "; $q.= "WHERE PackageBaseID = " . $base_id . " ";
if (!$include_deleted) { if (!$include_deleted) {
$q.= "AND DelTS IS NULL"; $q.= "AND DelTS IS NULL ";
} }
if ($only_pinned) { if ($only_pinned) {
$q.= "AND NOT PinnedTS = 0"; $q.= "AND NOT PinnedTS = 0";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment