mirror of
https://github.com/Automattic/wordpress-activitypub
synced 2024-10-18 15:43:32 +00:00
Merge branch 'master' of https://github.com/Automattic/wordpress-activitypub
This commit is contained in:
commit
8104463928
1 changed files with 7 additions and 5 deletions
|
@ -876,18 +876,20 @@ function get_comment_ancestors( $comment ) {
|
|||
|
||||
$ancestors = array();
|
||||
|
||||
$id = $comment->comment_parent;
|
||||
$id = (int) $comment->comment_parent;
|
||||
$ancestors[] = $id;
|
||||
|
||||
// phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
|
||||
while ( $ancestor = \get_comment( $id ) ) {
|
||||
while ( $id > 0 ) {
|
||||
$ancestor = \get_comment( $id );
|
||||
$parent_id = (int) $ancestor->comment_parent;
|
||||
|
||||
// Loop detection: If the ancestor has been seen before, break.
|
||||
// phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
|
||||
if ( empty( $ancestor->comment_parent ) || ( $ancestor->comment_parent == $comment->comment_ID ) || in_array( $ancestor->comment_parent, $ancestors, true ) ) {
|
||||
if ( empty( $parent_id ) || ( $parent_id === (int) $comment->comment_ID ) || in_array( $parent_id, $ancestors, true ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
$id = $comment->comment_parent;
|
||||
$id = $parent_id;
|
||||
$ancestors[] = $id;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue