how do I display a meaningful error message in PHP in case of out-of-memory?
My company is running an internal MediaWiki site on LAMP, which is actively used and has a number of custom modifications. Some users write really big DPL queries, and some of those queries actually exceed the configured memory limit per request.
The problem is that when PHP runs out of memory, it simply returns an HTTP error 500 and a blank page. I am trying to install a custom error handler which would return something useful to the user, e.g. "your query is too big and exceeded the alotted memory limit". I looked up the docs and found how it (supposedly) can be done; the problem is that the solution simply doesn't work. here is what i am trying to do:
Basically a lot of debug code in there. I trap the error, and i log all the pertinent into via the "error_log". I can set the response headers and HTTP code, and the browser receives it (in this case, I was setting it to 200 just because I felt like it). But no matter what I do, I cannot get any output to display to the user in their browser!
That "print" statement should work. The output string is in the buffer, I can see it in the buffer dump, and I am flushing the buffer -- but the browser simply receives no HTML content, nothing. Blank page.