fix: correct PollIsEndedFilter logic and showcase page poll display#114
Merged
imorland merged 5 commits intoFriendsOfFlarum:1.xfrom Apr 15, 2026
Merged
Conversation
The filter had two bugs: - The negate/non-negate branches were swapped, causing filter[isEnded]=1 to return active polls and vice versa. - The orWhere for null end_date was not scoped inside a closure, leaking into the outer query and returning unrelated rows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously the showcase page fetched a single list of all polls (capped at 20) and split them client-side using hasEnded(). When more than 20 polls existed, active polls beyond position 20 were silently dropped. Now the page makes two separate filtered API requests — one for active polls (filter[-isEnded]=1) and one for ended polls (filter[isEnded]=1) — ensuring both sections display all results independently. Adds a "Load More" button for ended polls pagination. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds ListGlobalPollsTest with 6 test cases covering the isEnded filter on the GET /api/fof/polls endpoint: - List all global polls without filter - Filter ended polls (isEnded=1) - Filter active polls (-isEnded=1) - Verify null end_date included in active results - Verify future end_date included in active results - Verify null/future end_date excluded from ended results Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The polls table has a CHECK constraint requiring the settings column to be valid JSON. The test fixture was missing this column, causing all DeletePollGroupTest tests to fail with a constraint violation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
imorland
approved these changes
Apr 15, 2026
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.
Summary
negate/non-negate branches inPollIsEndedFilter, and scope theorWhereNullinside a closure to prevent query leakagefilter[-isEnded]=1for active,filter[isEnded]=1for ended) instead of fetching a single combined list capped at 20 and filtering client-sideGET /api/fof/pollsendpoint covering theisEndedfiltersettingscolumn inDeletePollGroupTestfixture dataProblem
The polls showcase page (
/polls) was not displaying all active polls. Two bugs contributed:PollIsEndedFilterhad its$negatebranches swapped —filter[isEnded]=1returned active polls andfilter[-isEnded]=1returned ended polls. Additionally,orWhereNull('end_date')was not wrapped in a closure, causing it to match unrelated rows.PollsShowcasePagefetched a single unfiltered list of all polls (hardcoded page size of 20), then split them client-side usinghasEnded(). When more than 20 total polls existed, active polls beyond position 20 were silently dropped.Changes
src/Filter/PollIsEndedFilter.phporWhereNullin closurejs/src/forum/components/PollsShowcasePage.tsxPollListStateinstances with server-side filtersjs/src/forum/components/Poll/PollShowcase.tsxactiveState/endedState; add Load More for ended pollstests/integration/api/ListGlobalPollsTest.phpisEndedfiltertests/integration/api/AbstractPollGroupTestCase.phpsettingscolumn to poll fixtureTest plan
/pollspage shows all active polls in "Active" section and all ended polls in "Ended" sectionfilter[-isEnded]=1andfilter[isEnded]=1)