[wp-trac] [WordPress Trac] #38816: REST API: logic error in comments post ID

WordPress Trac noreply at wordpress.org
Thu Nov 17 02:21:58 UTC 2016


#38816: REST API: logic error in comments post ID
----------------------------------------+-----------------------
 Reporter:  dd32                        |       Owner:
     Type:  defect (bug)                |      Status:  new
 Priority:  normal                      |   Milestone:  4.7
Component:  Comments                    |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:  rest-api
----------------------------------------+-----------------------
Changes (by jnylen0):

 * keywords:  has-patch => has-patch needs-unit-tests


Comment:

 This is closely related to #38700.  Currently, creating a comment with an
 invalid post ID fails.  However, when updating a comment, this is caught
 in `wp_update_comment` which leads to a 500 error.

 > I'm not sure I understand the logic behind allowing comment creation for
 a non-existent post_id if the user has `moderate_comments` cap though

 I agree, we shouldn't support this either.

 I don't think this is a permissions issue, so it shouldn't be addressed in
 the `permission_callback`.  [attachment:38700.5.diff:ticket:38700
 38700.5.diff] fixes this for comment updates, and we should add this check
 in `create_item` also.

 Finally I think 404 is a better status code here.

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


More information about the wp-trac mailing list