Page MenuHomePhabricator

The parameter srbackend is no more effective in Special:Search
Closed, ResolvedPublicBUG REPORT

Description

In Special:Search, the parameter srbackend can used to specify an alternative search engine (like CirrusSearch during a transition phase): see SpecialSearch.php.

This parameter is not taken into account in 1.36-alpha (but it works in 1.33).

Details

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Seb35 changed the subtype of this task from "Task" to "Bug Report".Mar 10 2021, 2:29 PM
Seb35 added a subscriber: EBernhardson.

Tracking a bit this issue, it appears the issue lays in order of operations in the class SpecialSearch:

  • in execute(), we go to load() on line 185
  • in load(), we go to getSearchEngine() on line 277
  • in getSearchEngine(), the property $this->searchEngine is set with $this->searchEngineType == null (default value) until the object is destroyed and this method will always return it
  • we finish load(), then in execute we assign $this->searchEngineType = $request->getVal( 'srbackend' ); but it is too late to be effective because the corresponding SearchEngine is already created and will remain

The order of operations was changed in rMW4d9d61460d9420cc184c22243b0da81855e8f3a1 because getSearchEngine() is now used sooner.

A fix is to move the $this->searchEngineType = $request->getVal( 'srbackend' ); sooner, either at the beginning of execute() either at the beginning of load().

Poke @EBernhardson as author of the commit: you have probably a better idea than me on how to fix it properly.

Looking at this it seems like setting searchEngineType so late is unintentional. Moving it to the top of load() seems the most sensible, it matches the purpose stated in the doc comment. Might be nice to also add a test case that verifies the appropriate search engine is chosen.

Change 672661 had a related patch set uploaded (by Seb35; owner: Seb35):
[mediawiki/core@master] Restore the parameter srbackend in Special:Search

https://gerrit.wikimedia.org/r/672661

I added you as reviewer @EBernhardson. The patch implements the description you did, I hope the quality is sufficient.

Change 672661 merged by jenkins-bot:
[mediawiki/core@master] Restore the parameter srbackend in Special:Search

https://gerrit.wikimedia.org/r/672661

Seb35 claimed this task.