Ticket #38494: 38494.diff
File 38494.diff, 9.3 KB (added by , 9 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
726 726 727 727 $request->set_param( 'context', 'edit' ); 728 728 729 $ response= $this->prepare_item_for_response( $comment, $request );729 $previous = $this->prepare_item_for_response( $comment, $request ); 730 730 731 731 if ( $force ) { 732 732 $result = wp_delete_comment( $comment->comment_ID, true ); … … 747 747 return new WP_Error( 'rest_cannot_delete', __( 'The comment cannot be deleted.' ), array( 'status' => 500 ) ); 748 748 } 749 749 750 $response = new WP_REST_Response(); 751 $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data() ) ); 752 750 753 /** 751 754 * Fires after a comment is deleted via the REST API. 752 755 * -
src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
749 749 750 750 $request->set_param( 'context', 'edit' ); 751 751 752 $response = $this->prepare_item_for_response( $post, $request );753 752 754 753 // If we're forcing, then delete permanently. 755 754 if ( $force ) { 755 $previous = $this->prepare_item_for_response( $post, $request ); 756 756 $result = wp_delete_post( $id, true ); 757 $response = new WP_REST_Response(); 758 $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data() ) ); 757 759 } else { 758 760 // If we don't support trashing for this type, error out. 759 761 if ( ! $supports_trash ) { … … 768 770 // (Note that internally this falls through to `wp_delete_post` if 769 771 // the trash is disabled.) 770 772 $result = wp_trash_post( $id ); 773 $post = $this->get_post( $id ); 774 $response = $this->prepare_item_for_response( $post, $request ); 771 775 } 772 776 773 777 if ( ! $result ) { -
src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
220 220 * @return true|WP_Error True on success, or WP_Error object on failure. 221 221 */ 222 222 public function delete_item( $request ) { 223 $revision = $this->get_post( $request['id'] ); 224 $previous = $this->prepare_item_for_response( $revision, $request ); 225 223 226 $result = wp_delete_post( $request['id'], true ); 224 227 225 228 /** … … 234 237 */ 235 238 do_action( 'rest_delete_revision', $result, $request ); 236 239 237 if ( $result ) { 238 return true; 239 } else { 240 if ( ! $result ) { 240 241 return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) ); 241 242 } 243 244 $response = new WP_REST_Response(); 245 $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data() ) ); 246 return $response; 242 247 } 243 248 244 249 /** -
src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
573 573 574 574 $request->set_param( 'context', 'view' ); 575 575 576 $ response= $this->prepare_item_for_response( $term, $request );576 $previous = $this->prepare_item_for_response( $term, $request ); 577 577 578 578 $retval = wp_delete_term( $term->term_id, $term->taxonomy ); 579 579 … … 581 581 return new WP_Error( 'rest_cannot_delete', __( 'The resource cannot be deleted.' ), array( 'status' => 500 ) ); 582 582 } 583 583 584 $response = new WP_REST_Response(); 585 $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data() ) ); 586 584 587 /** 585 588 * Fires after a single term is deleted via the REST API. 586 589 * -
src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
620 620 621 621 $request->set_param( 'context', 'edit' ); 622 622 623 $ response= $this->prepare_item_for_response( $user, $request );623 $previous = $this->prepare_item_for_response( $user, $request ); 624 624 625 625 /** Include admin user functions to get access to wp_delete_user() */ 626 626 require_once ABSPATH . 'wp-admin/includes/user.php'; … … 631 631 return new WP_Error( 'rest_cannot_delete', __( 'The resource cannot be deleted.' ), array( 'status' => 500 ) ); 632 632 } 633 633 634 $response = new WP_REST_Response(); 635 $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data() ) ); 636 634 637 /** 635 638 * Fires immediately after a user is deleted via the REST API. 636 639 * -
tests/phpunit/tests/rest-api/rest-categories-controller.php
716 716 $response = $this->server->dispatch( $request ); 717 717 $this->assertEquals( 200, $response->get_status() ); 718 718 $data = $response->get_data(); 719 $this->assertEquals( 'Deleted Category', $data['name'] ); 719 $this->assertTrue( $data['deleted'] ); 720 $this->assertEquals( 'Deleted Category', $data['previous']['name'] ); 720 721 } 721 722 722 723 public function test_delete_item_force_false() { -
tests/phpunit/tests/rest-api/rest-comments-controller.php
1622 1622 $response = $this->server->dispatch( $request ); 1623 1623 $this->assertEquals( 200, $response->get_status() ); 1624 1624 $data = $response->get_data(); 1625 $this->assertEquals( self::$post_id, $data['post'] ); 1625 $this->assertTrue( $data['deleted'] ); 1626 $this->assertEquals( self::$post_id, $data['previous']['post'] ); 1626 1627 } 1627 1628 1628 1629 public function test_delete_item_skip_trash() { … … 1639 1640 $response = $this->server->dispatch( $request ); 1640 1641 $this->assertEquals( 200, $response->get_status() ); 1641 1642 $data = $response->get_data(); 1642 $this->assertEquals( self::$post_id, $data['post'] ); 1643 $this->assertTrue( $data['deleted'] ); 1644 $this->assertNotEmpty( $data['previous']['post'] ); 1643 1645 } 1644 1646 1645 1647 public function test_delete_item_already_trashed() { -
tests/phpunit/tests/rest-api/rest-posts-controller.php
1830 1830 $this->assertEquals( 200, $response->get_status() ); 1831 1831 $data = $response->get_data(); 1832 1832 $this->assertEquals( 'Deleted post', $data['title']['raw'] ); 1833 $this->assertEquals( 'trash', $data['status'] ); 1833 1834 } 1834 1835 1835 1836 public function test_delete_item_skip_trash() { … … 1843 1844 $this->assertNotInstanceOf( 'WP_Error', $response ); 1844 1845 $this->assertEquals( 200, $response->get_status() ); 1845 1846 $data = $response->get_data(); 1846 $this->assertEquals( 'Deleted post', $data['title']['raw'] ); 1847 $this->assertTrue( $data['deleted'] ); 1848 $this->assertNotEmpty( $data['previous'] ); 1847 1849 } 1848 1850 1849 1851 public function test_delete_item_already_trashed() { -
tests/phpunit/tests/rest-api/rest-tags-controller.php
599 599 $response = $this->server->dispatch( $request ); 600 600 $this->assertEquals( 200, $response->get_status() ); 601 601 $data = $response->get_data(); 602 $this->assertEquals( 'Deleted Tag', $data['name'] ); 602 $this->assertTrue( $data['deleted'] ); 603 $this->assertEquals( 'Deleted Tag', $data['previous']['name'] ); 603 604 } 604 605 605 606 public function test_delete_item_force_false() { … … 641 642 642 643 $this->assertEquals( 200, $response->get_status() ); 643 644 $data = $response->get_data(); 644 $this->assertEquals( 'Deleted Tag', $data['name'] ); 645 $this->assertTrue( $data['deleted'] ); 646 $this->assertEquals( 'Deleted Tag', $data['previous']['name'] ); 645 647 } 646 648 647 649 public function grant_delete_term( $caps, $cap ) { -
tests/phpunit/tests/rest-api/rest-users-controller.php
1048 1048 1049 1049 $this->assertEquals( 200, $response->get_status() ); 1050 1050 $data = $response->get_data(); 1051 $this->assertEquals( 'Deleted User', $data['name'] ); 1051 $this->assertTrue( $data['deleted'] ); 1052 $this->assertEquals( 'Deleted User', $data['previous']['name'] ); 1052 1053 } 1053 1054 1054 1055 public function test_delete_item_no_trash() {