[2.x] A filter on a resource without a searcher returns a 500

Aperta
#5,578 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@imorland ci sta già lavorando.

Dal 23/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

type/bug
Current Behavior

Any filter[...] on a list endpoint whose resource has no searcher returns a 500:

RuntimeException: Not supported in Flarum, please use a model searcher instead https://docs.flarum.org/extend/search.

Api\Endpoint\Index uses the search manager only for searchable models. For other resources it calls applyFilters(), which calls AbstractDatabaseResource::filters(), and that method always throws. A client mistake therefore surfaces as a server error. This happens on every database driver.

Steps to Reproduce
  1. Enable flarum/flags (its flags resource has no searcher).
  2. As an admin, request GET /api/flags?filter[id]=1.
  3. The response is a 500 with the exception above.
Expected Behavior

A 400, as json-api-server's apply_filters() gives for a filter a resource doesn't define (Invalid filter: <name>).

Environment
  • Flarum: 2.x @ b43a84be3
  • Reproduced on PostgreSQL 18; the code path doesn't depend on the driver.
Possible Solution

In Index, when the model isn't searchable and the request has filters, throw the same BadRequestException instead of reaching filters().

Lingua principale
PHP
Stelle
6.8k
Fork
891
Merge medio
1g 10h
PR unite (30g)
209

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di flarum/framework

Tutte le issue di flarum/framework

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.