Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26094 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89406 invoked by uid 1010); 19 Oct 2006 20:11:31 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 89391 invoked from network); 19 Oct 2006 20:11:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Oct 2006 20:11:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=evert@rooftopsolutions.nl; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=evert@rooftopsolutions.nl; sender-id=unknown Received-SPF: error (pb1.pair.com: domain rooftopsolutions.nl from 66.207.192.7 cause and error) X-PHP-List-Original-Sender: evert@rooftopsolutions.nl X-Host-Fingerprint: 66.207.192.7 smtp0.beanfield.net FreeBSD 4.6-4.9 Received: from [66.207.192.7] ([66.207.192.7:2058] helo=smtp0.beanfield.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FB/3C-27040-1FBD7354 for ; Thu, 19 Oct 2006 16:11:31 -0400 Received: from [66.207.213.206] (66-207-213-206.beanfield.net [66.207.213.206]) by smtp0.beanfield.net (8.13.4/8.12.11) with ESMTP id k9JK9wJ2088149; Thu, 19 Oct 2006 16:09:59 -0400 (EDT) (envelope-from evert@rooftopsolutions.nl) Message-ID: <4537DBEC.8050506@rooftopsolutions.nl> Date: Thu, 19 Oct 2006 16:11:24 -0400 Reply-To: evert@rooftopsolutions.nl User-Agent: Thunderbird 1.5.0.7 (Macintosh/20060909) MIME-Version: 1.0 To: Rasmus Lerdorf CC: internals@lists.php.net References: <4537C21F.9070900@rooftopsolutions.nl> <4537D328.6080706@lerdorf.com> In-Reply-To: <4537D328.6080706@lerdorf.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Feature request: ini setting for http 500 on fatal errors From: evert@rooftopsolutions.nl (Evert | Rooftop) 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 >