[wp-trac] [WordPress Trac] #55600: Can't save registered post meta field of type string that equals registered default value via REST API
WordPress Trac
noreply at wordpress.org
Wed Jun 26 09:48:13 UTC 2024
#55600: Can't save registered post meta field of type string that equals registered
default value via REST API
--------------------------------------+------------------------------
Reporter: kraftner | Owner: (none)
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: rest-api
--------------------------------------+------------------------------
Comment (by kraftner):
As it is the back of my brain kept grinding on the issue and I went back
to double check again if/how the tests fail without the patch.
While doing so I noticed that my table above was wrong. The 500 error
@ramon-fincken and me noticed with non-single/multi value keys is actually
worse.
Without the change from `get_metadata` to `get_metadata_raw` any updates
of keys registered as non-single make the whole request fail with a 500
error.
This is due to the fact that [https://github.com/WordPress/wordpress-
develop/blob/df256e414c183ff001cdf26ebf37b19b960180de/src/wp-includes
/rest-api/fields/class-wp-rest-meta-fields.php#L265-L364
`update_multi_meta_value`] does delete existing values before it re-adds
them. But since it thinks of the non-stored values as stored and then
tries to delete them the deletion fails resulting in the whole request to
abort and fail with a 500.
This is even worse than my initially reported issue since it might abort
mid-way updating multiple meta values which can result in an inconsistent
state of the meta values.
The good news is that the patch in my PR also fixes this issue.
For completeness sake I'll update the table in my previous comment also
considering that original error state.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55600#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list