WordPress/wp-includes/rest-api/fields
dmsnell 63c7122ed0 REST API, Meta: Store updates in database when they are equal to the defaults.
This patch fixes an oversight from when default metadata values were introduced
in #43941 in WordPress 5.5: metadata updates should persist in the database
even if they match the registered default value (because the default values 
can change over time).

Previously, the REST API code was comparing updated values against the value
returned by the default-aware `get_metadata()` method. This meant that if no
value existed in the database, and the default value was supplied to the update,
WordPress would think that the updated value was already persisted and skip
the database call.

Now, the `get_metadata_raw()` method is called for comparing whether or not
a database update is required, fixing the bug.

In this patch both issues are resolved.

Developed in https://github.com/wordpress/wordpress-develop/pull/6782
Discussed in https://core.trac.wordpress.org/ticket/55600

Follow-up to [48402].

Props: dmsnell, kraftner, ramon-fincken.
Fixes #55600.

Built from https://develop.svn.wordpress.org/trunk@58831


git-svn-id: http://core.svn.wordpress.org/trunk@58227 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-07-29 18:49:14 +00:00
..
class-wp-rest-comment-meta-fields.php REST API: Update “object” strings to use the appropriate nouns. 2021-05-25 13:12:58 +00:00
class-wp-rest-meta-fields.php REST API, Meta: Store updates in database when they are equal to the defaults. 2024-07-29 18:49:14 +00:00
class-wp-rest-post-meta-fields.php REST API: Update “object” strings to use the appropriate nouns. 2021-05-25 13:12:58 +00:00
class-wp-rest-term-meta-fields.php REST API: Update “object” strings to use the appropriate nouns. 2021-05-25 13:12:58 +00:00
class-wp-rest-user-meta-fields.php REST API: Update “object” strings to use the appropriate nouns. 2021-05-25 13:12:58 +00:00