-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: #26250 fatal error on kit #32674
base: 18.0
Are you sure you want to change the base?
Conversation
@@ -5016,7 +5016,8 @@ public function getChildsArbo($id, $firstlevelonly = 0, $level = 1, $parents = a | |||
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); | |||
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); | |||
if (empty($firstlevelonly)) { | |||
$listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, array_push($parents, $rec['rowid'])); | |||
array_push($parents, $rec['rowid']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see fix #26454
it was replaced with :
$parents[] = $rec['rowid'];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you try with theses changes ? (see "getChildsArbo()" function in "htdocs/product/class/product.class.php" of
https://github.com/Dolibarr/dolibarr/pull/27570/files)
`public function getChildsArbo($id, $firstlevelonly = 0, $level = 1, $parents = array())
{
if (empty($id)) {
return array();
}
$sql = "SELECT p.rowid, p.ref, p.label as label, p.fk_product_type,";
$sql .= " pa.qty as qty, pa.fk_product_fils as id, pa.incdec,";
$sql .= " pa.rowid as fk_association, pa.rang";
$sql .= " FROM ".$this->db->prefix()."product as p,";
$sql .= " ".$this->db->prefix()."product_association as pa";
$sql .= " WHERE p.rowid = pa.fk_product_fils";
$sql .= " AND pa.fk_product_pere = ".((int) $id);
$sql .= " AND pa.fk_product_fils <> ".((int) $id); // This should not happens, it is to avoid infinite loop if it happens
$sql .= " ORDER BY pa.rang";
dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level. ' parents='.(is_array($parents) ? implode(',', $parents) : $parents), LOG_DEBUG);
// Protection against infinite loop
if ($level > 30) {
return array();
}
$res = $this->db->query($sql);
if ($res) {
$prods = array();
if ($this->db->num_rows($res) > 0) {
$parents[] = $id;
}
while ($rec = $this->db->fetch_array($res)) {
if (in_array($rec['id'], $parents)) {
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; // We discard this child if it is already found at a higher level in tree in the same branch.
}
$prods[$rec['rowid']] = array(
0 => $rec['rowid'],
1 => $rec['qty'],
2 => $rec['fk_product_type'],
3 => $this->db->escape($rec['label']),
4 => $rec['incdec'],
5 => $rec['ref'],
6 => $rec['fk_association'],
7 => $rec['rang']
);
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']);
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']);
if (empty($firstlevelonly)) {
//$parents[] = $rec['rowid'];
$listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, $parents);
foreach ($listofchilds as $keyChild => $valueChild) {
$prods[$rec['rowid']]['childs'][$keyChild] = $valueChild;
}
}
}
return $prods;
} else {
dol_print_error($this->db);
return -1;
}
}`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @lvessiller-opendsi ,
Thanks for pointing to #26454, I updated patch to same solution.
Also tested your solution, works fine. Hope your shipment kit dispatcher V2 gets merged soon.
@rycks & @lvessiller-opendsi fatal error when kit child is also a parent.
#26250 was closed by robot