diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 869a989e55d..aa53d92d6c6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2049,7 +2049,7 @@ abstract class CommonObject * * @param int $rowid Id of line * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label() - * @return void + * @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optionnal loaded */ function fetch_optionals($rowid,$optionsArray='') { @@ -2077,7 +2077,8 @@ abstract class CommonObject $resql=$this->db->query($sql); if ($resql) { - if ($this->db->num_rows($resql)) + $numrows=$this->db->num_rows($resql); + if ($numrows) { $tab = $this->db->fetch_array($resql); @@ -2093,12 +2094,17 @@ abstract class CommonObject } $this->db->free($resql); + + if ($numrows) return $numrows; + else return 0; } else { dol_print_error($this->db); + return -1; } } + return 0; } /**