Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Commit

Permalink
Merge branch 'antisilent-2398-error-codes' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelbaker committed Jul 31, 2016
2 parents 549581d + 565b9a7 commit c661101
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/endpoints/class-wp-rest-posts-controller.php
Expand Up @@ -395,7 +395,7 @@ public function update_item( $request ) {
$post = $this->get_post( $id );

if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
return new WP_Error( 'rest_post_invalid_id', __( 'Post id is invalid.' ), array( 'status' => 400 ) );
return new WP_Error( 'rest_post_invalid_id', __( 'Post id is invalid.' ), array( 'status' => 404 ) );
}

$post = $this->prepare_item_for_database( $request );
Expand Down
4 changes: 2 additions & 2 deletions lib/endpoints/class-wp-rest-users-controller.php
Expand Up @@ -374,7 +374,7 @@ public function update_item( $request ) {

$user = get_userdata( $id );
if ( ! $user ) {
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource id.' ), array( 'status' => 400 ) );
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource id.' ), array( 'status' => 404 ) );
}

if ( email_exists( $request['email'] ) && $request['email'] !== $user->user_email ) {
Expand Down Expand Up @@ -457,7 +457,7 @@ public function delete_item( $request ) {

$user = get_userdata( $id );
if ( ! $user ) {
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource id.' ), array( 'status' => 400 ) );
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource id.' ), array( 'status' => 404 ) );
}

if ( ! empty( $reassign ) ) {
Expand Down
4 changes: 2 additions & 2 deletions tests/test-rest-posts-controller.php
Expand Up @@ -1241,7 +1241,7 @@ public function test_update_post_invalid_id() {
$request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ) );
$response = $this->server->dispatch( $request );

$this->assertErrorResponse( 'rest_post_invalid_id', $response, 400 );
$this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 );
}

public function test_update_post_invalid_route() {
Expand All @@ -1250,7 +1250,7 @@ public function test_update_post_invalid_route() {
$request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/pages/%d', $this->post_id ) );
$response = $this->server->dispatch( $request );

$this->assertErrorResponse( 'rest_post_invalid_id', $response, 400 );
$this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 );
}

public function test_update_post_with_format() {
Expand Down
4 changes: 2 additions & 2 deletions tests/test-rest-users-controller.php
Expand Up @@ -905,7 +905,7 @@ public function test_update_user_invalid_id() {
$request->set_body_params( $params );
$response = $this->server->dispatch( $request );

$this->assertErrorResponse( 'rest_user_invalid_id', $response, 400 );
$this->assertErrorResponse( 'rest_user_invalid_id', $response, 404 );
}

public function test_delete_item() {
Expand Down Expand Up @@ -961,7 +961,7 @@ public function test_delete_user_invalid_id() {
$request['force'] = true;
$response = $this->server->dispatch( $request );

$this->assertErrorResponse( 'rest_user_invalid_id', $response, 400 );
$this->assertErrorResponse( 'rest_user_invalid_id', $response, 404 );
}

public function test_delete_user_reassign() {
Expand Down

0 comments on commit c661101

Please sign in to comment.