FIX : param $protection - Deep counter to avoid infinite loop

This commit is contained in:
gauthier 2016-10-20 13:30:47 +02:00
parent d85dd69184
commit 9a3d4031c5

View File

@ -620,17 +620,20 @@ class Entrepot extends CommonObject
/** /**
* Return full path to current warehouse * 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; global $user,$langs,$conf;
$TArbo = array($this->libelle); $TArbo = array($this->libelle);
$id = $this->id; $id = $this->id;
$i=0;
while(true) { while((empty($protection) || $i < $protection)) {
$sql = 'SELECT fk_parent $sql = 'SELECT fk_parent
FROM '.MAIN_DB_PREFIX.'entrepot FROM '.MAIN_DB_PREFIX.'entrepot
WHERE rowid = '.$id; WHERE rowid = '.$id;
@ -644,6 +647,9 @@ class Entrepot extends CommonObject
$o->fetch($id); $o->fetch($id);
$TArbo[] = $o->libelle; $TArbo[] = $o->libelle;
} else break; } else break;
$i++;
} }
return implode(' >> ', array_reverse($TArbo)); return implode(' >> ', array_reverse($TArbo));