novaksolutions / infusionsoft-php-sdk

An OO Infusionsoft PHP SDK
Other
69 stars 53 forks source link

Null response from Infusionsoft causes Fatal Error #158

Open brumiser1550 opened 4 years ago

brumiser1550 commented 4 years ago

The save() method on line 165 of vendor/infusionsoft/php-sdk/src/Infusionsoft/Api/Rest/RestModel.php cannot handle null responses from Infusionsoft resulting in an uncatchable fatal error.

I figured this out from trying to add a tag through the REST API where the tag category was not valid.

I feel like Infusionsoft should be returning some kind of message saying that the resource doesn't exist, not just a null response.

An easy solution would be to just say:

if(!$data){
    $data = [];
}
$this->fill($data);

because the fill method requires an array.

The Stack trace

PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Infusionsoft\Api\Rest\RestModel::fill() must be of the type array, null given, called in /vendor/infusionsoft/php-sdk/src/Infusionsoft/Api/Rest/RestModel.php on line 177 and defined in /vendor/infusionsoft/php-sdk/src/Infusionsoft/Api/Rest/RestModel.php:391
Stack trace:
#0 /vendor/infusionsoft/php-sdk/src/Infusionsoft/Api/Rest/RestModel.php(177): Infusionsoft\Api\Rest\RestModel->fill(NULL)
#1 /vendor/infusionsoft/php-sdk/src/Infusionsoft/Api/Rest/RestModel.php(155): Infusionsoft\Api\Rest\RestModel->save()
#2 /process.php(918): Infusionsoft\Api\Rest\RestModel->create(Array)
#3 {main}
  thrown in /vendor/infusionsoft/php-sdk/src/Infusionsoft/Api/Rest/RestModel.php on line 391
joeynovak commented 4 years ago

That's awesome :). I think we are using the newer SDK for the Rest API, but neither the Rest code in this sdk, or the new one are done they are both really in pre-alpha (but they are functional). So I'm going to move this to something other than "Open" for now.

brumiser1550 commented 4 years ago

Well, this is embarrassing... I actually meant to add this to the IFS repo. I can leave it here though, if you want, hopefully this is something IFS will fix on their end.