Skip to content

Commit 4c0cc8a

Browse files
Include all decendents, return success status
1 parent d6cf076 commit 4c0cc8a

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/wp-includes/comment.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ function wp_trash_comment( $comment_id ) {
16191619

16201620
// For top level 'note' type comments, also trash any children as well.
16211621
if ( 'note' === $comment->comment_type && 0 === (int) $comment->comment_parent ) {
1622-
wp_trash_comment_children( $comment->comment_ID );
1622+
wp_trash_note_descendants( $comment->comment_ID );
16231623
}
16241624

16251625
return true;
@@ -1629,24 +1629,33 @@ function wp_trash_comment( $comment_id ) {
16291629
}
16301630

16311631
/**
1632-
* Delete all of a note's children (replies).
1632+
* Trash all of a note's descendants (replies).
16331633
*
16341634
* @since 6.9.0
16351635
*
16361636
* @param int $comment_id The comment ID.
1637+
* @return bool Whether the descendants were successfully trashed.
16371638
*/
1638-
function wp_trash_comment_children( $comment_id ) {
1639-
$children = get_comments(
1639+
function wp_trash_note_descendants( $comment_id ) {
1640+
$comment = get_comment( $comment_id );
1641+
if ( ! $comment ) {
1642+
return false;
1643+
}
1644+
$children = $comment->get_children(
16401645
array(
1641-
'parent' => $comment_id,
1646+
'fields' => 'ids',
16421647
'status' => 'all',
16431648
'type' => 'note',
1644-
'fields' => 'ids',
16451649
)
16461650
);
1651+
1652+
$success = true;
16471653
foreach ( $children as $child_id ) {
1648-
wp_trash_comment( $child_id );
1654+
if ( ! wp_trash_comment( $child_id ) ) {
1655+
$success = false;
1656+
}
16491657
}
1658+
return $success;
16501659
}
16511660

16521661
/**

0 commit comments

Comments
 (0)