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

WordPress Trac noreply at wordpress.org
Fri Sep 25 05:46:03 UTC 2015


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

 * keywords:  has-patch needs-testing dev-feedback => needs-patch


Comment:

 We can't start returning `WP_Error` objects from `wp_insert_comment()`.
 It'll break any plugin doing something like

 {{{
 $comment_id = wp_insert_comment( $args );
 if ( ! $comment_id ) {
     $weep = true;
 }
 }}}

 If we want to have some more elegant and informative error handling, we'll
 need to do it in a new function, and turn `wp_insert_comment()` into a
 wrapper for it.

 Two other possible courses of action: (1) Simply return false when no
 comment_post_ID is present. (2) Do nothing, and leave it as-is, since it
 doesn't look like there's a functional bug here.

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


More information about the wp-trac mailing list