Opened 4 years ago
Last modified 4 years ago
#53942 assigned defect (bug)
Non-single post meta multiple value update breaks post save through REST API
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | blocker | Version: | 5.8 |
| Component: | REST API | Keywords: | needs-patch |
| Focuses: | rest-api | Cc: |
Description
This is a follow-up to #52787.
Same situation as in #52787, but this time while updating non-single meta multiple values at once like { meta: { metaKey: [1, 2, 3] } }, REST API fires update_multi_meta_value(), which tries first to delete old values in the database. When no meta value is present in database, get_metadata() returns defaults as $current_values and then trying to delete them anyway (non-existent in fact). This causes update_multi_meta_value() to return WP_Error('rest_meta_database_error') on delete_metadata() failure.
BTW, error messages could be more specific from 'Could not update the meta value of %s in database.' to 'Could not update/delete...' and 'Could not update/add...'.
Note: See
TracTickets for help on using
tickets.
Temporary workaround could use short-circuit filter in
delete_metadata()and might look like this: