From a827ce812279fe2cbe94239b3a345a1ec34143e6 Mon Sep 17 00:00:00 2001 From: Rebecca Hum <16962021+rebeccahum@users.noreply.github.com> Date: Mon, 28 Mar 2022 11:08:46 -0600 Subject: [PATCH 1/2] get_term_tree(): fix infinite loop for non-existent parent --- includes/utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/utils.php b/includes/utils.php index 3153269a7d..f48ddd6100 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -353,7 +353,7 @@ function get_term_tree( $all_terms, $orderby = 'count', $order = 'desc', $flat = $terms_map[ $term->term_id ] = $term; } - if ( empty( $term->parent ) ) { + if ( empty( $term->parent ) || ( ! empty( $term->parent ) && ! term_exists( $term->parent, $term->taxonomy ) ) ) { $term->level = 0; if ( empty( $orderby ) ) { From 849a60f97c0b26a029d81ce1b86ade09e500e227 Mon Sep 17 00:00:00 2001 From: Rebecca Hum <16962021+rebeccahum@users.noreply.github.com> Date: Mon, 28 Mar 2022 11:31:32 -0600 Subject: [PATCH 2/2] Remove first condition on second check --- includes/utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/utils.php b/includes/utils.php index f48ddd6100..c40452f992 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -353,7 +353,7 @@ function get_term_tree( $all_terms, $orderby = 'count', $order = 'desc', $flat = $terms_map[ $term->term_id ] = $term; } - if ( empty( $term->parent ) || ( ! empty( $term->parent ) && ! term_exists( $term->parent, $term->taxonomy ) ) ) { + if ( empty( $term->parent ) || ! term_exists( $term->parent, $term->taxonomy ) ) { $term->level = 0; if ( empty( $orderby ) ) {