[wp-trac] [WordPress Trac] #65050: REST API: Comments controller returns 403 instead of 404 for invalid post ID in update_item()

WordPress Trac noreply at wordpress.org
Sun May 3 19:30:07 UTC 2026


#65050: REST API: Comments controller returns 403 instead of 404 for invalid post
ID in update_item()
-----------------------------------------+-------------------------------
 Reporter:  saratheonline                |       Owner:  saratheonline
     Type:  defect (bug)                 |      Status:  assigned
 Priority:  normal                       |   Milestone:  7.1
Component:  REST API                     |     Version:  trunk
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch changes-requested  |     Focuses:  coding-standards
-----------------------------------------+-------------------------------

Comment (by yusufmudagal):

 Tested PR https://github.com/WordPress/wordpress-develop/pull/11529

 I created a post and comment locally, then called
 `WP_REST_Comments_Controller::update_item()` with that comment ID and
 `post => 999999`.

 Before the patch, the response was `rest_comment_invalid_post_id` with
 status `403`.
 After the patch, the same error code returns status `404`.

 This matches the behavior in `get_item()` and looks correct to me. Patch
 tests well.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65050#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list