Page MenuHomePhabricator

MediaSearch tabs go to Special:Search when javascript is off
Closed, ResolvedPublicBUG REPORT

Description

  • disable javascript in your browser
  • search for something on commons using the top-right search bar
  • arrive on the MediaSearch page
  • click on one other other tabs
  • ... and you end up on Special:Search, when you should stay in MediaSearch

Event Timeline

I think I have a pretty clear idea of why this is happening:

The PHP UI supports the same search filters that the JS UI does (file type, file size, etc). If a no-JS user lands on the MediaSearch page with a url like ?type=image&filemime=png, the server-rendered results page will give the user only PNG results, etc.

Most of these filters are specific to a given media type. It's not valid to ask for video results and then filter by PNG files for instance. We show an "invalid search" message to users who arrive on the page with invalid type & filter combinations in their URL params.

So, in the PHP UI, the tabs that allow the user to change their search to a different type have a little extra logic built in that does two things:

  • preserves the search term while changing the type to match the given tab
  • strips out all search filter options except sorting preference (since that is the only one supported across all tabs).

Now that this change has gone live in production, a lot of users are landing on this page via index.php with title=Special:MediaSearch parameters. But changing tabs in the no-JS interface strips out the title=Special:MediaSearch params. So these users are getting booted back to the standard search page.

Basically, we now need to support another "global" parameter across all tabs in the PHP UI – title – if present. Unfortunately the code we already have here is somewhat convoluted inside a Mustache template (not designed for complex logic), so we may need to refactor things a bit. This logic probably needs to be pulled out of Mustache and back into the PHP special page file.

If this bug is considered serious, we might want to block or revert the work done so far as part of T297484 until we have a complete solution here.

Change 747976 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[mediawiki/extensions/MediaSearch@master] Don't boot users with title=\"Special:MediaSearch\" back to old search page

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

Change 747909 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[mediawiki/extensions/MediaSearch@wmf/1.38.0-wmf.13] Don't boot users with title=\"Special:MediaSearch\" back to old search page

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

Change 747976 merged by jenkins-bot:

[mediawiki/extensions/MediaSearch@master] Don't boot users with title=\"Special:MediaSearch\" back to old search page

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

Change 747909 merged by jenkins-bot:

[mediawiki/extensions/MediaSearch@wmf/1.38.0-wmf.13] Don't boot users with title=\"Special:MediaSearch\" back to old search page

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

Mentioned in SAL (#wikimedia-operations) [2021-12-17T00:45:56Z] <brennen@deploy1002> Synchronized php-1.38.0-wmf.13/extensions/MediaSearch/templates/SERPWidget.mustache: Backport: [[gerrit:747909|Don't boot users with title="Special:MediaSearch" back to old search page (T297877)]] (duration: 00m 57s)

This fix has been backported and is now live on production Commons.

Etonkovidova claimed this task.
Etonkovidova added a subscriber: Etonkovidova.

Checked - works as expected.