Page MenuHomePhabricator

Gather frontend should make sure list sorting does not depend on the browser's JSON property iteration order
Closed, DeclinedPublic

Description

Compare http://en.wikipedia.org/w/api.php?action=query&format=jsonfm&generator=listpages&glspid=13 and

$.get( 'https://en.wikipedia.org/w/api.php?action=query&format=json&generator=listpages&glspid=13' ).then( function( data ) {
    for ( i in data.query.pages ) {
        console.log( i, data.query.pages[i] );
    }
} );

The first will order results by title. On Chrome, the second will order results by page id. This is due to Chrome's technically valid but annoying behavior of rearranging numeric JSON keys. Clients should ensure they do not depend on the browser's iteration order; this can be done by asking for and iterating the indexpageids parameter.

Noticed in the generator=listpages API calls, but any call using title parameter or a generator might be affected.

Event Timeline

Tgr raised the priority of this task from to Needs Triage.
Tgr updated the task description. (Show Details)
Tgr added a project: Gather.
Tgr subscribed.
MBinder_WMF subscribed.

This task was declined as part of a batch-decline related to sunsetting the Gather project. Please ping (politely) if this task should be reopened. For more information, you can also see here: https://www.mediawiki.org/wiki/Extension:Gather