- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 24
 
Open
Description
Assume displayExceptions is true.
If in the exception stack trace a function argument contains binary data that json_encode could not handle, then json_encode will return false.  As a result the response content is empty.
This happens at following lines:
RenderErrorListener.php#L94
ApiProblemResponse.php#L59
This situation can occur in various debugging scenarios, e.g. uploading a file and passing its blob to a function, and it can be pretty difficult to overcome because the empty response.
Proposed solution
A better choice would be to use \Zend\Json\Encoder::encode because it can correctly handle the encoding of binary data that json_encode can not encode.
// Assuming $data['blob'] contains the binary data of a PDF file
json_encode($data); // return false
\Zend\Json\Json::encode($data); // return false if the json extension is available, otherwise \Zend\Json\Encoder::encode is used
\Zend\Json\Encoder::encode($data); // return the encoded jsonOriginally posted by @leogr at zfcampus/zf-api-problem#29
Metadata
Metadata
Assignees
Labels
No labels