Opened 10 years ago
Closed 10 years ago
#30944 closed defect (bug) (duplicate)
wp_insert_comment() allows to insert a comment with wrong or missing post ID
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.1 |
Component: | Comments | Keywords: | |
Focuses: | Cc: |
Description
Currently wp_insert_comment()
allows the insertion of a comment with no post ID
specified, or with an invalid post ID
(one that does not correspond to a valid post).
So the following use case:
wp_insert_comment( array() );
creates a comment with post ID
0
, and the following use case:
wp_insert_comment( array('comment_post_ID' => 999999) );
creates a comment with post ID
of 999999
(considering that 999999
does not correspond to a valid post).
Both of the created comments are invalid, as they "hang" in the middle of nowhere, attached to non-existing posts, and displaying weird results and errors in the Comments administration screen.
In order to fix this, the function should check the $comment_post_ID
, and if it is invalid, false
should be returned.
Change History (1)
Note: See
TracTickets for help on using
tickets.
Duplicate of #23931.