[wp-trac] [WordPress Trac] #42069: Saving metadata fails (randomly) if equal value already exists

WordPress Trac noreply at wordpress.org
Mon Sep 17 19:09:23 UTC 2018


#42069: Saving metadata fails (randomly) if equal value already exists
-------------------------------------+-----------------------
 Reporter:  JVel                     |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  5.0
Component:  REST API                 |     Version:  4.8.2
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  rest-api
-------------------------------------+-----------------------

Comment (by boonebgorges):

 Quoting from https://core.trac.wordpress.org/ticket/42810#comment:10:

 >
 > I'd like to flag this as a Gutenberg blocker, because of the following
 situation:
 >
 > 1. You have a post with more than one block that uses post meta
 attributes
 > 2. One or more of those blocks save their data as a JSON-encoded string,
 as recommended in the documentation
 https://wordpress.org/gutenberg/handbook/block-
 api/attributes/#considerations
 > 3. You save the post without modifying the data in one or more of the
 blocks
 >
 > Because the REST API uses *slashed* data to compare with the existing
 values, but `get_metadata()` returns *unslashed* data, most JSON-encoded
 strings will look "new" to the REST API
 https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-includes/rest-
 api/fields/class-wp-rest-meta-fields.php?marks=299,301#L287 But
 `update_metadata()` correctly compares unslashed-to-unslashed values, so
 returns `false`. Not only does this cause an "Updating failed" notice in
 Gutenberg, but because of the way that the `update_value()` method returns
 early out of the `foreach()` loop, blocks further down the page are not
 processed. https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-
 includes/rest-api/fields/class-wp-rest-meta-
 fields.php?marks=131,163-165#L129

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


More information about the wp-trac mailing list