Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions cannot register custom Searcher classes #2712

Closed
clarkwinkelmann opened this issue Mar 18, 2021 · 1 comment · Fixed by #2755
Closed

Extensions cannot register custom Searcher classes #2712

clarkwinkelmann opened this issue Mar 18, 2021 · 1 comment · Fixed by #2755
Assignees
Milestone

Comments

@clarkwinkelmann
Copy link
Member

Bug Report

Current Behavior
Beta 16 introduced the new Search API, including the AbstractSearcher class and container-bound gambits.

It's not made super clear in the documentation, but just like for custom frontends, it's assumed that the developer needs to register at least one gambit via Extend\SimpleFlarumSearch for the container bindings to be set up for a new searcher class.

It's also not super clear in the documentation but clear from the source code that a full text gambit must be registered as it's the basis for the SearchServiceProvider to register the bindings.

However registering a full text gambit does not sets up the bindings, and as a result the Searcher class cannot be resolved through the container.

The issue is actually that the full text gambits for new searcher are not saved in the container due to resolving used instead of extend.

Steps to Reproduce

  1. Create custom Searcher class extending AbstractSearcher
  2. Register class with full text gambit (new Extend\SimpleFlarumSearch(MyCustomSearcher::class))->setFullTextGambit(AFullTextGambit::class)
  3. Try resolving MyCustomSearcher
  4. Observe error Illuminate\Contracts\Container\BindingResolutionException: Unresolvable dependency resolving [Parameter #1 [ <required> array $searchMutators ]] in class Flarum\Search\AbstractSearcher in /home/clark/Projects/flarum-beta16/vendor/illuminate/container/Container.php:1057

A dump at line 67 of SearchServiceProvider confirms there is no entry for the new searcher.

Environment

  • Flarum version: beta 16

Possible Solution

resolving needs to be replaced with extend. Tests need to be added for custom searcher classes.

@clarkwinkelmann
Copy link
Member Author

clarkwinkelmann commented Apr 5, 2021

For cross reference, there is a discussion about this on the forum here https://discuss.flarum.org/d/26503-custom-searcher-classes-broken-in-beta-16

There are actually quite a few more extensions impacted than I originally thought.

Published extensions include KILOWHAT Formulaire, KILOWHAT Audit and FoF Pages. It will probably impact FoF Taxonomies whenever I manage to update it for the latest Flarum version.

Carving Contest was also affected but it was a candidate for the new filter system.

It's also impacting two of my WIP extensions, KILOWHAT Cimaise and Flamarkt.

The workaround published on Discuss works great as a temporary solution though, so not too big of an issue.

yixuan added a commit to cosname/flarum-chinese-search that referenced this issue Apr 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants