Skip to content

Commit dd907ab

Browse files
REST API: Fix incorrect 403 status code for invalid post ID in Comments controller.
`update_item()` was returning HTTP 403 (Forbidden) when a non-existent post ID was provided. The correct status is 404 (Not Found), as the resource is missing — not access-restricted. This also makes `update_item()` consistent with `get_item()` in the same controller, which already returns 404 for the same scenario.
1 parent e12ddb3 commit dd907ab

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ public function update_item( $request ) {
920920
return new WP_Error(
921921
'rest_comment_invalid_post_id',
922922
__( 'Invalid post ID.' ),
923-
array( 'status' => 403 )
923+
array( 'status' => 404 )
924924
);
925925
}
926926
}

0 commit comments

Comments
 (0)