When the OData service returns an empty (null) response, that null value is passed into json_decode within ODataResponse.php:93. This also results in an undefined array key access as well.
Warning: Undefined array key 0 in./vendor/saintsystems/odata-client/src/ODataResponse.php on line 93
Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in ./vendor/saintsystems/odata-client/src/ODataResponse.php on line 93
Honestly, removing lines 90-98 would be desirable. If a garbage response is returned from the server, the client should error out instead of attempting to figure it out.
Additionally, validate the JSON by checking json_last_error() === JSON_ERROR_NONE or pass json_decode(json: $body, associative: true, flags: JSON_THROW_ON_ERROR) to have it throw an exception.
This library is already proving super useful! Would love to see more work on it. I will PR these changes if I have some time later on.
When the OData service returns an empty (
null
) response, thatnull
value is passed intojson_decode
withinODataResponse.php:93
. This also results in an undefined array key access as well.Honestly, removing lines 90-98 would be desirable. If a garbage response is returned from the server, the client should error out instead of attempting to figure it out.
Additionally, validate the JSON by checking
json_last_error() === JSON_ERROR_NONE
or passjson_decode(json: $body, associative: true, flags: JSON_THROW_ON_ERROR)
to have it throw an exception.This library is already proving super useful! Would love to see more work on it. I will PR these changes if I have some time later on.