zoho / zohocrm-php-sdk-6.0

Apache License 2.0
1 stars 1 forks source link

Invalid array access in src/com/zoho/crm/api/util/JSONConverter.php #9

Closed mattanger closed 1 month ago

mattanger commented 1 month ago

Hi, I believe there is a bug in the file src/com/zoho/crm/api/util/JSONConverter.php I'm not sure what the cause is, but in the isRecord request method it checks for mandatory key values. It can produce this error: com\zoho\crm\api\exception\SDKException Caused by : Trying to access array offset on value of type null

In the for loop starting on line 265, the variable $keyDetail can sometimes be null, and there is guard to check if it is null. I don't know the root cause of why this happens, but it shouldn't with a valid request/record object. Simply putting this code at the start of the loop:

if ($keyDetail == null) continue;
....

Resolves the issue, and the requests complete successfully.

Edit: Here is an example of the fix that worked for me: https://github.com/zoho/zohocrm-php-sdk-6.0/pull/10

I don't know the root cause of this issue, and I don't really have time to figure it out. It would be helpful to know what's going on.

raja-7453 commented 1 month ago

Thanks, @mattanger for notifying us. We have resolved this issue in our 5.0.0 version release. Please update the SDK version.