mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 15:31:42 +01:00
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. Built from https://develop.svn.wordpress.org/trunk@30402 git-svn-id: http://core.svn.wordpress.org/trunk@30397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f17d168a0f
commit
e2339bdb1b
@ -136,7 +136,11 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
|
|||||||
* @return int|array $comments The approved comments, or number of comments if `$count`
|
* @return int|array $comments The approved comments, or number of comments if `$count`
|
||||||
* argument is true.
|
* argument is true.
|
||||||
*/
|
*/
|
||||||
function get_approved_comments( $post_id = 0, $args = array() ) {
|
function get_approved_comments( $post_id, $args = array() ) {
|
||||||
|
if ( ! $post_id ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'post_id' => $post_id,
|
'post_id' => $post_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user