Page MenuHomePhabricator

Enabling to specify which tab of MediaSearch should open (eg images or pages) with InputBox on Commons is broken
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

It opens the Image tab. This is just like before T404955 was implemented.

I think this worked well when I edited Template:Search box but now it doesn't anymore.

What should have happened instead?:

It should open the Categories and Pages tab (and with the specified namespace restrictions like namespaces = Commons or namespaces=Help**).

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

I wanted to test whether the namespace restrictions still work with MediaSearch and start adjusting some searchboxes but now it doesn't work at all.

T404955

Event Timeline

Oh good catch. I think it works if you specify both searchengine = MediaSearch and searchtype = page but not if you rely on the default for searchengine (which is MediaSearch and so it should be fine to leave it out).

Thanks. Could things be changed so it also works when MediaSearch is not specified as the searchengine? The namespace parameter doesn't work with MediaSearch, I'll make a separate issue about that.

Could things be changed so it also works when MediaSearch is not specified as the searchengine?

Yes, I think it should look at the default value of searchengine and if it's MediaSearch then searchtype should take effect. But if the default (or user pref) is for Search, then searchtype should probably be ignored.

My user preference is not SpecialSearch. I thought the default on Commons by now is Commons.
So I think it should make use of the specified searchtype (but doesn't and if I remember correctly it did use it but not anymore),

Moreover, even when specifying searchengine=MediaSearch in the template and then specifying its added parameter searchtype from where the template is used like so {{Search in category|searchtype=video}} e.g. here, it still doesn't work and like before just opens the default image tab of the MediaSearch.

The {{search inside category}} template needed to invoke <inputbox> as {{#tag: inputbox }}. I've updated it, and updated the usage in Category:Featured_media, and the searchtype param is now honoured.

The docs do say to do it like this, but they don't really explain why, and it's not very clear why some things (like {{langswitch}}) do work as expected within the tag form but others (like {{#if:}}) don't. :-(

Prototyperspective claimed this task.

@Samwilson Thanks for explaining! This solved it. I think it would be good to update the docs with the info, in specific in the table for the parameters to add a brief note like "Only works when using #tag" – do you know which other parameters only work when using that? If it's too many that's probably not a good idea but if I was to create a template or change it, I maybe would only look at the parameters table without checking the whole page for a potential section about use in templates which is unusual and not needed for other similar things. An alternative idea, especially if it's more than 3-6 parameters would be to add a short note to the top of the Parameters section.

@Prototyperspective It's calling Parser::replaceVariables() on all parameters (well, on the whole contents of <inputbox>), which replaces variables, templates, and template arguments — but it doesn't get passed the current frame and so doesn't replace template arguments. I'm not sure why it is this way. I've opened a task to figure it out: T414158: Expand template arguments in inputbox parameters