php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63701 Php CLI does not respect display_errors option to report to STDOUT.
Submitted: 2012-12-05 21:56 UTC Modified: 2018-03-19 16:51 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: ksours at internetbrands dot com Assigned: cmb (profile)
Status: Closed Package: PHP options/info functions
PHP Version: 5.3.19 OS: CentOS
Private report: No CVE-ID: None
 [2012-12-05 21:56 UTC] ksours at internetbrands dot com
Description:
------------
Run the script from the command line using something like:
# php test.php > outstd.txt

Note that I get the same behavior setting the display_errors in the php.ini instead of by the script.  The problem only occurs in the CLI and only on Unix, Windows is fine.

The use case here is that I would like to be able to test the eval, capture any errors, and report them via the app.  Having it randomly output stuff to the stream messes up the reporting.  There does not appear to be anyway to catch the output of STDERR with php using output buffering.  

Test script:
---------------
<?php
ini_set('display_errors', 'STDOUT');

include('foo');
ob_start();
eval ('foo alkadsjfladsjfladsfjl');
$foo = ob_get_contents();
ob_end_clean();
var_dump('xxx', $foo, 'xxx');
?>


Expected result:
----------------
PHP Warning:  include(foo): failed to open stream: No such file or directory in /home/ksours/test.php on line 4
PHP Warning:  include(): Failed opening 'foo' for inclusion (include_path='.:/php/includes:/usr/share/pear') in /home/ksours/test.php on line 4
PHP Parse error:  syntax error, unexpected T_STRING in /home/ksours/test.php(6) : eval()'d code on line 1

the outstd.txt will contain:
Warning: include(foo): failed to open stream: No such file or directory in /home/ksours/test.php on line 4

Warning: include(): Failed opening 'foo' for inclusion (include_path='.:/php/includes:/usr/share/pear') in /home/ksours/test.php on line 4
string(3) "xxx"
string(102) "
Parse error: syntax error, unexpected T_STRING in /home/ksours/test.php(6) : eval()'d code on line 1
"
string(3) "xxx"

Actual result:
--------------
No output to STDERR when display_errors is set to STDOUT.  It's also odd that the output buffering captures the output, but its still displayed.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-17 15:39 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-03-17 15:39 UTC] cmb@php.net
I cannot reproduce the described behavior on a recent PHP-7.1
checkout (the oldest version that could be target of a normal bug
fix).

So please try with a still supported version of PHP to verify
whether this issue has been resolved in the meantime.
 [2018-03-19 16:06 UTC] ksours at internetbrands dot com
I don't remember the context for this report, so if you can't reproduce just close it.
 [2018-03-19 16:51 UTC] cmb@php.net
-Status: Feedback +Status: Closed
 [2018-03-19 16:51 UTC] cmb@php.net
Okay, closing.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC