Make WordPress Core

Changeset 34668


Ignore:
Timestamp:
09/28/2015 07:25:05 PM (9 years ago)
Author:
johnbillion
Message:

Correctly slash post fields when trashing and untrashing posts.

Fixes #27550
Props dmenard, Denis-de-Bernardy

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-functions.php

    r34566 r34668  
    25192519
    25202520    $post['post_status'] = 'trash';
    2521     wp_insert_post($post);
     2521    wp_insert_post( wp_slash( $post ) );
    25222522
    25232523    wp_trash_post_comments($post_id);
     
    25662566    delete_post_meta($post_id, '_wp_trash_meta_time');
    25672567
    2568     wp_insert_post($post);
     2568    wp_insert_post( wp_slash( $post ) );
    25692569
    25702570    wp_untrash_post_comments($post_id);
  • trunk/tests/phpunit/tests/post/slashes.php

    r31065 r34668  
    130130    }
    131131
     132    /**
     133     * @ticket 27550
     134     */
     135    function test_wp_trash_untrash() {
     136        $post = array(
     137            'post_title'   => $this->slash_1,
     138            'post_content' => $this->slash_3,
     139            'post_excerpt' => $this->slash_5,
     140        );
     141        $id = wp_insert_post( wp_slash( $post ) );
     142
     143        $trashed = wp_trash_post( $id );
     144        $this->assertNotEmpty( $trashed );
     145
     146        $post = get_post( $id );
     147
     148        $this->assertEquals( $this->slash_1, $post->post_title );
     149        $this->assertEquals( $this->slash_3, $post->post_content );
     150        $this->assertEquals( $this->slash_5, $post->post_excerpt );
     151
     152        $untrashed = wp_untrash_post( $id );
     153        $this->assertNotEmpty( $untrashed );
     154
     155        $post = get_post( $id );
     156
     157        $this->assertEquals( $this->slash_1, $post->post_title );
     158        $this->assertEquals( $this->slash_3, $post->post_content );
     159        $this->assertEquals( $this->slash_5, $post->post_excerpt );
     160    }
    132161}
Note: See TracChangeset for help on using the changeset viewer.