From 0d50cab97e8243152b820810d8681999c84fc511 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 10 Mar 2018 23:05:24 +0100 Subject: [PATCH 1/3] primary key without space --- test/phpunit/CodingSqlTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 57be8fc62a9..460a3e2fbeb 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -200,7 +200,7 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase else { // Test for non key files only - $result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY ') == 0); + $result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY') == 0); print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n"; $this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.'); From 3da645ab3b2bd24547da40b199bdd916583272ec Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Sat, 10 Mar 2018 23:40:56 +0100 Subject: [PATCH 2/3] fix trigger position into explication class --- htdocs/expedition/class/expedition.class.php | 25 +++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 61b95c50064..3f75dbbdc41 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1096,6 +1096,18 @@ class Expedition extends CommonObject $error=0; $this->error=''; + $this->db->begin(); + + if (!$error) { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('SHIPPING_DELETE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + // Add a protection to refuse deleting if shipment has at least one delivery $this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment if (count($this->linkedObjectsIds) > 0) @@ -1104,9 +1116,11 @@ class Expedition extends CommonObject return -1; } - $this->db->begin(); + + + // Stock control - if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0) + if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0 && !$error) { require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); @@ -1203,11 +1217,6 @@ class Expedition extends CommonObject if ($this->db->query($sql)) { - // Call trigger - $result=$this->call_trigger('SHIPPING_DELETE',$user); - if ($result < 0) { $error++; } - // End call triggers - if (! empty($this->origin) && $this->origin_id > 0) { $this->fetch_origin(); @@ -2440,7 +2449,7 @@ class ExpeditionLigne extends CommonObjectLine dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error.=($this->error?', '.$errmsg:$errmsg); } - + $this->db->rollback(); return -1*$error; } From 17d1a15d50b8f5f7b678036c0aadcad42c86cd70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Mar 2018 00:00:24 +0100 Subject: [PATCH 3/3] Update expedition.class.php --- htdocs/expedition/class/expedition.class.php | 31 +++++++++----------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 3f75dbbdc41..05328d57b05 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1081,24 +1081,32 @@ class Expedition extends CommonObject /** * Delete shipment. - * Warning, do not delete a shipment if a delivery is linked to (with table llx_element_element) + * Warning, do not delete a shipment if a delivery is linked to (with table llx_element_element) * * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO */ function delete() { global $conf, $langs, $user; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if ($conf->productbatch->enabled) - { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; - } + $error=0; $this->error=''; $this->db->begin(); - if (!$error) { + // Add a protection to refuse deleting if shipment has at least one delivery + $this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment + if (count($this->linkedObjectsIds) > 0) + { + $this->error='ErrorThereIsSomeDeliveries'; + $error++; + } + + if (! $error) + { if (! $notrigger) { // Call trigger @@ -1108,19 +1116,8 @@ class Expedition extends CommonObject } } - // Add a protection to refuse deleting if shipment has at least one delivery - $this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment - if (count($this->linkedObjectsIds) > 0) - { - $this->error='ErrorThereIsSomeDeliveries'; - return -1; - } - - - - // Stock control - if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0 && !$error) + if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0) { require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");