Page MenuHomePhabricator

Sort MediaSearch results by index
Closed, ResolvedPublic

Description

Sort per-page MediaSearch by index before adding to image suggestions response data.

Results from the Action API are not sorted in the same order as they are if you perform the same search in MediaSearch on Commons. Looking at the index values of the data from the Action API, the Image Suggestions API is receiving the top X results, but the results are not sorted by index.

Inspecting the MediaSearch extension code, in file SpecialMediaSearch.php function search(), the extension sorts the returned results by index:

https://gerrit.wikimedia.org/g/mediawiki/extensions/MediaSearch/+/48b924223edc0bfebec12229ea637649a65dadbe/src/Special/SpecialMediaSearch.php#496

We therefore need to mirror this logic by adding an equivalent sort to the Image Suggestion API code. As these are tiny arrays, this will not measurably affect performance.

Event Timeline

Change 683443 had a related patch set uploaded (by BPirkle; author: BPirkle):

[mediawiki/services/image-suggestion-api@master] Sort MediaSearch results by index

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

Change 683443 merged by jenkins-bot:

[mediawiki/services/image-suggestion-api@master] Sort MediaSearch results by index

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

Change 888726 had a related patch set uploaded (by Kimberly Sarabia; author: Kimberly Sarabia):

[mediawiki/skins/MinervaNeue@master] Remove onBeforePageDisplay for Minerva

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

Change 888726 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Remove onBeforePageDisplay for Minerva

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