Page MenuHomePhabricator

Enabling the InputBox on Commons to use the new MediaSearch instead of SpecialSearch
Closed, ResolvedPublicFeature

Description

Feature summary (what you would like to be able to do and where):
On Commons, Template:Search inside category is a neat template that can be manually added to category pages to add a search box where users (even unexperienced ones) can search the category contents. including all its often many subcategories. The problem is that there doesn't seem to be any way to make it use the MediaSearch – it only uses the old outdated SpecialSearch. Please enable using it with MediaSearch by making the InputBox extension compatible with MediaSearch (this probably needs a parameter for whether or not MediaSearch is to be used and some parameter(s) for the tab that should be opened which is "Images" by default).

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):
Searching categories to see a wall of images (see also this) conveniently from category pages (+ enabling users who don't know about advanced features like the deepcategory search operator to search categories trees like that). More details here (the other issue is T376440, the namespaces thing is fixed).

Benefits (why should this be implemented?):
See above

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

In my understanding this first requires to add a new parameter to the InputBox extension (in Git) to per-case define a different frontend for results than Special:Search in MediaWiki core. Afterwards, templates (content on wikis) could be adjusted by community members according to the community's preferences. Which of these two separate aspects is this task supposed to cover?

Yes, the former. See "The problem is that there doesn't seem to be any way to make it use the MediaSearch" so this is about enabling community members to adjust the template so it uses MediaSearch (which is currently not possible) by changing the InputBox extension.

There are two existing "other extension" parameters, useve=true and usedt=true for VisualEditor and DiscussionTools respectively. Would usems=true be an appropriate parameter for MediaSearch (applying to type=search and type=search2)?

@Samwilson In my opinion yes. Thanks for looking into it.

Would usems=true be an appropriate parameter for MediaSearch (applying to type=search and type=search2)?

I think I would prefer engine=MediaSearch since MS is not a commonly understood abbreviation for MediaSearch.

If nobody puts a stop to this design by analogy we'll end up with all extensions abbreviated to two letters.

How about searchengine= to go along with searchfilter= and searchbuttonlabel=?

Change #1154028 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/InputBox@master] Add searchengine=mediasearch option

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

Change #1154909 had a related patch set uploaded (by Samwilson; author: Samwilson):

[integration/config@master] zuul/dependencies.yaml: Add MediaSearch as dep for InputBox

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

Change #1154909 merged by jenkins-bot:

[integration/config@master] Zuul: [mediawiki/extensions/InputBox] add MediaSearch as dep

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

Actually, there is a user preference for handling which search is used: search-special-page. This could be used instead of a new parameter for <inputbox> so that the search behaviour matches that of the site search. That way users can get whichever they want, according to their preference.

@Samwilson Under "Choose your search interface" I already have MediaSearch selected but it still doesn't use it. I don't know if that's the default setting (and the setting for users who are no registered&loggedin) but if not it really should be by now. So if the inputbox was changed to use whatever is configured there and mediasearch was the default, then this would be solved.

@Prototyperspective No that's right, at the moment that preference is ignored by InputBox. I'm going to update the above patch to make it use the preference value instead of adding a new searchengine=mediasearch option to the InputBox options. That feels a bit cleaner. It doesn't sound like there's any need to be able to override which search is used, per-inputbox; that's right isn't it?

@Samwalton9 Thanks! No, there isn't afaik except if the default is SpecialSearch which it shouldn't be.

update the above patch to make it use the preference value instead of adding a new searchengine=mediasearch option to the InputBox options.

Actually I'm not sure this is possible. The InputBox HTML is output with a parser hook and so can not include user-specific content. It could use the site's default value for the search-special-page preference, and then that could be replaced in the front end with the user's preference. (And for T391583 it'd be useful to have a JS module for InputBox as well, so adding this functionality here would perhaps be acceptable.)

I've updated the above patch to set the initial search value to match the configured default (i.e. $wgDefaultUserOptions['search-special-page'] = 'MediaSearch') and added a frontend module to change it dynamically to the current user's pref.

