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

WordPress Trac noreply at wordpress.org
Wed Aug 15 16:59:16 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 dcavins):

 Ah, the test setup was broken--the meta registration was moved in one of
 the patch updates. I'll upload a new patch that corrects the test setup
 and also moves to the `(string) sanitize_meta( $meta_key, wp_unslash(
 $meta_value ), $meta_type ) === $old_value[0]` comparison check.

 With the corrected tests (and the old comparison code in place), 9 out of
 15 assertions fail:


 {{{
 1)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_same_value
 with data set #0 ('test_boolean_update', 0)
 Failed asserting that 500 matches expected 200.

 2)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_same_value
 with data set #2 ('test_boolean_update', false)
 Failed asserting that 500 matches expected 200.

 3)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_same_value
 with data set #4 ('test_boolean_update', '')
 Failed asserting that 400 matches expected 200.

 4)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_same_value
 with data set #5 ('test_boolean_update', '0')
 Failed asserting that 500 matches expected 200.

 5)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_same_value
 with data set #7 ('test_textured_text_update', 'She said, "What about the
 > 1...chen?"')
 Failed asserting that 500 matches expected 200.

 6)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_same_value
 with data set #8 ('test_textured_text_update', 'He's about to do something
 rash...')
 Failed asserting that 500 matches expected 200.

 7)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_similar_value
 with data set #0 ('test_boolean_update', 0, '')
 Failed asserting that 400 matches expected 200.

 8)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_similar_value
 with data set #2 ('test_boolean_update', false, 0)
 Failed asserting that 500 matches expected 200.

 9)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_similar_value
 with data set #4 ('test_boolean_update', '', false)
 Failed asserting that 500 matches expected 200.
 }}}


 7 of these failures are the expected 500 when `update_metadata()` fails.
 2, though, are "Bad Request" 400 errors, caused by passing an empty string
 as the update value to the test, and these are unaffected by the changes,
 so I'm assuming that they happen upstream of the actual update routine.

 With the new comparison in place, there are only the two "Bad Request"
 failures:


 {{{
 1)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_same_value
 with data set #4 ('test_boolean_update', '')
 Failed asserting that 400 matches expected 200.

 /Users/dcavins/Sites/develop.git.wordpress.org/tests/phpunit/tests/rest-
 api/rest-post-meta-fields.php:1239

 2)
 WP_Test_REST_Post_Meta_Fields::test_update_value_return_success_with_similar_value
 with data set #0 ('test_boolean_update', 0, '')
 Failed asserting that 400 matches expected 200.
 }}}

 Thanks again for the help with getting this change accepted.

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


More information about the wp-trac mailing list