WordPress.org

Make WordPress Core

Ticket #36991: type_list_pagination.patch

File type_list_pagination.patch, 1.1 KB (added by rachelbaker, 5 years ago)

Don't use wp_count_comments if filtering by comment_type

  • src/wp-admin/includes/ajax-actions.php

     
    395395                                $status = $query_vars['comment_status'];
    396396                        if ( !empty( $query_vars['p'] ) )
    397397                                $post_id = (int) $query_vars['p'];
     398                        if ( ! empty( $query_vars['comment_type'] ) )
     399                                $type = $query_vars['comment_type'];
    398400                }
    399401
    400                 $comment_count = wp_count_comments($post_id);
     402                if ( empty( $type ) ) {
     403                        // Only use the comment count if not filtering by a comment_type.
     404                        $comment_count = wp_count_comments($post_id);
    401405
    402                 // We're looking for a known type of comment count.
    403                 if ( isset( $comment_count->$status ) )
    404                         $total = $comment_count->$status;
    405                         // Else use the decremented value from above.
     406                        // We're looking for a known type of comment count.
     407                        if ( isset( $comment_count->$status ) )
     408                                $total = $comment_count->$status;
     409                }
     410                // Else use the decremented value from above.
    406411        }
    407412
    408413        // The time since the last comment count.