[wp-trac] [WordPress Trac] #42195: wp_slash() is lossy

WordPress Trac noreply at wordpress.org
Thu Oct 12 10:27:16 UTC 2017


#42195: wp_slash() is lossy
-------------------------+-------------------------------------------------
 Reporter:  johnbillion  |      Owner:
     Type:  defect       |     Status:  new
  (bug)                  |  Milestone:  Awaiting Review
 Priority:  normal       |    Version:
Component:  Formatting   |   Keywords:  needs-patch dev-feedback needs-
 Severity:  normal       |  unit-tests
  Focuses:               |
-------------------------+-------------------------------------------------
 Calling `wp_slash()` converts all values to strings, causing data loss for
 integers, floats, and booleans.

 Example:

 {{{
 wp_slash( 123 ); // '123'
 wp_slash( 123.4 ); // '123.4'
 }}}

 The above results in the values being cast to strings.

 Booleans are cast to strings too, with a value of '1' or an empty string:

 {{{
 wp_slash( true ); // '1'
 wp_slash( false ); // ''
 }}}

 This causes particular problems for `delete_metadata()` when passing a
 meta value, because the meta value is slashed before being serialized in
 order to perform the SQL lookup for matching rows, causing the lookup to
 fail.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42195>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list