[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
Tue Jun 25 15:13:43 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):
@dmnsell It wouldn't make sense to only fix one case because than the
behavior would be even more confusing. Anyway, I got this working now for
all types including extensive test coverage. I just really can't do any
productive work on Contributor Day - I just need my proper setup and a
calm room :)
@ramon-fincken I don't think we should move the registration to the setUp
function. They would then be registered for every test in this test class
which is not needed. There are plenty of tests in this file that do set up
their own fields just for one particular test. I think those on the setUp
function are only those that are used across multiple tests.
For the sake of completeness: Here is the table we've been talking about
@dmsnell
It shows whether a default value of a specific type is being saved to the
DB using either the PHP API or the REST API.
|| ||= `update_metadata()` =||=
`WP_REST_Meta_Fields::update_meta_value()` =||
||= boolean default (single) =|| Yes || Yes ||
||= boolean default (multi) =|| Yes || Yes ||
||= integer default (single) =|| Yes || Yes ||
||= integer default (multi) =|| Yes || Yes ||
||= number default (single) =|| Yes || Yes ||
||= number default (multi) =|| Yes || Yes ||
||= object default (single) =|| Yes || Yes ||
||= object default (multi) =|| Yes || Yes ||
||= string default (single) =|| Yes || No ||
||= string default (multi) =|| Yes || No ||
All in all I've thought this through again and it looks good to me now as
is.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55600#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list