[wp-trac] [WordPress Trac] #43599: WP is asking for comment count for post 0
WordPress Trac
noreply at wordpress.org
Wed Mar 21 10:19:11 UTC 2018
#43599: WP is asking for comment count for post 0
-------------------------------+-----------------------------
Reporter: Grzegorz.Janoszka | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: 4.9.5
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
In wp-includes/comment.php we have a function wp_count_comments defined:
function wp_count_comments( $post_id = 0 )
so by default $post_id is 0.
Later on in the function we query the cache:
$count = wp_cache_get( "comments-{$post_id}", 'counts' );
We shouldn't query the cache for such number if post_id is 0 as we will
never get a value from the cache, so I suggest adding "if ($post_id) then"
before querying the cache. It might be that more of this function code
should be included in such if, being void for post_id equal to 0 (and
there are such calls).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43599>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list