Ticket #38962: 38962.3.diff
File 38962.3.diff, 4.0 KB (added by , 8 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
701 701 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. 702 702 */ 703 703 public function delete_item( $request ) { 704 // We don't support delete requests in multisite. 705 if ( is_multisite() ) { 706 return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 501 ) ); 707 } 708 704 709 $id = (int) $request['id']; 705 710 $reassign = false === $request['reassign'] ? null : absint( $request['reassign'] ); 706 711 $force = isset( $request['force'] ) ? (bool) $request['force'] : false; -
tests/phpunit/tests/rest-api/rest-users-controller.php
1643 1643 $request->set_param( 'reassign', false ); 1644 1644 $response = $this->server->dispatch( $request ); 1645 1645 1646 // Not implemented in multisite. 1647 if ( is_multisite() ) { 1648 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1649 return; 1650 } 1651 1646 1652 $this->assertEquals( 200, $response->get_status() ); 1647 1653 $data = $response->get_data(); 1648 1654 $this->assertTrue( $data['deleted'] ); … … 1660 1666 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) ); 1661 1667 $request->set_param( 'reassign', false ); 1662 1668 $response = $this->server->dispatch( $request ); 1669 1670 // Not implemented in multisite. 1671 if ( is_multisite() ) { 1672 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1673 return; 1674 } 1675 1663 1676 $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 ); 1664 1677 1665 1678 $request->set_param( 'force', 'false' ); … … 1683 1696 $request->set_param( 'reassign', false ); 1684 1697 $response = $this->server->dispatch( $request ); 1685 1698 1699 // Not implemented in multisite. 1700 if ( is_multisite() ) { 1701 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1702 return; 1703 } 1704 1686 1705 $this->assertEquals( 200, $response->get_status() ); 1687 1706 $data = $response->get_data(); 1688 1707 $this->assertTrue( $data['deleted'] ); … … 1699 1718 $request = new WP_REST_Request( 'DELETE', '/wp/v2/users/me' ); 1700 1719 $request->set_param( 'reassign', false ); 1701 1720 $response = $this->server->dispatch( $request ); 1721 1722 // Not implemented in multisite. 1723 if ( is_multisite() ) { 1724 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1725 return; 1726 } 1727 1702 1728 $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 ); 1703 1729 1704 1730 $request->set_param( 'force', 'false' ); … … 1740 1766 $request->set_param( 'reassign', false ); 1741 1767 $response = $this->server->dispatch( $request ); 1742 1768 1769 // Not implemented in multisite. 1770 if ( is_multisite() ) { 1771 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1772 return; 1773 } 1774 1743 1775 $this->assertErrorResponse( 'rest_user_invalid_id', $response, 404 ); 1744 1776 } 1745 1777 … … 1764 1796 $request->set_param( 'reassign', $reassign_id ); 1765 1797 $response = $this->server->dispatch( $request ); 1766 1798 1799 // Not implemented in multisite. 1800 if ( is_multisite() ) { 1801 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1802 return; 1803 } 1804 1767 1805 $this->assertEquals( 200, $response->get_status() ); 1768 1806 1769 1807 // Check that the post has been updated correctly … … 1782 1820 $request->set_param( 'reassign', 100 ); 1783 1821 $response = $this->server->dispatch( $request ); 1784 1822 1823 // Not implemented in multisite. 1824 if ( is_multisite() ) { 1825 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1826 return; 1827 } 1828 1785 1829 $this->assertErrorResponse( 'rest_user_invalid_reassign', $response, 400 ); 1786 1830 } 1787 1831