php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43358 500 HTTP error when eval()'d code contains a notice/warning
Submitted: 2007-11-21 10:13 UTC Modified: 2008-04-11 01:00 UTC
Votes:8
Avg. Score:4.8 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:6 (85.7%)
Same OS:2 (28.6%)
From: andrea dot spacca at gmail dot com Assigned: fb-req-jani (profile)
Status: No Feedback Package: *General Issues
PHP Version: 5.2.5 OS: Gentoo
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: andrea dot spacca at gmail dot com
New email:
PHP Version: OS:

 

 [2007-11-21 10:13 UTC] andrea dot spacca at gmail dot com
Description:
------------
When E_NOTICE or E_WARNING happen in eval'd code the script return 500
HTTP respons even on not blank pages

PS: third time i have to open the bug, 'cause jani@php.net continue to close it as bogus without wait my reply to his comments. i'll put, as soon as possibile, a script online on our server so you could test the behaviour on the enviroment where we reproduce the bug

Reproduce code:
---------------
<?php
    eval('$pluto = "test ".UNDEFINED_CONST." test";');

    echo 'AFTER';
?>


Expected result:
----------------
Apache Access Log:
192.168.1.1 - - [20/Nov/2007:16:09:23 +0100] "GET /testBug.cgi HTTP/1.1"
200 25

Actual result:
--------------
Apache Access Log:
192.168.1.1 - - [20/Nov/2007:16:09:23 +0100] "GET /testBug.cgi HTTP/1.1"
500 25

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-21 10:23 UTC] andrea at spacca dot org
from our httpd.conf:
LoadModule php5_module etc etc
AddType application/x-httpd-php .php .cgi
 [2007-11-21 13:41 UTC] andrea at spacca dot org
here you can test the http response on our enviroment:
http://89.186.95.3/test/testBug.cgi
 [2007-12-17 22:28 UTC] not at public dot com
This is an existing bug. Having the same error on 2.5.4 on FreeBSD.

A failed eval results in a 500 error, although when calling error_log() on the last line of the code, the php script does reach and execute that.

The script is executed correctly, and the response from the server also includes the ( correct ) output of the script without any php errors, but after the 500 header ofcourse. Browsers hang on the error and don't show the output.
 [2008-02-26 11:31 UTC] zorfling at hotmail dot com
Hi,

I've been having the same problem and thought I'd post my workaround.
If you simply overwrite the headers to return a 200, it works.

eg header("Content-type: text/html", true, 200); (second arg is to overwrite the current header)

NB This needs to be called AFTER the eval that causes the issue.

Hope this helps,


Chris
 [2008-02-29 19:33 UTC] not at public dot com
Was able to eliminate this bug by turning output buffering off in php.ini
 [2008-04-11 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-07-23 12:00 UTC] andy at boeckler dot org
I have the same issue with 5.2.6 with @eval. See Bug #45592.
Some can mark my bug entry as duplicate.

testCode:
<?php
error_reporting(E_ALL & ~E_NOTICE);

class Test {
    function func1() { // HTTP 500                                          
        ini_set('display_errors', 'off');
        @eval('completely wrong');
        echo 'boo'; exit();
    }
    function func2() { //HTTP 200                                                
        ini_set('display_errors', 'on');
        @eval('completely wrong');
        echo 'boo'; exit();
    }
    function func3() { // HTTP 200  and HTTP 500 with output buffering  

        ini_set('display_errors', 'off');
        echo 'noerror';
        @eval('completely wrong');
        echo 'boo'; exit();
    }
}

Test::func1();
//Test::func2();                                                        
//Test::func3();                                                        
                                                                        
                   
?>
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jul 04 04:05:46 2022 UTC