Skip to content

fix: compatibility with blomstra/search - #20

Merged
imorland merged 1 commit into
1.xfrom
im/blomstra-search-compat
Apr 20, 2026
Merged

fix: compatibility with blomstra/search#20
imorland merged 1 commit into
1.xfrom
im/blomstra-search-compat

Conversation

@imorland

@imorland imorland commented Apr 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • Pass tags via filter[tag] instead of embedding tag: gambits inside filter[q].
  • Omit filter[q] entirely when there is no free-text search term.

Why

blomstra/search overrides Flarum\Api\Client in the container (Provider.php) and hijacks any /discussions call where filter[q] is set, rerouting it to /blomstra/search/discussions. That handler passes q straight to Elasticsearch as free text — it does not parse tag: gambits — so RSS feeds that relied on filter[q]=tag:foo returned empty results.

By moving tags to the native filter[tag] param (handled by TagFilterGambit as a FilterInterface) and only setting filter[q] when there is an actual search term, the request stays on core's /discussions path on vanilla Flarum, with flarum/tags, and with blomstra/search installed.

Closes #17 — supersedes that PR with a cleaner implementation (no debug code, no absolute-URL workaround, correct comma-separated tag list).

Test plan

  • /rss returns discussions on vanilla Flarum
  • /rss/t/<slug> returns tag-scoped discussions with flarum/tags only
  • /rss and /rss/t/<slug> both work with blomstra/search enabled
  • Multi-tag feeds (comma-separated) still filter correctly

Pass tags via filter[tag] instead of embedding tag: gambits in filter[q].
When there is no free-text search term, filter[q] is omitted entirely,
which avoids blomstra/search's ApiClient override rerouting the request
to its Elasticsearch endpoint (which does not parse tag: gambits).

Closes #17
@imorland
imorland force-pushed the im/blomstra-search-compat branch from 5bc4459 to 0bb5278 Compare April 20, 2026 17:35
@imorland
imorland merged commit 9784f20 into 1.x Apr 20, 2026
13 checks passed
@imorland
imorland deleted the im/blomstra-search-compat branch April 20, 2026 18:55
imorland added a commit that referenced this pull request Apr 20, 2026
* test: add PHPUnit integration suite via flarum/testing

Covers all feed routes: /rss, /atom, /rss/discussions, /rss/d/{id},
/rss/u/{username}/posts, /rss/t/{slug}, /rss/t/{slug}/discussions
(and their atom equivalents). 25 tests, 66 assertions.

Also includes a regression guard for the blomstra/search compatibility
fix in #20: asserts tag filtering is passed via filter[tag] and that
filter[q] is omitted when no free-text search term is supplied.

Fixes a latent bug in DiscussionsActivityFeedController where a null
return from getRelationship() (when a post is hidden, soft-deleted, or
not in the API document's 'included' section) caused a fatal
property-access error while rendering the feed. The fallback
stdClass now sets both contentHtml and number.

Wires up composer test scripts and enables the Flarum reusable CI
workflow's backend testing job.

* chore: gitignore phpunit result cache

* Apply fixes from StyleCI

* test: add .gitkeep so tests/unit exists in CI checkout

PHPUnit exits 2 on newer PHP versions when the configured test
directory does not exist; the empty unit/ directory was not tracked
by git.

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
This was referenced Apr 20, 2026
imorland added a commit that referenced this pull request Apr 20, 2026
* docs: refresh README

- Fix dead LICENSE link (master -> 1.x) and badge label typo.
- Add backend CI status badge.
- Document the /u/{username}/posts feed added in 6391780.
- Reformat the feed list as a table and include 'requires flarum/tags'
  annotations for the two tag-scoped routes.
- Add a settings table covering all five admin options.
- Note the blomstra/search compatibility behaviour with a link to #20.
- Drop the obsolete Firefox autodiscovery aside.

* docs: drop Extiverse link (service is dead)
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.

1 participant