Fix warehouse fetch was not checking parameters. Fixes #10414

This commit is contained in:
Maxime Kohlhaas 2019-02-02 18:43:25 +01:00
parent 75845a990f
commit bb3225809b

View File

@ -308,6 +308,16 @@ class Entrepot extends CommonObject
{ {
global $conf; global $conf;
dol_syslog(get_class($this)."::fetch id=".$id." ref=".$ref);
// Check parameters
if (! $id && ! $ref)
{
$this->error='ErrorWrongParameters';
dol_syslog(get_class($this)."::fetch ".$this->error);
return -1;
}
$sql = "SELECT rowid, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id"; $sql = "SELECT rowid, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
if ($id) if ($id)
@ -320,7 +330,6 @@ class Entrepot extends CommonObject
if ($ref) $sql.= " AND ref = '".$this->db->escape($ref)."'"; if ($ref) $sql.= " AND ref = '".$this->db->escape($ref)."'";
} }
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {