Merge pull request #18546 from lainwir3d/fix_restapi_order_mail_substitutes

FIX #18544 Shipment rest api: load thirdparty object when validating
This commit is contained in:
Laurent Destailleur 2021-09-01 18:19:11 +02:00 committed by GitHub
commit 82d99bfa01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -717,6 +717,8 @@ class Orders extends DolibarrApi
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();