Open sschultze opened 1 year ago
I would say the shutdown error handler should be updated so that you can configure what type of errors it should handle, as right now, it treats warnings and notices as errors and those would break the response or send an error response when you are sending a 200.
Steps to reproduce
return $this->respondWithData($bigJson)
)What happens?
The server returns the action response partially, and then continues with the error JSON. So you get an invalid mess.
What would be expected?
The server returns the action response entirely. -or- The server returns the error JSON entirely.
Causes of the bug
When debugging I found out that the following happens:
ResponseEmitter
.error_get_last()
returns something, so a new error response is createdResponseEmitter
tries to clean the output buffer withob_clean()
, but only the not yet flushed part of the big JSON is cleaned. What has been flushed (the first part of the big JSON) cannot be un-flushed.Workaround 1
In
public/index.php
, register a PHP error handler withset_error_handler
which throws an exception.Workaround 2
Create a global flag which allows the reponse emitter to check if a response has already been written.
Disclaimer
I am new to PHP (only used it many many years ago) - so I might have misunderstood something.