Ticket #39000: 39000.diff
File 39000.diff, 2.1 KB (added by , 8 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
92 92 'reassign' => array( 93 93 'type' => 'integer', 94 94 'description' => __( 'Reassign the deleted user\'s posts and links to this user ID.' ), 95 'required' => true, 96 'sanitize_callback' => array( $this, 'check_reassign' ), 95 97 ), 96 98 ), 97 99 ), … … 125 127 'reassign' => array( 126 128 'type' => 'integer', 127 129 'description' => __( 'Reassign the deleted user\'s posts and links to this user ID.' ), 130 'required' => true, 131 'sanitize_callback' => array( $this, 'check_reassign' ), 128 132 ), 129 133 ), 130 134 ), … … 133 137 } 134 138 135 139 /** 140 * Checks for a valid value for the reassign parameter when deleting users. 141 * 142 * @since 4.7.0 143 * 144 * @param $value 145 * @param $request 146 * @param $param 147 * 148 * @return int|WP_Error 149 */ 150 public function check_reassign( $value, $request, $param ) { 151 if ( null === $value || is_numeric( $value ) ) { 152 return $value; 153 } 154 155 return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 444 ) ); 156 } 157 158 /** 136 159 * Permissions check for getting all users. 137 160 * 138 161 * @since 4.7.0 -
tests/phpunit/tests/rest-api/rest-users-controller.php
1639 1639 1640 1640 $userdata = get_userdata( $user_id ); // cache for later 1641 1641 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) ); 1642 $request['force'] = true; 1642 $request->set_param( 'force', true ); 1643 $request->set_param( 'reassign', null ); 1643 1644 $response = $this->server->dispatch( $request ); 1644 1645 1645 1646 $this->assertEquals( 200, $response->get_status() );