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:
@@ -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(
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user