WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 7 days ago

#50790 new defect (bug)

REST API: Allow sending empty array to remove all values for single = false meta

Reported by: chrisvanpatten Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: good-first-bug
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 (1)

#1 @TimothyBlynJacobs
7 days ago

  • Keywords good-first-bug added
  • Milestone changed from Awaiting Review to Future Release
  • Version set to 4.7

@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 in WP_REST_Meta_Fields::update_value() to a accept an empty array if the meta type is not single.

Note: See TracTickets for help on using tickets.