[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
Mon Jul 29 18:47:37 UTC 2024


#55600: Can't save registered post meta field of type string that equals registered
default value via REST API
-------------------------------------------------+-------------------------
 Reporter:  kraftner                             |       Owner:  dmsnell
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  6.7
Component:  Options, Meta APIs                   |     Version:  5.5
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests needs-dev-  |     Focuses:  rest-api
  note 2nd-opinion                               |
-------------------------------------------------+-------------------------
Changes (by dmsnell):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"58831" 58831]:
 {{{
 #!CommitTicketReference repository="" revision="58831"
 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.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55600#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list