{"action":"created","issue":{"url":"https://api.github.com/repos/WP-API/WP-API/issues/2582","repository_url":"https://api.github.com/repos/WP-API/WP-API","labels_url":"https://api.github.com/repos/WP-API/WP-API/issues/2582/labels{/name}","comments_url":"https://api.github.com/repos/WP-API/WP-API/issues/2582/comments","events_url":"https://api.github.com/repos/WP-API/WP-API/issues/2582/events","html_url":"https://github.com/WP-API/WP-API/issues/2582","id":163648713,"number":2582,"title":"Using term filters can cause the API to return objects instead of arrays","user":{"login":"27pchrisl","id":6286310,"avatar_url":"https://avatars.githubusercontent.com/u/6286310?v=3","gravatar_id":"","url":"https://api.github.com/users/27pchrisl","html_url":"https://github.com/27pchrisl","followers_url":"https://api.github.com/users/27pchrisl/followers","following_url":"https://api.github.com/users/27pchrisl/following{/other_user}","gists_url":"https://api.github.com/users/27pchrisl/gists{/gist_id}","starred_url":"https://api.github.com/users/27pchrisl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/27pchrisl/subscriptions","organizations_url":"https://api.github.com/users/27pchrisl/orgs","repos_url":"https://api.github.com/users/27pchrisl/repos","events_url":"https://api.github.com/users/27pchrisl/events{/privacy}","received_events_url":"https://api.github.com/users/27pchrisl/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/WP-API/WP-API/labels/Bug","name":"Bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-07-04T10:31:58Z","updated_at":"2016-09-21T21:01:27Z","closed_at":null,"body":"Hi,\r\n\r\nWordPress allows you to filter processes like get_terms. Through this you can unset terms from the array that's then returned for further processing. A side effect of doing this that affects the JSON encoder but not normally further PHP processing is that the JSON encoder must now output arrays filtered in this way as JSON objects instead of arrays, because the internal structure of the array is now key/value due to deleted numeric keys (wrong terminology, but it sort of works).\r\n\r\nAn example of the problem is here: http://stackoverflow.com/questions/5943149/rebase-array-keys-after-unsetting-elements\r\n\r\nShould the API:\r\n\r\na) defensively call array_values on things it expects to be trying to output as an array? (So that the API contract can't be broken), or:\r\nb) should this be documented behaviour and it's the responsibility of the filter developer to call array_values?\r\n\r\nI might suggest (a), if only because there may be plugins out in the world that do not call array_values because it's never affected PHP, but being used on sites that then would have potentially random WP-API behaviour switching between Object and Array for filtered and non-filtered term arrays.\r\n\r\nThis probably isn't restricted to term filters, but it's where I noted the behaviour."},"comment":{"url":"https://api.github.com/repos/WP-API/WP-API/issues/comments/248741801","html_url":"https://github.com/WP-API/WP-API/issues/2582#issuecomment-248741801","issue_url":"https://api.github.com/repos/WP-API/WP-API/issues/2582","id":248741801,"user":{"login":"rmccue","id":21655,"avatar_url":"https://avatars.githubusercontent.com/u/21655?v=3","gravatar_id":"","url":"https://api.github.com/users/rmccue","html_url":"https://github.com/rmccue","followers_url":"https://api.github.com/users/rmccue/followers","following_url":"https://api.github.com/users/rmccue/following{/other_user}","gists_url":"https://api.github.com/users/rmccue/gists{/gist_id}","starred_url":"https://api.github.com/users/rmccue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmccue/subscriptions","organizations_url":"https://api.github.com/users/rmccue/orgs","repos_url":"https://api.github.com/users/rmccue/repos","events_url":"https://api.github.com/users/rmccue/events{/privacy}","received_events_url":"https://api.github.com/users/rmccue/received_events","type":"User","site_admin":false},"created_at":"2016-09-21T21:01:27Z","updated_at":"2016-09-21T21:01:27Z","body":"This is definitely a bug; I think we just need to defensively call `array_values`. It's not the responsibility of the filter developers, since this is a specific thing to JSON encoding."}}
{"actor":{"display_login":"rmccue"}}