[2.x] Audit's discussion and user filters fail on PostgreSQL

Open
#5,577 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@imorland is already working on this.

Since Nov 23, 2026.

Assessment

This issue has not been assessed yet.

Description

type/bug
Current Behavior

On PostgreSQL, filtering the audit log by discussion returns a 500:

SQLSTATE[42703]: Undefined column: 7 ERROR:  column "$.discussion_id" does not exist

extensions/audit/src/Search/Filter/DiscussionFilter.php compares json_extract(payload, "$.discussion_id"). That is MySQL's JSON syntax: PostgreSQL has no json_extract(), and it reads the double-quoted path as a column name. UserFilter.php builds json_extract(payload, "$.user_id") the same way, so the user filter should fail too (from reading the code, not reproduced).

The discussion and user audit modals open the audit browser with discussion:<id> and user:<username>, so on PostgreSQL those modals should fail to load (also from reading the code).

Steps to Reproduce
  1. Run Flarum on PostgreSQL with flarum/audit enabled.
  2. As an admin, request GET /api/audit?filter[discussion]=1.
  3. The response is a 500 with the error above.
Expected Behavior

The audit entries for that discussion (or user), as on MySQL.

Environment
  • Flarum: 2.x @ b43a84be3
  • Database: PostgreSQL 18
Possible Solution

Build the JSON path per driver, e.g. with the query grammar's JSON support (payload->discussion_id through where/whereIn on a JSON column), or payload::jsonb->>'discussion_id' on PostgreSQL.

Dominant language
PHP
Stars
6.8k
Forks
891
Avg merge
1d 10h
Merged PRs (30d)
209

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flarum/framework

All issues in flarum/framework

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.