WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/20/2014 01:51:38 AM (6 years ago)
Author:
boonebgorges
Message:

Return an empty array from get_approved_comments() when $post_id is empty.

This behavior was broken when moving the internals to WP_Comment_Query in
[30098]. As a result, get_approved_comments( 0 ) was fetching *all* approved
comments, causing performance issues.

Props dd32.
Fixes #30412.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r30281 r30402  
    137137 *                             argument is true.
    138138 */
    139 function get_approved_comments( $post_id = 0, $args = array() ) {
     139function get_approved_comments( $post_id, $args = array() ) {
     140    if ( ! $post_id ) {
     141        return array();
     142    }
     143
    140144    $defaults = array(
    141145        'status'  => 1,
Note: See TracChangeset for help on using the changeset viewer.