WordPress.org

Make WordPress Core

Ticket #38494: return-updated-post-on-trash.diff

File return-updated-post-on-trash.diff, 1.7 KB (added by timmydcrawford, 3 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

     
    754754                // If we're forcing, then delete permanently.
    755755                if ( $force ) {
    756756                        $result = wp_delete_post( $id, true );
     757                        $response = true;
    757758                } else {
    758759                        // If we don't support trashing for this type, error out.
    759760                        if ( ! $supports_trash ) {
     
    768769                        // (Note that internally this falls through to `wp_delete_post` if
    769770                        // the trash is disabled.)
    770771                        $result = wp_trash_post( $id );
     772                        $post = $this->get_post( $id );
     773                        $response = $this->prepare_item_for_response( $post, $request );
    771774                }
    772775
    773776                if ( ! $result ) {
  • tests/phpunit/tests/rest-api/rest-posts-controller.php

     
    17811781                $this->assertEquals( 200, $response->get_status() );
    17821782                $data = $response->get_data();
    17831783                $this->assertEquals( 'Deleted post', $data['title']['raw'] );
     1784                $this->assertEquals( 'trash', $data['status'] );
    17841785        }
    17851786
    17861787        public function test_delete_item_skip_trash() {
     
    17931794
    17941795                $this->assertNotInstanceOf( 'WP_Error', $response );
    17951796                $this->assertEquals( 200, $response->get_status() );
    1796                 $data = $response->get_data();
    1797                 $this->assertEquals( 'Deleted post', $data['title']['raw'] );
     1797                $this->assertTrue( $response->get_data() );
    17981798        }
    17991799
    18001800        public function test_delete_item_already_trashed() {