#18824 [Bgs]: PHP should produce an appropriate status code when an error is encountered

From: Date: Fri, 09 Aug 2002 09:40:09 +0000
Subject: #18824 [Bgs]: PHP should produce an appropriate status code when an error is encountered
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-16374@lists.php.net to get a copy of this message
ID: 18824 Updated by: markonen@php.net Reported By: bugs.php.net@mnot.net Status: Bogus Bug Type: Feature/Change Request Operating System: unknown (maybe FreeBSD?) PHP Version: 4.2.2 New Comment: There is one huge, practical problem with the 500 responses -- IE/Win's canned error messages. Most people have not turned them off; many don't even know how. Getting the PHP error messages replaced by an obfuscated Microsoft notice will have a very, very high WTF factor for a lot of users. That said, there is no doubt that a tutorial like "HTTP for PHP Developers" would be a very useful part of the PHP manual. Status codes and, for example, the IMS negotiation mechanism are among the worst understood aspects of this trade. Previous Comments: ------------------------------------------------------------------------ [2002-08-09 04:55:10] bugs.php.net@mnot.net No, actually I missed it ;) All that I'm proposing is that the default status code be changed from 200 to 500 *if* a fault is encoutered. If the script has changed it in the meantime, so be it. I definately don't want to remove the flexibility to express semantics in the language; only create the proper defaults based on known conditions. I can think of many real-world situations where the current behaviour is broken; e.g., CDNs like Akamai will cache erroneous content if it comes with a 200, but do the right thing if they see a 500. Tis late (at least here). Obviously, you don't agree with my arguments here, so I'm happy to leave this as is, for consideration by others. Cheers, ------------------------------------------------------------------------ [2002-08-09 04:09:24] rasmus@php.net That's fine, and trust me, I have read Roy's papers, but you nicely avoided the realworld example I gave you which showed a perfect case where the application author needs control over when to make something a server error and when not to. I fully agree that people should write decent error handling functions that do something intelligent, but I do not believe in removing flexibility from PHP and forcing every error to generate a 500. ------------------------------------------------------------------------ [2002-08-09 03:49:44] bugs.php.net@mnot.net Please see Roy Fieldings' dissertation: http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm And comments by Henrik Frystyk Neilsen: http://discuss.develop.com/archives/wa.exe?A2=ind0004&L=soap&F=&S=&P=33153 Basically, there is no "Application Layer" vs. "Server Layer"; HTTP is an application layer protocol, and any differentiation between the software that serves the request and the software that implements the logic to generate the content is in the mind of the developer only. This point has been debated elsewhere ad nauseum, but the people who architected the Web in the first place all agree that HTTP status codes should carry this kind of information. ------------------------------------------------------------------------ [2002-08-09 03:42:21] rasmus@php.net I still don't agree that this should be a default thing. An application level error is quite different from a server-level error. Most production sites should be redirecting all errors to a log file or some other mechanism. There can be runtime errors that occur that do not significantly impact users. In that sense I do not believe application level errors should be extended to the client. Perhaps an argument can be made for fatal php initialization errors that occur at the interface between the server and PHP. For example, how about a simple redirection script which sends a location header and either a 301 or a 302. Some logging code after the redirect fails for some reason. In normal operation, the user still gets redirected, but in your scenario this becomes a 500 and the script no longer works. ------------------------------------------------------------------------ [2002-08-09 03:01:45] bugs.php.net@mnot.net IMP buffers, as does any other application using HTTP:Compress. > Also, consider that errors generally occur after some > valid content has been generated, and not sending this > in a valid response would make it considerably harder to > debug things. A 500 response can have a body just as easily as a 200 can. > If someone wants this functionality in buffered mode, > they could easily do it with their own error handling > function. It's not the person writing the application who would necessarily want this functionality; it's the consumer of the application. The idea is to be compatible with the Web architecture, and that means honoring the semantics of the protocols. Cheers, ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/18824 -- Edit this bug report at http://bugs.php.net/?id=18824&edit=1

« previous php.bugs (#16374) next »