PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | json-endpoints/class.wpcom-json-api-list-comments-endpoint.php +13 -4 16.3-a.7 → 16.3-beta View file →
@@ -317,12 +317,8 @@
317 317 $query['date_query']['after'] = $args['after_gmt'];
318 318 }
319 319 }
320 320 }
321 - if ( $args['hierarchical'] && $found > 5000 ) {
322 - // Massive comment thread found; don't pre-load comment metadata to reduce memory used.
323 - $query['update_comment_meta_cache'] = false;
324 - }
325 321
326 322 if ( $post_id ) {
327 323 $post = get_post( $post_id );
328 324 if ( ! $post || is_wp_error( $post ) ) {
@@ -337,8 +333,21 @@
337 333 if ( ! $comment || is_wp_error( $comment ) ) {
338 334 return new WP_Error( 'unknown_comment', 'Unknown comment', 404 );
339 335 }
340 336 $query['parent'] = $comment_id;
337 + }
338 +
339 + // A single post's count uses the comment_post_ID index; site-wide typed counts would not.
340 + if ( -1 === $found && $post_id ) {
341 + $count_query = $query;
342 + $count_query['count'] = true;
343 + unset( $count_query['number'], $count_query['offset'] );
344 + $found = (int) get_comments( $count_query );
345 + }
346 +
347 + if ( $args['hierarchical'] && $found > 5000 ) {
348 + // Massive comment thread found; don't pre-load comment metadata to reduce memory used.
349 + $query['update_comment_meta_cache'] = false;
341 350 }
342 351
343 352 $comments = get_comments( $query );
344 353