#50790 closed defect (bug) (fixed)
REST API: Allow sending empty array to remove all values for single = false meta
| Reported by: | chrisvanpatten | Owned by: | TimothyBlynJacobs |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.7 |
| Component: | REST API | Version: | 4.7 |
| Severity: | normal | Keywords: | good-first-bug has-patch has-unit-tests |
| Cc: | Focuses: | rest-api |
Description
When sending an update to a piece of content via the REST API, meta registered with 'single' => false cannot be removed by sending an empty array; you must send null.
The inability to send an empty array is slightly confusing and inconsistent with array-type meta registered with 'single' => true, which will correctly save the empty value.
Change History (6)
#1
@
6 years ago
- Keywords good-first-bug added
- Milestone Awaiting Review → Future Release
- Version → 4.7
This ticket was mentioned in Slack in #core-restapi by chrisvanpatten. View the logs.
6 years ago
This ticket was mentioned in PR #869 on WordPress/wordpress-develop by chrisvanpatten.
6 years ago
#3
- Keywords has-patch has-unit-tests added
Allow passing an empty array to the REST API for registered non-single meta to remove the DB values, as an alternative to sending null.
Trac ticket: https://core.trac.wordpress.org/ticket/50790
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
@chrisvanpatten Do you want to work on a patch for this? We have a bit more time for inclusion in 5.6.
I think the fix would be updating the
is_null()clause inWP_REST_Meta_Fields::update_value()to a accept an empty array if the meta type is notsingle.