Changeset 39438
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r39426 r39438 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'] ); -
trunk/tests/phpunit/tests/rest-api/rest-users-controller.php
r39426 r39438 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(); … … 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 … … 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(); … … 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 … … 1740 1766 $request->set_param( 'reassign', false ); 1741 1767 $response = $this->server->dispatch( $request ); 1768 1769 // Not implemented in multisite. 1770 if ( is_multisite() ) { 1771 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1772 return; 1773 } 1742 1774 1743 1775 $this->assertErrorResponse( 'rest_user_invalid_id', $response, 404 ); … … 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 … … 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 } … … 1813 1857 $request['force'] = true; 1814 1858 $request->set_param( 'reassign', false ); 1815 $this->server->dispatch( $request ); 1859 $response = $this->server->dispatch( $request ); 1860 1861 // Not implemented in multisite. 1862 if ( is_multisite() ) { 1863 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1864 return; 1865 } 1816 1866 1817 1867 $test_post = get_post( $test_post ); … … 1832 1882 $request['force'] = true; 1833 1883 $request->set_param( 'reassign', 'false' ); 1834 $this->server->dispatch( $request ); 1884 $response = $this->server->dispatch( $request ); 1885 1886 // Not implemented in multisite. 1887 if ( is_multisite() ) { 1888 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1889 return; 1890 } 1835 1891 1836 1892 $test_post = get_post( $test_post ); … … 1851 1907 $request['force'] = true; 1852 1908 $request->set_param( 'reassign', '' ); 1853 $this->server->dispatch( $request ); 1909 $response = $this->server->dispatch( $request ); 1910 1911 // Not implemented in multisite. 1912 if ( is_multisite() ) { 1913 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1914 return; 1915 } 1854 1916 1855 1917 $test_post = get_post( $test_post ); … … 1870 1932 $request['force'] = true; 1871 1933 $request->set_param( 'reassign', 0 ); 1872 $this->server->dispatch( $request ); 1934 $response = $this->server->dispatch( $request ); 1935 1936 // Not implemented in multisite. 1937 if ( is_multisite() ) { 1938 $this->assertErrorResponse( 'rest_cannot_delete', $response, 501 ); 1939 return; 1940 } 1873 1941 1874 1942 $test_post = get_post( $test_post );
Note: See TracChangeset
for help on using the changeset viewer.