php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64882 'Could not open input file' error message goes to STDOUT
Submitted: 2013-05-20 14:08 UTC Modified: 2016-06-21 11:29 UTC
Votes:13
Avg. Score:4.6 ± 0.5
Reproduced:13 of 13 (100.0%)
Same Version:7 (53.8%)
Same OS:8 (61.5%)
From: weirdan at gmail dot com Assigned:
Status: Verified Package: CGI/CLI related
PHP Version: 5.4.15 OS: Debian GNU/Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-05-20 14:08 UTC] weirdan at gmail dot com
Description:
------------
Error messages in CLI should go to STDERR. This was the case with 5.3.x, but it 
doesn't seem to be the case with 5.4.*

Test script:
---------------
#!/bin/bash
for dir in `ls -d php-5*|grep -v tar`; do 
   echo -n "$dir: ";
   # the following line should output nothing 
   $dir/sapi/cli/php -n $(tempfile).php 2>/dev/null; 
   echo; 
done 


Expected result:
----------------
php-5.3.25: 
php-5.4.0:
php-5.4.15:
php-5.4.7:

Actual result:
--------------
php-5.3.25: 
php-5.4.0: Could not open input file: /tmp/filelm8WcG.php

php-5.4.15: Could not open input file: /tmp/filehmMkOG.php

php-5.4.7: Could not open input file: /tmp/fileSfJZ4E.php


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-20 14:13 UTC] weirdan at gmail dot com
Those folders contain vanilla PHP code, with NO Debian patches applied.
 [2013-05-23 18:30 UTC] aharvey@php.net
-Status: Open +Status: Feedback
 [2013-05-23 18:30 UTC] aharvey@php.net
This is controlled by the display_errors and error_log configuration variables: what do you get on each version if you run php -i | egrep '(display_errors|error_log)' ?

For example, I get:

adamh@swiftdesk7:/tmp$ php -i | egrep '(display_errors|error_log)'
display_errors => STDOUT => STDOUT
error_log => no value => no value

And as you'd expect, errors are output to stdout.
 [2013-05-23 22:21 UTC] weirdan at gmail dot com
-Status: Feedback +Status: Open
 [2013-05-23 22:21 UTC] weirdan at gmail dot com
Even though display_errors is set to STDOUT by default in php 5.3.25:

weirdan@367-dsividov:~/Downloads$ php-5.3.25/sapi/cli/php -i -n | grep 
display_errors
display_errors => STDOUT => STDOUT

(and display_startup_errors are off): 

weirdan@367-dsividov:~/Downloads$ php-5.3.25/sapi/cli/php -i -n | grep 
display_startup
display_startup_errors => Off => Off
weirdan@367-dsividov:~/Downloads$

the following 

weirdan@367-dsividov:~/Downloads$ php-5.3.25/sapi/cli/php -n $(tempfile).php 
2>/dev/null
weirdan@367-dsividov:~/Downloads$ php-5.3.25/sapi/cli/php -n $(tempfile).php
Could not open input file: /tmp/fileLHIKSE.php
weirdan@367-dsividov:~/Downloads$

clearly shows that startup errors are actually going to STDERR

But even I specify errors should go to STDERR, they go to STDOUT in php >= 
5.4.0:


weirdan@367-dsividov:~/Downloads$ for dir in `ls -d php-5* | grep -v tar`; do 
echo -n "$dir: "; $dir/sapi/cli/php -ddisplay_errors=STDERR -
ddisplay_startup_errors=0 -n $(tempfile).php 2>/dev/null; echo; done;

php-5.3.25:
php-5.4.0: Could not open input file: /tmp/filedhceXV.php

php-5.4.15: Could not open input file: /tmp/fileUv3FxW.php

php-5.4.7: Could not open input file: /tmp/fileBH6TsZ.php

weirdan@367-dsividov:~/Downloads$



to me it seems that startup errors started to go to STDOUT (regardless of 
display_errors and display_startup_errors value) in php-5.4.x and you can't 
really control it through either 
display_errors or display_startup_errors:

weirdan@367-dsividov:~/Downloads$ php-5.4.0/sapi/cli/php -
ddisplay_startup_errors=STDERR -ddisplay_errors=STDERR -i | egrep 
'(display_errors|display_startup_errors|error_log)'
display_errors => STDERR => STDERR
display_startup_errors => Off => Off
error_log => no value => no value
weirdan@367-dsividov:~/Downloads$ php-5.3.25/sapi/cli/php -
ddisplay_startup_errors=STDERR -ddisplay_errors=STDERR -i | egrep 
'(display_errors|display_startup_errors|error_log)'
display_errors => STDERR => STDERR
display_startup_errors => Off => Off
error_log => no value => no value
weirdan@367-dsividov:~/Downloads$ php-5.4.0/sapi/cli/php -n -
ddisplay_startup_errors=STDERR -ddisplay_errors=STDERR $(tempfile).php 
2>/dev/null
Could not open input file: /tmp/file7laZhC.php
weirdan@367-dsividov:~/Downloads$ php-5.3.25/sapi/cli/php -n -
ddisplay_startup_errors=STDERR -ddisplay_errors=STDERR $(tempfile).php 
2>/dev/null
weirdan@367-dsividov:~/Downloads$
 [2014-06-26 07:12 UTC] cweiske@php.net
I can confirm this issue on 5.6.0RC1:

$ ./inst/bin/php-5.6.0RC1 -i|grep display_errors
display_errors => STDERR => STDERR
$ ./inst/bin/php-5.6.0RC1 foo.php > /dev/null
$
 [2016-06-21 11:29 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2016-06-21 11:29 UTC] cmb@php.net
I can confirm this issue still exists with latest master. The
culprit appears to be that php_printf() is used[1].

[1] <https://github.com/php/php-src/blob/php-7.0.7/sapi/cli/php_cli.c#L622>
 [2020-08-12 10:36 UTC] ja at lukasruzicka dot cz
I can confirm that the issue still persists in version 7.4.9.

[user.name@server ~]$ php -v
PHP 7.4.9 (cli) (built: Aug  4 2020 08:28:13) ( NTS )
...

[user.name@server ~]$ php -i | egrep '(display_errors|error_log)'
display_errors => STDERR => STDERR
error_log => no value => no value
opcache.error_log => no value => no value

[user.name@server ~]$ php non-existing-file.php > /dev/null

[user.name@server ~]$ php non-existing-file.php
Could not open input file: non-existing-file.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 17:01:30 2024 UTC