FIX #29424 API GET member categories (#31881)

* Fix members categories when user is not found

* Return empty array instead of 0 when member does not have category assigned
This commit is contained in:
Thibault Parodi 2024-11-15 23:57:58 +01:00 committed by GitHub
parent c96b909727
commit be72bfa664
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -689,6 +689,12 @@ class Members extends DolibarrApi
throw new RestException(403);
}
$member = new Adherent($this->db);
$result = $member->fetch($id);
if (0 === $result) {
throw new RestException(404, 'Member not found');
}
$categories = new Categorie($this->db);
$result = $categories->getListForItem($id, 'member', $sortfield, $sortorder, $limit, $page);

View file

@ -1103,7 +1103,7 @@ class Categorie extends CommonObject
return -1;
}
if (!count($categories)) {
return 0;
return [];
}
return $categories;