[wp-trac] [WordPress Trac] #64247: REST API: `class_list` sometimes returned as an object
WordPress Trac
noreply at wordpress.org
Thu Nov 13 05:18:41 UTC 2025
#64247: REST API: `class_list` sometimes returned as an object
--------------------------+-----------------------------
Reporter: dlh | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 6.6
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64247>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list