diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index e101fb89602..89d170feb60 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -173,7 +173,7 @@ class DolibarrApi unset($object->name_bis); unset($object->newref); - if ($object->table_element != 'ticket') { + if (!isset($object->table_element) || $object->table_element != 'ticket') { unset($object->comments); } diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index eb377b7685e..d50fec76353 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -142,11 +142,11 @@ class Users extends DolibarrApi * Get properties of an user object * * @param int $id ID of user - * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) - * @return array|mixed data without useless information + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) + * @return array|mixed data without useless information * - * @throws RestException 401 Insufficient rights - * @throws RestException 404 User or group not found + * @throws RestException 401 Insufficient rights + * @throws RestException 404 User or group not found */ public function get($id, $includepermissions = 0) { @@ -177,13 +177,13 @@ class Users extends DolibarrApi * Get properties of an user object by login * * @param string $login Login of user - * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) - * @return array|mixed data without useless information + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) + * @return array|mixed Data without useless information * * @url GET login/{login} * - * @throws RestException 401 Insufficient rights - * @throws RestException 404 User or group not found + * @throws RestException 401 Insufficient rights + * @throws RestException 404 User or group not found */ public function getByLogin($login, $includepermissions = 0) { @@ -211,8 +211,8 @@ class Users extends DolibarrApi * Get properties of an user object by Email * * @param string $email Email of user - * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) - * @return array|mixed data without useless information + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) + * @return array|mixed Data without useless information * * @url GET email/{email} * diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index d2dd8660922..6222f7fcaf7 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -190,7 +190,6 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase */ public function testRestCreateUser() { - // attemp to create without mandatory fields : $url = $this->api_url.'/users?api_key='.$this->api_key; $addheaders=array('Content-Type: application/json');