Skip to content

fix: OpenSearch on forums whose homepage isn't the discussion list - #5328

Merged
imorland merged 1 commit into
2.xfrom
im/opensearch-default-route
Oct 30, 2026
Merged

imorland merged 1 commit into
2.xfrom
im/opensearch-default-route

Conversation

@imorland

Copy link
Copy Markdown
Member

Fixes: no issue filed. Follow-up to #5321.

Changes proposed in this pull request:

The OpenSearch description always sent searches to /?q={searchTerms}. That only works when the discussion list is the homepage. With a different homepage, such as Tags, the search opened that page and ignored the query. When the discussion list is the homepage, the frontend has nothing at /all, so that address can't be used unconditionally either. Searches now go to / when the default route is /all, and to /all otherwise. A tag page set as the homepage therefore gets a forum-wide search rather than one inside that tag.

Also:

  • The description is served as application/xml. Browsers download application/opensearchdescription+xml when the address is opened rather than show it. Neither Firefox nor Chrome checks the type when it loads the description, and Discourse serves the same type. The skeleton's .htaccess also expires application/xml immediately, where an unlisted type got a month.
  • <Tags> and an example <Query> are added, as the OpenSearch 1.1 spec suggests. The example uses the forum's title, the term most likely to have results in any language.

Reviewers should focus on:

  • Checked on a forum with Tags as the homepage, in fresh profiles. Firefox 158 added the engine with …/all?q={searchTerms}, and a search from its address bar showed results. Chrome stored the same address.
  • moz:SearchForm stays at the forum's root. Firefox uses it as the engine's main page, opened with no terms; it isn't a search template.

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation. (No frontend changes.)
  • Frontend changes: tests are green (run yarn test in js/). (No frontend changes.)
  • Frontend changes: tests have been added, or are not appropriate here. (No frontend changes.)
  • Backend changes: tests are green (run composer test).
  • Backend changes: tests have been added, or are not appropriate here.
  • Where applicable, changes are suitable for all supported database drivers (MySQL, MariaDB, PostgreSQL, SQLite). (No database changes.)
  • Core developer confirmed locally this works as intended.
  • The description above is written by me and describes what this pull request actually does.

Searches went to /?q=, which only searches when the discussion list is
the homepage: any other homepage ignored the query. When it is the
homepage, the frontend has nothing at /all, so the address now depends
on the default route.

The description is also served as application/xml, which browsers show
when the address is opened rather than download, and gains Tags and an
example Query.
@imorland imorland added this to the 2.1 milestone Oct 30, 2026
@imorland
imorland requested a review from a team as a code owner October 30, 2026 07:05
@imorland
imorland merged commit 979664b into 2.x Oct 30, 2026
29 checks passed
@imorland
imorland deleted the im/opensearch-default-route branch October 30, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant