From 4381f67a64bc90c2c2df6b8a8084c169e5aef7e5 Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Mon, 30 Aug 2021 00:08:43 +0400 Subject: [PATCH] FIX #18544 Shipment REST API: load thirdparty object into the shipment before validating. --- htdocs/commande/class/api_orders.class.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 745fea5ab76..f5e9aea75bd 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -716,7 +716,9 @@ class Orders extends DolibarrApi if (!$result) { throw new RestException(404, 'Order not found'); } - + + $result = $this->commande->fetch_thirdparty(); // do not check result, as failure is not fatal (used only for mail notification substitutes) + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -729,13 +731,6 @@ class Orders extends DolibarrApi throw new RestException(500, 'Error when validating Order: '.$this->commande->error); } $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } - - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } $this->commande->fetchObjectLinked();