[wp-trac] [WordPress Trac] #39730: Checking if wp_new_comment() return value is a WP_Error
WordPress Trac
noreply at wordpress.org
Sat Jan 28 17:21:28 UTC 2017
#39730: Checking if wp_new_comment() return value is a WP_Error
-------------------------------+-----------------------------
Reporter: enrico.sorcinelli | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
Since `wp_new_comment()` can return `WP_Error` (also it can be returned
through `pre_comments_approved` filter), we should check it in all call
occurrences.
This essentially affects adding new comments (via ajax) in post admin
where the result was a new empty comment (with anonymous avatar) with not
working links (since they don't have comment id).
I added the check before `get_comment($comment_id)` (*) call and comments
list building.
The patch also fix all other `wp_new_comment()` calls I found.
(*): In general, maybe should `WP_Comment` take care to the object passed
in the constructor by checking if it's a `WP_Error`
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39730>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list