Skip to content

Fix invalid SQL when filtering all-user subscriptions as admin - #1174

Closed
abdoulk30 wants to merge 1 commit into
ellite:mainfrom
abdoulk30:fix-1157-admin-filter-sql-error
Closed

abdoulk30 wants to merge 1 commit into
ellite:mainfrom
abdoulk30:fix-1157-admin-filter-sql-error

Conversation

@abdoulk30

Copy link
Copy Markdown

What changed

The admin-only branch of get_subscriptions.php (used when
all-user-subscription=1) built its base SQL query with no WHERE
clause. Any filter (member, category, payment, or state) then got
appended with AND, producing invalid SQL like:

SELECT * FROM subscriptions AND inactive = :inactive

which SQLite rejects, causing prepare() to fail and a fatal error
instead of a JSON response. This PR changes the base query to
WHERE 1 = 1 so filters can append uniformly, matching the pattern
already used in the non-admin branch.

Why I picked this

It's a real, reproducible bug with a clear root cause and a small,
contained fix, so it felt like a solid first contribution to make
carefully rather than rushing something bigger.

Testing

Reproduced locally by running Wallos with php -S, hitting
get_subscriptions.php with all-user-subscription=1 and a filter
(state=0) as the admin user, confirming the fatal error, applying
the fix, and re-running the same request to confirm it now returns
valid filtered JSON.

Fixes #1157

The admin branch of get_subscriptions.php built its base query with no
WHERE clause, so appending a filter (member, category, payment, or
state) produced invalid SQL like:
  SELECT * FROM subscriptions AND inactive = :inactive
which failed to prepare and threw a fatal error.

Use WHERE 1 = 1 as the base query so filters can append uniformly.

Fixes ellite#1157
@ellite ellite closed this Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_subscriptions.php: all-user-subscription with any filter builds invalid SQL and fatals

2 participants