diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index eae452f542..771123ff5a 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/wp-includes/class-wp-comment-query.php @@ -833,10 +833,9 @@ class WP_Comment_Query { } } - $date_query = $this->query_vars['date_query']; - if ( ! empty( $date_query ) && is_array( $date_query ) ) { - $date_query_object = new WP_Date_Query( $date_query, 'comment_date' ); - $this->sql_clauses['where']['date_query'] = preg_replace( '/^\s*AND\s*/', '', $date_query_object->get_sql() ); + if ( ! empty( $this->query_vars['date_query'] ) && is_array( $this->query_vars['date_query'] ) ) { + $this->date_query = new WP_Date_Query( $this->query_vars['date_query'], 'comment_date' ); + $this->sql_clauses['where']['date_query'] = preg_replace( '/^\s*AND\s*/', '', $this->date_query->get_sql() ); } $where = implode( ' AND ', $this->sql_clauses['where'] );