Tuesday, November 24, 2009

SmallSearchInputBox Ignores Search Scope Settings

About the only nice thing about spending hours tracing a seemingly-incomprehensible issue is the satisfaction of cracking the bugger!

I have just beaten a particularly annoying SharePoint problem, which with hindsight shouldn't have been too hard at all to trace. But only going through the steps that lead to discovering the cause was I able to reach the final "why didn't I think of that before?" realisation.

The SmallSearchInputBox search box on a standard SharePoint site was ignoring the search scopes, and only ever displaying contextual scopes. These are the steps I followed:
  1. Looked at all the enabled features at all scopes (farm, web application, site and web), but nothing unusual was visible there
  2. Tried creating a new search box feature with lower sequence numbers than the normal "25" used by the enhanced search feature. Still no change. Tried activating this feature at all scopes, but still no effect
  3. Created a new content placeholder in the master page, set the visibility to false for the existing content holder that holds the "SmallSearchInputBox" delegate control. Added a delegate control with a new ID to the new content placeholder, and tried activating a feature adding a search box to that new custom placeholder. The new search box always repeated the behaviour of the now-hidden one (i.e. still ignored the search scopes
Finally I wrote a small console application that lists the delegate controls that are activated at all scopes in the farm. There I found that some non-standard feature was adding the SmallSearchInputBox with the lowest sequence number. Here's a screenshot of the control delegates from my custom application (minus the offending instance, as I took this after the fix!):

Phew, at last some headway. I could then do a text search in the Features folder of the 12 hive to find the XML file that set the sequence number for a SmallSearchInputBox control to "10". Found the feature, that happened to be configured as "hidden", uninstalled that feature, and at last the search is good again.

Now time to relax!