[wp-trac] [WordPress Trac] #27550: Incorrect slashing in `wp_trash_post()` and `wp_untrash_post()`

WordPress Trac noreply at wordpress.org
Tue Aug 25 15:22:14 UTC 2015


#27550: Incorrect slashing in `wp_trash_post()` and `wp_untrash_post()`
----------------------------------------+------------------------------
 Reporter:  Denis-de-Bernardy           |       Owner:
     Type:  defect (bug)                |      Status:  new
 Priority:  normal                      |   Milestone:  Awaiting Review
Component:  Posts, Post Types           |     Version:  2.9
 Severity:  major                       |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:
----------------------------------------+------------------------------

Comment (by dmenard):

 Hi!

 We're experiencing this bug too.

 In our case, we're storing JSON snippets in `post_excerpt`/`post_content`
 and when a post is trashed (and then untrashed), the json becomes invalid
 because the backslashes are removed by wp_trash_post().

 The patch by Denis (just two lines) solves the problem, so I have uploaded
 a phpunit test which shows the problem and fails with current code:

 {{{
 $ phpunit tests/phpunit/tests/post/slashes.php

 1) Tests_Post_Slashes::test_wp_trash_untrash
 Failed asserting that two strings are equal.
 --- Expected
 +++ Actual
 @@ @@
 -'String with 1 slash \'
 +'String with 1 slash '

 \wordpress-develop\tests\phpunit\tests\post\slashes.php:145

 FAILURES!
 Tests: 4, Assertions: 19, Failures: 1.
 }}}

 And I have refreshed Denis patch against current trunk:

 {{{
 $ phpunit tests/phpunit/tests/post/slashes.php

 OK (4 tests, 24 assertions)
 }}}

 This is my first try at contributing to WordPress, hope I did it right...

 It would be great to get this bug fixed!

 Cheers

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


More information about the wp-trac mailing list