pipedrive / client-php

Pipedrive API client for PHP
MIT License
48 stars 55 forks source link

CamelCaseHelper - empty response body causes `invalid argument supplied for foreach()` #72

Closed titzel24 closed 2 years ago

titzel24 commented 2 years ago

Sometimes Pipedrive Api returns an empty body causing CamelCaseHelper to fail because response is not iterable.

Sadly, we do not know how to reproduce this at the moment.

/var/www/vendor/pipedrive/pipedrive/src/Utils/CamelCaseHelper.php:27 Invalid argument supplied for foreach()
/var/www/vendor/pipedrive/pipedrive/src/Utils/CamelCaseHelper.php in _exception_handler() at line 27
/var/www/vendor/pipedrive/pipedrive/src/Controllers/PersonsController.php in Pipedrive\Utils\CamelCaseHelper::keysToCamelCase() at line 233
/var/www/application/logic/pipedrive.php in Pipedrive\Controllers\PersonsController->searchPersons() at line 433
titzel24 commented 2 years ago

Thinking about sth like

if (!is_array($input) || !is_object($input)) {
    return [];
}
SpaceOven commented 2 years ago

Fixed in the latest release: https://github.com/pipedrive/client-php/releases/tag/4.0.3