Merge pull request #13730 from simicar29/11.0-expedition

Clean line extrafields when deleting expedition
This commit is contained in:
Laurent Destailleur 2020-04-24 15:16:41 +02:00 committed by GitHub
commit eda3643639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1280,15 +1280,23 @@ class Expedition extends CommonObject
if (!$error)
{
$main = MAIN_DB_PREFIX . 'expeditiondet';
$ef = $main . "_extrafields";
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_expedition = " . $this->id . ")";
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet";
$sql .= " WHERE fk_expedition = ".$this->id;
if ($this->db->query($sql))
if ($this->db->query($sqlef) && $this->db->query($sql))
{
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
// delete extrafields
$res = $this->deleteExtraFields();
if ($res < 0) $error++;
if (!$error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition";