[wp-trac] [WordPress Trac] #23931: wp_insert_comment should require comment_post_ID

WordPress Trac noreply at wordpress.org
Tue Feb 21 20:07:06 UTC 2023


#23931: wp_insert_comment should require comment_post_ID
-------------------------------+---------------------
 Reporter:  markoheijnen       |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:
Component:  Comments           |     Version:  2.0
 Severity:  normal             |  Resolution:
 Keywords:  needs-patch close  |     Focuses:
-------------------------------+---------------------

Comment (by costdev):

 I'm inclined to agree with @rachelbaker here. While most cases involve a
 comment with a relationship to a post, it's entirely possible that the
 desired behaviour is that a comment could be inserted without having a
 relationship with a post.

 Some thoughts:
 - "Comments" is its own menu item. It's not nested under "Posts", "Pages",
 or both.
 - Most comment functions that deal with a post ID are within `comment-
 template.php`, which is specifically for use within the loop.
 - For comments that are post-independent, a relationship to a post is not
 desired. If a relationship to a post was required by WP, deleting that
 post would also delete its comments.
 - As an example, a contact form can be created by adding a form to a page
 that submits comments. This doesn't need a plugin that uses custom post
 types and such, as the Comments API provides all that's needed (email,
 custom comment types, etc). For this ''type'' of available usage, there's
 no need for a relationship to a post.

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


More information about the wp-trac mailing list