Skip to content

Statistics Page Database Query Issues #2605

@flowdnb

Description

@flowdnb

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

  1. Undefined column errors:

    ERROR: column "date" does not exist
    LINE 1: ...authid WHERE   u.auth_secret IS NOT NULL ORDER BY Date DESC ...
                                                                 ^
    
  2. 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.' '.$sortdirectionORDER BY "'.$sort.'" '.$sortdirection
  • Line 120: ORDER BY '.$sort.' '.$sortdirectionORDER BY "'.$sort.'" '.$sortdirection
  • Line 160: ORDER BY '.$sort.' '.$sortdirectionORDER BY "'.$sort.'" '.$sortdirection
  • Line 199: ORDER BY "Date" '.$sortdirectionORDER BY "'.$sort.'" '.$sortdirection

Testing

The fix has been tested with PostgreSQL and should resolve all reported database errors in the statistics page functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix mergedA PR has been created and merged to help or address this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions