Automattic / Automattic/jetpack

JSON API: parse_types should return an array or be checked

Open
#7,216 2 comments 0 reactions 0 assignees View on GitHub
[Feature] WPCOM API [Pri] Low [Status] Stale Bug
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

`E_WARNING: array_shift() expects parameter 1 to be array, string given in array_shift called at /var/www/wp-content/mu-plugins/jetpack/class.json-api-endpoints.php (316)`

LOC in question: https://github.com/Automattic/jetpack/blob/4.9/class.json-api-endpoints.php#L316

Problem is here:
https://github.com/Automattic/jetpack/blob/4.9/class.json-api-endpoints.php#L689

We're returning `'none'` instead of something like an empty array or something else that would be fine OR we need to type check near L316.

Originally reported in p1HpG7-42b-p2

Contributor guide

Open the contributing guide

Research direction

Inspect class.json-api-endpoints.php at lines 316 and 689, starting with how parse_types is produced and consumed. Confirm the warning path and establish whether the completed behavior should ensure parse_types is array-compatible or guard array_shift() before making the change.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.