Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The admin-only branch of
get_subscriptions.php(used whenall-user-subscription=1) built its base SQL query with no WHEREclause. Any filter (member, category, payment, or state) then got
appended with AND, producing invalid SQL like:
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 = 1so filters can append uniformly, matching the patternalready 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, hittingget_subscriptions.phpwithall-user-subscription=1and a filter(
state=0) as the admin user, confirming the fatal error, applyingthe fix, and re-running the same request to confirm it now returns
valid filtered JSON.
Fixes #1157