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 claimed this task.
Anomie raised the priority of this task from to Needs Triage.
Anomie updated the task description. (Show Details)
Anomie added a project: MediaWiki-Action-API.
Anomie subscribed.

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

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

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

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

Change 716459 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/core@master] Revert \"API: Work around PHP bug 45959\"

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

Change 716459 merged by jenkins-bot:

[mediawiki/core@master] Revert \"API: Work around PHP bug 45959\"

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