Ticket #38962: 38962.2.diff
File 38962.2.diff, 3.7 KB (added by , 8 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
672 672 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. 673 673 */ 674 674 public function delete_item( $request ) { 675 // We don't support delete requests in multisite. 676 if ( is_multisite() ) { 677 return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 501 ) ); 678 } 679 675 680 $id = (int) $request['id']; 676 681 $reassign = isset( $request['reassign'] ) ? absint( $request['reassign'] ) : null; 677 682 $force = isset( $request['force'] ) ? (bool) $request['force'] : false; -
tests/phpunit/tests/rest-api/rest-users-controller.php
1642 1642 $request['force'] = true; 1643 1643 $response = $this->server->dispatch( $request ); 1644 1644 1645 // Not implemented in multisite. 1646 if ( is_multisite() ) { 1647 $this->assertEquals( 501, $response->get_status() ); 1648 return; 1649 } 1650 1645 1651 $this->assertEquals( 200, $response->get_status() ); 1646 1652 $data = $response->get_data(); 1647 1653 $this->assertTrue( $data['deleted'] ); … … 1658 1664 1659 1665 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) ); 1660 1666 $response = $this->server->dispatch( $request ); 1667 1668 // Not implemented in multisite. 1669 if ( is_multisite() ) { 1670 $this->assertEquals( 501, $response->get_status() ); 1671 return; 1672 } 1673 1661 1674 $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 ); 1662 1675 1663 1676 $request->set_param( 'force', 'false' ); … … 1680 1693 $request['force'] = true; 1681 1694 $response = $this->server->dispatch( $request ); 1682 1695 1696 // Not implemented in multisite. 1697 if ( is_multisite() ) { 1698 $this->assertEquals( 501, $response->get_status() ); 1699 return; 1700 } 1701 1683 1702 $this->assertEquals( 200, $response->get_status() ); 1684 1703 $data = $response->get_data(); 1685 1704 $this->assertTrue( $data['deleted'] ); … … 1695 1714 1696 1715 $request = new WP_REST_Request( 'DELETE', '/wp/v2/users/me' ); 1697 1716 $response = $this->server->dispatch( $request ); 1717 1718 // Not implemented in multisite. 1719 if ( is_multisite() ) { 1720 $this->assertEquals( 501, $response->get_status() ); 1721 return; 1722 } 1723 1698 1724 $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 ); 1699 1725 1700 1726 $request->set_param( 'force', 'false' ); … … 1733 1759 $request['force'] = true; 1734 1760 $response = $this->server->dispatch( $request ); 1735 1761 1762 // Not implemented in multisite. 1763 if ( is_multisite() ) { 1764 $this->assertEquals( 501, $response->get_status() ); 1765 return; 1766 } 1767 1736 1768 $this->assertErrorResponse( 'rest_user_invalid_id', $response, 404 ); 1737 1769 } 1738 1770 … … 1757 1789 $request->set_param( 'reassign', $reassign_id ); 1758 1790 $response = $this->server->dispatch( $request ); 1759 1791 1792 // Not implemented in multisite. 1793 if ( is_multisite() ) { 1794 $this->assertEquals( 501, $response->get_status() ); 1795 return; 1796 } 1797 1760 1798 $this->assertEquals( 200, $response->get_status() ); 1761 1799 1762 1800 // Check that the post has been updated correctly … … 1775 1813 $request->set_param( 'reassign', 100 ); 1776 1814 $response = $this->server->dispatch( $request ); 1777 1815 1816 // Not implemented in multisite. 1817 if ( is_multisite() ) { 1818 $this->assertEquals( 501, $response->get_status() ); 1819 return; 1820 } 1821 1778 1822 $this->assertErrorResponse( 'rest_user_invalid_reassign', $response, 400 ); 1779 1823 } 1780 1824