From a12186a0b800f190d04d23f3f2cbc61cba8c8a58 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 14 Nov 2017 01:26:02 +0100 Subject: [PATCH] Use HTTP response code 304 instead of 500 when nothing is done --- htdocs/comm/propal/class/api_proposals.class.php | 4 ++-- htdocs/commande/class/api_orders.class.php | 2 +- htdocs/contrat/class/api_contracts.class.php | 4 ++-- htdocs/fourn/class/api_supplier_invoices.class.php | 2 +- htdocs/fourn/class/api_supplier_orders.class.php | 2 +- htdocs/projet/class/api_projects.class.php | 2 +- htdocs/projet/class/api_tasks.class.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 97ea07bf7e6..36a5c9a780d 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -493,7 +493,7 @@ class Proposals extends DolibarrApi $result = $this->propal->valid(DolibarrApiAccess::$user, $notrigger); if ($result == 0) { - throw new RestException(500, 'Error nothing done. May be object is already validated'); + throw new RestException(304, 'Error nothing done. May be object is already validated'); } if ($result < 0) { throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error); @@ -535,7 +535,7 @@ class Proposals extends DolibarrApi $result = $this->propal->cloture(DolibarrApiAccess::$user, $status, $note_private, $notrigger); if ($result == 0) { - throw new RestException(500, 'Error nothing done. May be object is already closed'); + throw new RestException(304, 'Error nothing done. May be object is already closed'); } if ($result < 0) { throw new RestException(500, 'Error when closing Commercial Proposal: '.$this->propal->error); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 64958b01ef6..8bfed9d4eb4 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -537,7 +537,7 @@ class Orders extends DolibarrApi $result = $this->commande->cloture(DolibarrApiAccess::$user, $notrigger); if ($result == 0) { - throw new RestException(500, 'Error nothing done. May be object is already closed'); + throw new RestException(304, 'Error nothing done. May be object is already closed'); } if ($result < 0) { throw new RestException(500, 'Error when closing Order: '.$this->commande->error); diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 0bc02458869..45595712b68 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -479,7 +479,7 @@ class Contracts extends DolibarrApi $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); if ($result == 0) { - throw new RestException(500, 'Error nothing done. May be object is already validated'); + throw new RestException(304, 'Error nothing done. May be object is already validated'); } if ($result < 0) { throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); @@ -525,7 +525,7 @@ class Contracts extends DolibarrApi $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); if ($result == 0) { - throw new RestException(500, 'Error nothing done. May be object is already close'); + throw new RestException(304, 'Error nothing done. May be object is already close'); } if ($result < 0) { throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 1d7efb236a2..e60fdccd4ad 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -312,7 +312,7 @@ class SupplierInvoices extends DolibarrApi $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); if ($result == 0) { - throw new RestException(500, 'Error nothing done. May be object is already validated'); + throw new RestException(304, 'Error nothing done. May be object is already validated'); } if ($result < 0) { throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 22cd4eb191c..74b5bbe43b3 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -316,7 +316,7 @@ class SupplierOrders extends DolibarrApi $result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger); if ($result == 0) { - throw new RestException(500, 'Error nothing done. May be object is already validated'); + throw new RestException(304, 'Error nothing done. May be object is already validated'); } if ($result < 0) { throw new RestException(500, 'Error when validating Order: '.$this->order->error); diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 6fcdfde7ca2..f6364eb0544 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -513,7 +513,7 @@ class Projects extends DolibarrApi $result = $this->project->setValid(DolibarrApiAccess::$user, $notrigger); if ($result == 0) { - throw new RestException(500, 'Error nothing done. May be object is already validated'); + throw new RestException(304, 'Error nothing done. May be object is already validated'); } if ($result < 0) { throw new RestException(500, 'Error when validating Project: '.$this->project->error); diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index f00a536df87..fc006706d81 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -529,7 +529,7 @@ class Tasks extends DolibarrApi $result = $this->task->addTimeSpent(DolibarrApiAccess::$user, 0); if ($result == 0) { - throw new RestException(500, 'Error nothing done. May be object is already validated'); + throw new RestException(304, 'Error nothing done. May be object is already validated'); } if ($result < 0) { throw new RestException(500, 'Error when adding time: '.$this->task->error);