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

WordPress Trac noreply at wordpress.org
Wed Oct 11 15:50:24 UTC 2017


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

Comment (by pilou69):

 Having an issue with this too in 4.8.2.

 It's not random, it always happens when the meta is not modified and has
 any characters that must be slashed.

 We found 3 ways to work around this:
 1. Apply modification above, but it overrides the core :(
 {{{
 if ( $old_value[0] === $value ) {
 }}}

 2. Register meta fields as single => false. But that seems very ugly.

 3. Create custom endpoint:

 create a class extending WP_REST_Meta_Fields, and override
 update_meta_value function with patch applied above

 {{{ extend WP_REST_Posts_Controller }}} (WP_REST_{$type}_Controller),)

 override in you custom endpoint controller
 {{{$this->meta}}} with your Class with the patch

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


More information about the wp-trac mailing list