Change #1154028 merged by jenkins-bot:

[mediawiki/extensions/InputBox@master] Change the search special page based on user preference

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

I'd not realised that MediaSearch doesn't yet support prefix searches (T268238), so I'm again thinking we should add searchengine= after all. (See this thread.)

Or should we just say "if prefix is set, never use MediaSearch"? That might be simpler, and I guess at some point prefix searches will be supported there.

Change #1167841 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/InputBox@master] Add new searchengine=Search|MediaSearch parameter

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

Why should MediaSearch ever support prefixes? Prefixes are primarily for search on meta pages. MediaSearch is made to easily find media files and not to search for content in discussion page archives.

MediaSearch sort of already supports prefix searches, e.g. "prefix:File:2025". You can do the same search on Special:Search with "prefix:File:2025 but it doesn't work with ?prefix=2025&ns6=1 (although that latter is how discussion page archives etc work).

It just feels like there's some odd differences between how the two handle prefixes, and it's not possible to switch to and fro without losing some search terms, and that seems strange. I've started work to add the new searchengine= parameter, hopefully that's going to be the best way to go rather than trying to guess which to use. It does now default to whichever the user prefers, so adding this param will make possible for some templates to opt in to a specific search engine. Hopefully that's not just making things even more confusing…

All the inputboxes on https://commons.wikimedia.org/wiki/Commons:Bots/Requests, including the one to create a request, seem to point to MediaSearch now, any idea why that happens? Doesn't happen on for example https://commons.wikimedia.org/wiki/Commons:Oversighters

I am not aware of any usage of inputbox on Commons where using MediaSearch does make sense. The default should be the old search and MediaSearch should only be used when a parameter is set.

I am not aware of any usage of inputbox on Commons where using MediaSearch does make sense. The default should be the old search and MediaSearch should only be used when a parameter is set.

I don't know what you mean, please read the issue description first.
Moreover, I'm not aware of any usage of inputbox on Commons where using the old legacy SpecialSearch instead does make sense. There probably are some which need to be migrated but it's unlikely to be many and many or all of those would also work well with MediaSearch if one can specify that the Categories & Pages tab is shown.

There are only some active direct usages of <inputbox> on Commons (through transclusion the search boxes are one a huge amount of pages):

https://commons.wikimedia.org/wiki/Template:Administrators%27_noticeboard

https://commons.wikimedia.org/wiki/Commons:Village_pump/Header

https://commons.wikimedia.org/wiki/Template:Help_desk_header

https://commons.wikimedia.org/wiki/Template:Search_box

https://commons.wikimedia.org/wiki/Template:Archive_box

All of these usages are broken when using MediaSearch. Only at the general Search box template it makes sense to have this as a option (but never as default).

Okay many of these seem broken since: 1. Categories and Pages isn't preselected and 2. even when manually going to that tab, it somehow dropped the prefix search option (tested with the VillagePump search box). Are there prefix option (/ equivalent options) in MediaSearch?

Regarding search box – maybe it could be better to have some graceful upgrade where it's not made the default at first but I still think at some point the new MediaSearch is the better default option (however unlike SpecialSearch one needs to have some option to preselect the tab). SpecialSearch I think wasn't even designed with Commons in mind. It depends on whether the search box is for media or pages and if 1 and 2 above are solved, then MediaSearch could also be better.

SpecialSearch I think wasn't even designed with Commons in mind.

But here we are talking about meta pages and their archives. For these pages there is no difference between Commons and any other Wiki.

The patch for the addition of searchengine=Search is ready for review.

Should we revert the preference-based approach for now? Very happy to. But I'm sort of erring towards not, because on a skim through the ~1000 usages of search inputboxes, it does look like there are more for searching media than there are for searching talk pages etc. There might actually be more of the latter on Commons, but they are more likely to use templates and so can be changed centrally.

Change #1167841 merged by jenkins-bot:

[mediawiki/extensions/InputBox@master] Add new searchengine=Search|MediaSearch parameter

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

I think this is all done, and the remaining part (the searchtype parameter) is part of the parent task.