From 9a3d4031c5dd6aa8d59bacac4ed6fc1a67736d93 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 20 Oct 2016 13:30:47 +0200 Subject: [PATCH] FIX : param $protection - Deep counter to avoid infinite loop --- htdocs/product/stock/class/entrepot.class.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 109460cfa1a..da39522126a 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -620,17 +620,20 @@ class Entrepot extends CommonObject /** * Return full path to current warehouse * - * @return string String full path to current warehouse separated by " >> " + * @param int $protection Deep counter to avoid infinite loop + * @return string String full path to current warehouse separated by " >> " */ - function get_full_arbo() { + function get_full_arbo($protection=1000) { global $user,$langs,$conf; $TArbo = array($this->libelle); $id = $this->id; + + $i=0; - while(true) { + while((empty($protection) || $i < $protection)) { $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.$id; @@ -644,6 +647,9 @@ class Entrepot extends CommonObject $o->fetch($id); $TArbo[] = $o->libelle; } else break; + + $i++; + } return implode(' >> ', array_reverse($TArbo));