From: Dmitry Stogov Date: Fri, 15 Jun 2007 09:20:53 +0000 (+0000) Subject: HTTP 500 is sent to browser in case of PHP error instead of blank page X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~448 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e6209db14c91391f3684904aa91502eb00d46869;p=php HTTP 500 is sent to browser in case of PHP error instead of blank page --- diff --git a/main/main.c b/main/main.c index c9766625e2..7abf5d0aee 100644 --- a/main/main.c +++ b/main/main.c @@ -931,17 +931,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; }