|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-11-02 11:41 UTC] taneli at crasman dot fi
Description:
------------
Errors in eval()'ed code produces HTTP status code 500 for the request.
Reproduce code:
---------------
Script:
<?php {
eval("this is not right");
}?>
Result:
# curl -I http://localhost/test.php
HTTP/1.0 500 Internal Server Error
Expected result:
----------------
Since parse errors and such in eval()'ed code don't interrupt the script or make it bail out, I think 200 would be a more approriate code.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 10:00:01 2025 UTC |
Here's a patch for this issue: --- php-5.2.4-vanilla/main/main.c 2007-11-01 15:20:37.000000000 +0200 +++ php-5.2.4/main/main.c 2007-11-01 17:26:45.000000000 +0200 @@ -957,11 +957,15 @@ 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); + if (!EG(current_execute_data) || + !EG(current_execute_data)->opline || + EG(current_execute_data)->opline->opcode != ZEND_INCLUDE_OR_EVAL) { + 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) {