From 66ed4aa5245995a70dfdc1ca4efc0560a5a17fd4 Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Mon, 11 Jul 2022 14:04:31 +0200 Subject: [PATCH] refixing the bug --- htdocs/product/class/product.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fd0d165dc86..7557f7eb77b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4681,7 +4681,17 @@ class Product extends CommonObject while ($rec = $this->db->fetch_array($res)) { if (!empty($alreadyfound[$rec['rowid']])) { dol_syslog(get_class($this).'::getChildsArbo the product id='.$rec['rowid'].' was already found at a higher level in tree. We discard to avoid infinite loop', LOG_WARNING); - //continue; + $hasParentInSamePath = false; + while (($fathers = $rec['rowid']->getFather()) != -1) { + foreach ($fathers as $father) { + if ($father['rowid'] == $id) { + $hasParentInSamePath = true; + break; + } + } + } + if ($hasParentInSamePath) + continue; // We discard this child if it is already found at a higher level in tree in the same branch. } $alreadyfound[$rec['rowid']] = 1; $prods[$rec['rowid']] = array(