I'm upgrading my site to MediaWiki 1.26 (from 1.24) and noticed a change in API behavior. One of our custom API modules:
http://mywiki.com/w/api.php?action=foobar&format=json......
used to return a JSON array, like this:
[ {"start":"2015-12-28","end":"2016-01-01", ...} ]
and now it returns a numerically indexed hash like this instead:
{"0":{"start":"2016-01-18","end":"2016-01-18", ...}}
Do we need to do something special in 1.26 to get the array instead of the hash? Or is this a breaking change? Or are we probably doing something wrong? I looked for breaking API changes in 1.25 and 1.26 but don't see anything like this:
https://www.mediawiki.org/wiki/MediaWiki_1.25#API_changes https://www.mediawiki.org/wiki/MediaWiki_1.26#API_changes
Thanks, DanB
On Mon, Jan 4, 2016 at 12:36 PM, Daniel Barrett danb@cimpress.com wrote:
I'm upgrading my site to MediaWiki 1.26 (from 1.24) and noticed a change in API behavior. One of our custom API modules:
http://mywiki.com/w/api.php?action=foobar&format=json......
used to return a JSON array, like this:
[ {"start":"2015-12-28","end":"2016-01-01", ...} ]
and now it returns a numerically indexed hash like this instead:
{"0":{"start":"2016-01-18","end":"2016-01-18", ...}}
The API no longer returns root arrays by default, because that's almost always not what's intended (see T12887). If necessary you can override that for your action module with $result->addArrayType( null, 'array' ).
Do we need to do something special in 1.26 to get the array instead of the hash? Or is this a breaking change? Or are we probably doing something wrong? I looked for breaking API changes in 1.25 and 1.26 but don't see anything like this:
https://www.mediawiki.org/wiki/MediaWiki_1.25#API_changes
Apparently that page didn't pick up the ApiResult rewrite that was mentioned in 1.25's full release notes < https://phabricator.wikimedia.org/diffusion/MW/browse/REL1_25/RELEASE-NOTES-.... API modules may need changing, see https://lists.wikimedia.org/pipermail/wikitech-l/2015-May/081646.html for details.
mediawiki-api@lists.wikimedia.org