Page MenuHomePhabricator

no drop down box in search field of Special:RandomInCategory
Open, Needs TriagePublic

Description

On MediaWiki.org a drop down box appears below the search field when starting to type.

However, on my wiki's Special:RandomInCategory page, no such box appears. I checked the response of the ajax call and it seems to be valid:

{"batchcomplete":"","query":{"pages":{"-1":{"ns":0,"title":"Category:Apache","missing":"","index":1,"contentmodel":"wikitext","pagelanguage":"en","pagelanguagehtmlcode":"en","pagelanguagedir":"ltr"},"-2":{"ns":0,"title":"Category:Article","missing":"","index":2,"contentmodel":"wikitext","pagelanguage":"en","pagelanguagehtmlcode":"en","pagelanguagedir":"ltr"}}}}

Above was the response after I typed the letter a in the search field. So I don't understand why there's no dropdown box below the search field.

I tried IRC, but maybe there were no devs on the channel today. I don't know what else to do. But I reckon that for someone with knowledge of the internals this should be easy to figure out.

mw-screenshot.jpg (920×584 px, 94 KB)

Event Timeline

Anomie subscribed.

There doesn't seem to be any problem in the API here, or in category handling. You're getting no popup because the API response has only nonsense titles in namespace 0 which the widget is ignoring because it's expecting namespace 14, and those are being returned by the API because that's what the underlying search engine code is giving it.

I see you have MediaWiki-extensions-TitleKey enabled on your wiki. The issue seems to be a combination of two things:

  • TitleKey is using the deprecated 'PrefixSearchBackend' hook.
  • SearchSuggestion::fromText() is using Title::makeTitle( 0, $text ) (which forces namespace 0) rather than something more sensible like Title::newFromText().
    • Call chain: SearchEngine::completionSearchBackend() calls the hook, then passes the array of title-strings to SearchSuggestionSet::fromStrings() which uses SearchSuggestion::fromText().

The second bullet is the real bug here, although TitleKey probably should be updated to no longer use the deprecated hook too.

Thank you very much for your answers. I've deactivated TitleKey and everything is good now.

What are the next steps? Do you want to close this ticket? From @Anomie's second bullet it looks like there could be a few improvements to the core code, or am I wrong?
Brion Vibber, the author of TitleKey, is one of the MediaWiki devs, isn't he? Shouldn't he know that he's using deprecated hooks? On the other hand, I haven't experienced any changes in the search behaviour (of the main search bar), after deactivating the extension, so maybe the functionality has already been included in core and the extension should be deprecated/removed.

Please let me know what you want to do with the ticket.

What are the next steps? Do you want to close this ticket? From @Anomie's second bullet it looks like there could be a few improvements to the core code, or am I wrong?

There are indeed fixes to be made to the core code.

Brion Vibber, the author of TitleKey, is one of the MediaWiki devs, isn't he? Shouldn't he know that he's using deprecated hooks?

Brion has written a lot of things over the years. He may or may not be actively updating TitleKey.

Brion has written a lot of things over the years. He may or may not be actively updating TitleKey.

Ok, that makes sense. But shall we let him know, or is the funtionality already in core (since I haven't experienced any changes after deactivating it)?

We do not need to let him know because he might not be interested in that code anymore. :)
This tag is tagged as MediaWiki-Search already so anyone who is interested in this code area could find this task.

Hmm, ok, what about the second part of the question:

Is the funtionality already in core (since I haven't experienced any changes after deactivating it)?