2
0
forked from Wavyzz/dolibarr

Use <= 0 instead of ! because delete method returns -1 or 1 (#31268)

* Use <= 0 instead of ! because delete method returns -1 or 1

* Added contact

* Removed user from parameters
This commit is contained in:
atm-irvine
2024-10-04 11:49:44 +02:00
committed by GitHub
parent f5fbbcfcb8
commit f287d100a3
2 changed files with 14 additions and 4 deletions

View File

@@ -267,8 +267,8 @@ class Categories extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if (!$this->category->delete(DolibarrApiAccess::$user)) {
throw new RestException(401, 'error when delete category');
if ($this->category->delete(DolibarrApiAccess::$user) <= 0) {
throw new RestException(500, 'Error when delete category : ' . $this->category->error);
}
return array(

View File

@@ -348,7 +348,7 @@ class Contacts extends DolibarrApi
* Delete contact
*
* @param int $id Contact ID
* @return integer
* @return array[]
*/
public function delete($id)
{
@@ -364,7 +364,17 @@ class Contacts extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->contact->oldcopy = clone $this->contact;
return $this->contact->delete();
if ($this->contact->delete() <= 0) {
throw new RestException(500, 'Error when delete contact ' . $this->contact->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Contact deleted'
)
);
}
/**