diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index 06b8cecf7f3..f2cb8c440c2 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -890,7 +890,10 @@ if ($rowid > 0) {
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).'';
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
$prodtmp = new Product($db);
- $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
+ $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
+ if ($result < 0) {
+ setEventMessage($prodtmp->error, 'errors');
+ }
print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
}
print '
';
@@ -912,7 +915,10 @@ if ($rowid > 0) {
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).'';
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
$prodtmp = new Product($db);
- $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
+ $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
+ if ($result < 0) {
+ setEventMessage($prodtmp->error, 'errors');
+ }
print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
}
print '
';
diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php
index ce734aadeb5..69fef80fd6b 100644
--- a/htdocs/api/class/api_documents.class.php
+++ b/htdocs/api/class/api_documents.class.php
@@ -419,8 +419,10 @@ class Documents extends DolibarrApi
$object = new Product($this->db);
$result = $object->fetch($id, $ref);
- if (!$result) {
+ if ($result==0) {
throw new RestException(404, 'Product not found');
+ } elseif ($result<0) {
+ throw new RestException(500, 'Error while fetching object: '.$object->error);
}
$upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
@@ -630,7 +632,7 @@ class Documents extends DolibarrApi
}
elseif ($result < 0)
{
- throw new RestException(500, 'Error while fetching object.');
+ throw new RestException(500, 'Error while fetching object: '.$object->error);
}
}
diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php
index f6dea256f6a..1ac908f361a 100644
--- a/htdocs/barcode/printsheet.php
+++ b/htdocs/barcode/printsheet.php
@@ -57,9 +57,11 @@ $thirdpartytmp = new Societe($db);
if (GETPOST('submitproduct') && GETPOST('submitproduct'))
{
$action = ''; // We reset because we don't want to build doc
- if (GETPOST('productid') > 0)
- {
- $producttmp->fetch(GETPOST('productid'));
+ if (GETPOST('productid') > 0) {
+ $result = $producttmp->fetch(GETPOST('productid'));
+ if ($result < 0) {
+ setEventMessage($producttmp->error, 'errors');
+ }
$forbarcode = $producttmp->barcode;
$fk_barcode_type = $producttmp->barcode_type;
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index 4a1c4e2f179..f6fe33aa932 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -1004,7 +1004,11 @@ class BOM extends CommonObject
foreach ($this->lines as &$line) {
$tmpproduct = new Product($this->db);
- $tmpproduct->fetch($line->fk_product);
+ $result= $tmpproduct->fetch($line->fk_product);
+ if ($result < 0) {
+ $this->error=$tmpproduct->error;
+ return -1;
+ }
$line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
if (empty($line->unit_cost)) {
if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0)
diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php
index d6b8ebf9a7c..45340577228 100644
--- a/htdocs/bom/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php
@@ -52,8 +52,15 @@ foreach ($linkedObjectBlock as $key => $objectlink)
}
echo '';
echo '