Thats a smart idea.. I like that
As for letting PHP do the 500, I tend to use output buffering everywhere
(i think most people do, supposed to be faster too) so I'm used to
setting header()'s wherever I need them..
Besides, in most of my script the business logic gets executed first,
and this is where most errors can happen.. only after the presentation
is done.
So the solution would be, if fatal error is triggered, and
headers_sent() is false then set the error to 500..
Is this possible?
Evert
Rasmus Lerdorf wrote:
Evert | Rooftop wrote:
Excuse me if this has been discussed before, but I would like to know
the stance on this issue, it's hard to search the buglist or mailing
archives on stuff like http, 500 and fatal.
Would it be hard to implement an ini setting for throwing a http 500
error on a fatal error? It's hard to make certain applications and
have proper error handling if there is no way to do anything on a
fatal error..
It would be even grander if php could try to run a fall-back script
when something really bad happens, but just having that 500 on fatal
errors would be awesome ..
If this is not going to happen anytime soon, would you accept a patch?
How would you implement it. Fatal errors can happen after output has
already been sent in which case it is too late to change the http
status. And if you haven't sent anything yet, as in you are using
output buffering, then it is rather trivial to do in user space.
Simply start you script by setting the status to 500 and change it to
200 when you know you have good output to send. That way if a fatal
error happens, the 500 will be sent.
-Rasmus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php