[wp-trac] [WordPress Trac] #34977: When updating a Comment do not call `wp_update_comment_count` if there is no related Post
WordPress Trac
noreply at wordpress.org
Fri Dec 11 16:34:34 UTC 2015
#34977: When updating a Comment do not call `wp_update_comment_count` if there is
no related Post
----------------------------------------+--------------------------
Reporter: rachelbaker | Owner: rachelbaker
Type: enhancement | Status: reviewing
Priority: normal | Milestone: 4.5
Component: Comments | Version:
Severity: normal | Resolution:
Keywords: good-first-bug needs-patch | Focuses:
----------------------------------------+--------------------------
Comment (by rachelbaker):
As I dug more into this I found that this bug had a slightly larger scope.
Currently '''only''' `wp_delete_comment()` does check if the
`comment_post_ID` is valid (as in returns a WP_Post object from
`get_post()`) before calling `wp_update_comment_count()`. Instead of
adding a bunch of conditional checks before calling that function, it
would be cleaner to do the check in the `wp_update_comment_count()`
function itself, and return early if there is no post.
We will need to be careful when doing this because
`wp_defer_comment_counting()` actually intentionally passes `null` for the
`$post_id` param.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34977#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list