#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 |
---|---|---|---|
Milestone: | 5.7 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | REST API | Keywords: | good-first-bug has-patch has-unit-tests |
Focuses: | rest-api | Cc: |
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
@
4 years ago
- Keywords good-first-bug added
- Milestone changed from Awaiting Review to Future Release
- Version set to 4.7
This ticket was mentioned in Slack in #core-restapi by chrisvanpatten. View the logs.
4 years ago
This ticket was mentioned in PR #869 on WordPress/wordpress-develop by chrisvanpatten.
4 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
#4
@
4 years ago
- Owner set to TimothyBlynJacobs
- Resolution set to fixed
- Status changed from new to closed
In 49966:
@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
.