Open cmanley opened 4 years ago
More info:
See: https://github.com/datto/php-json-rpc-http/blob/db15a075f3562c4e8d297b9082acc5b2869bd4b4/src/Client.php#L229 and on line 226 too.
That triggered this exception in my code: ErrorException: Undefined variable: http_response_header at .../vendor/datto/json-rpc-http/src/Client.php line 229.
$http_response_header is a reserved variable, but it doesn't seem to always exist. See the note at the bottom of this page for the cause and solution: https://www.php.net/manual/en/reserved.variables.httpresponseheader.php Quoted below just in case it disappears in the future:
Bear in mind this special variable is somehow protected and not populated in some situation when the peer server close the connection early on (ssl reset) => Undefined variable: http_response_header
A code like this one: $response = @file_get_contents($url); empty($http_response_header) && $http_response_header = array('HTTP/1.1 400 Bad request');
Will return a cryptic error message: Fatal error: Call to undefined function array() on line 2
-- Should you want to cope with this situation: $hdrs = array('HTTP/1.1 400 Bad request'); !empty($htp_response_header) && $hdrs = $http_response_headers;
Now use $hdrs in place of $http_response_header
We are seeing this same error when using https://github.com/fiskaly/fiskaly-sdk-php (which is based on this library).
While there is obviously a root problem which needs to be fixed, this makes it practically impossible to actually debug it, because all real error details are hidden from the surface
Here it is: https://github.com/datto/php-json-rpc-http/blob/db15a075f3562c4e8d297b9082acc5b2869bd4b4/src/Client.php#L226 and a few lines down too. That gets converted into an ErrorException in onError() so the proper send() HTTP exception handling is effectively bypassed.