diff --git a/Zend/zend.c b/Zend/zend.c index 09338e7f83436..b370a79025bf1 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1215,7 +1215,13 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */ va_end(args); if (type == E_PARSE) { - EG(exit_status) = 255; + /* eval() errors do not affect exit_status */ + if (!(EG(current_execute_data) && + EG(current_execute_data)->opline && + EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL && + EG(current_execute_data)->opline->extended_value == ZEND_EVAL)) { + EG(exit_status) = 255; + } zend_init_compiler_data_structures(TSRMLS_C); } } diff --git a/main/main.c b/main/main.c index 5eb9947fe7a5c..2897577bd8360 100644 --- a/main/main.c +++ b/main/main.c @@ -1123,11 +1123,20 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ case E_PARSE: case E_COMPILE_ERROR: case E_USER_ERROR: - EG(exit_status) = 255; + { /* new block to allow variable definition */ + /* eval() errors do not affect exit_status or response code */ + zend_bool during_eval = (EG(current_execute_data) && + EG(current_execute_data)->opline && + EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL && + EG(current_execute_data)->opline->extended_value == ZEND_EVAL); + if (!during_eval) { + EG(exit_status) = 255; + } if (module_initialized) { if (!PG(display_errors) && !SG(headers_sent) && - SG(sapi_headers).http_response_code == 200 + SG(sapi_headers).http_response_code == 200 && + !during_eval ) { sapi_header_line ctr = {0}; @@ -1148,6 +1157,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ } } break; + } } /* Log if necessary */