Opened 9 hours ago
Last modified 8 hours ago
#64247 new defect (bug)
REST API: `class_list` sometimes returned as an object
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 6.6 |
| Component: | REST API | Keywords: | has-patch has-unit-tests |
| Focuses: | Cc: |
Description
The class_list property in the REST API posts endpoint returns the array of classes generated by get_post_class(). The final step in get_post_class() is to run array_unique() over the array, which removes duplicate classes but doesn't reset the array keys, usually causing the keys to become non-sequential, and in turn causing the array to be converted to a JSON object in the REST response. See the attached screenshot showing an API response from a site affected by this issue.
(A similar problem was fixed just the other day in [61210].)
The linked PR would address the issue within the controller, since the array needs to be indexed at that point no matter how the list of classes is generated.
Attachments (1)
Change History (4)
This ticket was mentioned in PR #10515 on WordPress/wordpress-develop by @dlh.
9 hours ago
#1
- Keywords has-patch has-unit-tests added
@Mamaduka commented on PR #10515:
9 hours ago
#2
@dlh commented on PR #10515:
8 hours ago
#3
Fixed!
The fix makes sense.
The unit tests are failing with following error: