Page MenuHomePhabricator

Action API returns images in unexpected order
Open, Needs TriagePublic

Description

When requesting a list of images from wikipedia API, the API can not always return the images in the right order.

Reproduce steps

  • API image info get request: https://www.mediawiki.org/wiki/API:Imageinfo
  • Set param titles as a string that consists the titles of several images seperated by '|'
  • Example titles: File:Albert%20Einstein%20Head.jpg|File:Pusa_hispida_pup.jpg|File:PD-icon.svg|usa_hispida_saimensis_at_the_Finnish_Museum_of_Natural_History_20110824|File:Pusa_hispida_hispida_NOAA_1_(cropped).jpg

Expected result
All image pages are returned in the same order as the titles

Actual result
Some image pages are not returned in the same order as the titles

Link to the API result page: https://en.wikipedia.org/w/api.php?action=query&prop=imageinfo&titles=File:Albert%20Einstein%20Head.jpg|File:Pusa_hispida_pup.jpg|File:PD-icon.svg|usa_hispida_saimensis_at_the_Finnish_Museum_of_Natural_History_20110824|File:Pusa_hispida_hispida_NOAA_1_(cropped).jpg

Event Timeline

The order of api results is based on page ids for the local page. For files from shared repos like Wikimedia Commons (without a local page) negative numbers are used and define an order. The negative numbers are based on the input order. The File:PD-icon.svg exists locally and has a page id on that wiki, which bring it to the end on your example link.
You should not depend on the order of any result from an api to work with it.
The order is needed in case of too many results and to provide pagination / continue option in the api.

For me this task sounds as it is not fixable.