-
Notifications
You must be signed in to change notification settings - Fork 154
Statistics Page Database Query Issues #2605
Copy link
Copy link
Closed
Labels
fix mergedA PR has been created and merged to help or address this issueA PR has been created and merged to help or address this issue
Description
Description
The statistics_page.php file contains SQL queries with incorrect ORDER BY clause handling that causes database access failures in PostgreSQL environments. Multiple errors occur due to improper handling of quoted column aliases and case sensitivity issues.
Environment
- FileSender 3.6
- Chrome 145.0.7632.160 arm64
- macOS 26.3.1 (25D2128)
Error Examples
-
Undefined column errors:
ERROR: column "date" does not exist LINE 1: ...authid WHERE u.auth_secret IS NOT NULL ORDER BY Date DESC ... ^ -
Column alias misidentification:
ERROR: column "transfers" does not exist LINE 1: ...user_email ORDER BY Transfers ASC LIMIT 10 OFFSET 0
Root Cause
The SQL queries in www/lib/tables/statistics_page.php use unquoted column aliases in ORDER BY clauses, causing PostgreSQL to interpret them with different case sensitivity than the defined quoted aliases.
Solution
Modified the ORDER BY clauses throughout the file to consistently quote column aliases:
- Line 77:
ORDER BY '.$sort.' '.$sortdirection→ORDER BY "'.$sort.'" '.$sortdirection - Line 120:
ORDER BY '.$sort.' '.$sortdirection→ORDER BY "'.$sort.'" '.$sortdirection - Line 160:
ORDER BY '.$sort.' '.$sortdirection→ORDER BY "'.$sort.'" '.$sortdirection - Line 199:
ORDER BY "Date" '.$sortdirection→ORDER BY "'.$sort.'" '.$sortdirection
Testing
The fix has been tested with PostgreSQL and should resolve all reported database errors in the statistics page functionality.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
fix mergedA PR has been created and merged to help or address this issueA PR has been created and merged to help or address this issue