summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2007-06-15 09:20:27 +0000
committerDmitry Stogov <dmitry@php.net>2007-06-15 09:20:27 +0000
commite1f08c829781a4eae7dbed6977fd1fcd9a5090fc (patch)
tree5cc9989bbadf7c65dfc18483d939245248763d07
parent1fe8fded5f688d8e95e2eaee4d476e6afe8a7414 (diff)
downloadphp-git-e1f08c829781a4eae7dbed6977fd1fcd9a5090fc.tar.gz
HTTP 500 is sent to browser in case of PHP error instead of blank page
-rw-r--r--NEWS2
-rw-r--r--main/main.c25
2 files changed, 20 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index ef88ccec8e..f9bb8671bd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2007, PHP 5.2.4
+- HTTP 500 is sent to browser in case of PHP error instead of blank page.
+ (Dmitry, Andrei Nigmatulin)
- Improved fix for MOPB-03-2007. (Ilia)
- Corrected fix for CVE-2007-2872. (Ilia)
- Enabled statement cache for non-persistent OCI8 connections.
diff --git a/main/main.c b/main/main.c
index 472ea8d5b0..290dabea6e 100644
--- a/main/main.c
+++ b/main/main.c
@@ -834,17 +834,28 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
/* no break - intentionally */
case E_ERROR:
case E_RECOVERABLE_ERROR:
- /* case E_PARSE: the parser would return 1 (failure), we can bail out nicely */
+ case E_PARSE:
case E_COMPILE_ERROR:
case E_USER_ERROR:
EG(exit_status) = 255;
if (module_initialized) {
- /* restore memory limit */
- zend_set_memory_limit(PG(memory_limit));
- efree(buffer);
- zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC);
- zend_bailout();
- return;
+ if (!SG(headers_sent) &&
+ SG(sapi_headers).http_response_code == 200) {
+ sapi_header_line ctr = {0};
+
+ ctr.line = "HTTP/1.0 500 Internal Server Error";
+ ctr.line_len = strlen(ctr.line);
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
+ }
+ /* the parser would return 1 (failure), we can bail out nicely */
+ if (type != E_PARSE) {
+ /* restore memory limit */
+ zend_set_memory_limit(PG(memory_limit));
+ efree(buffer);
+ zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC);
+ zend_bailout();
+ return;
+ }
}
break;
}