This will probably have to be done in multiple patches. Also this might be easier once T150390 has extracted the result rendering from the class. The high level idea:
- SpecialSearch::goResult should only handle 'go', and not forward on to SpecialSearch::showResults. Make things easier to follow by only having a single patch from execute -> showResults. Maybe goResult should just return a boolean true if go was sucessfull, and false on failure.
- SpecialSearch::showResults is currently ~225 lines, which can make it hard to keep in your head all the state the is around. Try and split a few functions out, for example the code that handles wgDisableTextSearch can probably move into its own function, and be called at the top level from SpecialSearch::execute instead.
- Could powersearch be extracted into some sort of helper class that just has methods to apply powersearch options to the search engine, and render the powersearch box? Could this be generalized into a way to map a profile to what it does? Also could we rename powersearch to 'advanced' to match the profile= parameter and how it's shown in the interface at the same time?
- Might be worth checking usage data, but we could also strip the 'startsWithImage' feature, which allows to search the file namespace by typing file:foo
- Can various stateless helpers, such as makeSearchLink, shortDialog, be extracted? might not be worthwhile.
- Maybe more, these are some initial things I noticed paging through.