Page MenuHomePhabricator

ApiResult validation should work around PHP bug 45959
Closed, ResolvedPublic

Description

When testing the patch for T91455, I noticed that the JSON output has duplicated all the numbered subkeys of the "params" item. This also occurs on the current TemplateData master.

Further investigation reveals that PHP is incredibly stupid when casting objects with integral keys to arrays: the array then has integral strings as keys, which can't be accessed via the [] operator (but do work with foreach), and assigning creates a new key with an integer key while leaving the integral-string key in place.

This was filed upstream as PHP bug 45959, where it was closed as "if we document it, then we can claim it's not a bug anymore". So we'd better work around the undesired behavior.

Event Timeline

Anomie created this task.Jan 14 2016, 9:11 PM
Anomie updated the task description. (Show Details)
Anomie raised the priority of this task from to Needs Triage.
Anomie claimed this task.
Anomie added a project: MediaWiki-API.
Anomie added a subscriber: Anomie.
Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald TranscriptJan 14 2016, 9:11 PM

Change 264138 had a related patch set uploaded (by Anomie):
API: Work around PHP bug 45959

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

Anomie moved this task from Unsorted to Needs Review on the MediaWiki-API board.Jan 14 2016, 9:13 PM

Change 264138 merged by jenkins-bot:
API: Work around PHP bug 45959

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

Anomie closed this task as Resolved.Jan 16 2016, 4:55 AM