ID: 22796 User updated by: gk at proliberty dot com Reported By: gk at proliberty dot com -Status: Feedback +Status: Open Bug Type: CGI related Operating System: linux RH 7.2 PHP Version: 4CVS-2003-03-19 (stable) Assigned To: helly New Comment:
OK. Now this is starting to make some sense, thanks to michael's last comment: >The message starting with "Fatal error:" goes to stdout, the other two to stderr. The whole issue here now is php.ini config. It is confusing in this particular example since there are THREE different errors for the same code input, two generated at startup, one later; two go to /dev/stderr, one to /dev/stdout. The issue is further complicated with the precedence of -c and -d options on the command line I think, but that will be discussed elsewhere.... [EMAIL PROTECTED] php4-STABLE-200303241830]# sapi/cli/php -c $(pwd)/php.ini-recommended -r 'f();' PHP Fatal error: Call to undefined function: f() in Command line code on line 1 The above error is generated with .ini file settings: display_startup_errors = Off display_errors = Off log_errors = On ;error_log = filename So the error_log file must default to /dev/stderr Hence, this bug should be CLOSED now since the error IS displayed, if log_erros = On. The other error messages below appear to be startup errors, require display_startup_errors=On [EMAIL PROTECTED] php4-STABLE-200303241830]# sapi/cli/php -c $(pwd)/php.ini-dist -r 'f();' [EMAIL PROTECTED] php4-STABLE-200303241830]# sapi/cli/php -c $(pwd)/php.ini-dist -i|grep php.ini Configuration File (php.ini) Path => /usr/local/src/php4-STABLE-200303241830/php.ini-dist [EMAIL PROTECTED] php4-STABLE-200303241830]# sapi/cli/php -d log_errors=1 -d error_log=/dev/stderr -d display_startup_errors=On -r 'f();' [24-Mar-2003 14:34:21] PHP Fatal error: Call to undefined function: f() in Command line code on line 1 [EMAIL PROTECTED] php4-STABLE-200303241830]# sapi/cli/php -d log_errors=1 -d error_log=/dev/stderr -d display_startup_errors=On -r 'f();' 2>/dev/null [EMAIL PROTECTED] php4-STABLE-200303241830]# sapi/cli/php -d log_errors=1 -d error_log=/dev/stderr -d display_startup_errors=1 -r 'f();' 2>/dev/null Fatal error: Call to undefined function: f() in Command line code on line 1 [EMAIL PROTECTED] php4-STABLE-200303241830]# Previous Comments: ------------------------------------------------------------------------ [2003-03-24 10:37:37] michael dot mauch at gmx dot de With php4-STABLE-200303241430 (and with 4.3.1), I can get even three error messages for the same error. # sapi/cli/php -c php.ini-dist -r 'f();' Command line code(1) : Fatal error - Call to undefined function: f() # sapi/cli/php -c php.ini-recommended -r 'f();' PHP Fatal error: Call to undefined function: f() in Command line code on line 1 Command line code(1) : Fatal error - Call to undefined function: f() # sed 's/\(display_.*errors = \)Off/\1On/' <php.ini-recommended >php.ini-display-errors # sapi/cli/php -c php.ini-display-errors -r 'f();' PHP Fatal error: Call to undefined function: f() in Command line code on line 1 Command line code(1) : Fatal error - Call to undefined function: f() Fatal error: Call to undefined function: f() in Command line code on line 1 This last php.ini is with display_errors and display_startup_errors = On. The message starting with "Fatal error:" goes to stdout, the other two to stderr. ------------------------------------------------------------------------ [2003-03-24 04:12:26] [EMAIL PROTECTED] And get first the latest stable snapshot again. ------------------------------------------------------------------------ [2003-03-24 04:11:54] [EMAIL PROTECTED] # php -r "f();" Command line code(1) : Fatal error - Call to undefined function: f() This is what I get when using the php.ini-dist from the latest stable CVS snapshot. As you can see, we get totally different style of error messages too. Please try with the plain, unmodified php.ini-dist instead of your current php.ini. ------------------------------------------------------------------------ [2003-03-24 02:11:34] gk at proliberty dot com I split this bug into two; changed the title to better reflect what I have learned: it is possible to work around this bug by changing the default value of display_startup_errors in php.ini: --- #default value #display_startup_errors = Off display_startup_errors = On --- Now I get the proper error message: [EMAIL PROTECTED] php4-STABLE-200303210630]# sapi/cli/php -r "f();" Fatal error: Call to undefined function: f() in Command line code on line Following sniper's advice of using -n to prevent reading php.ini has the same effect for me as display_startup_errors = Off; apparently it doesn't have the same result for sniper. Odd. ------------------------------------------------------------------------ [2003-03-21 20:09:38] gk at proliberty dot com I built it again, per your instructions and get the same result: [EMAIL PROTECTED] php4-STABLE-200303210630]# sapi/cli/php -n -r "require('/htdocs/common/test/junk/junk.php');" begin [EMAIL PROTECTED] php4-STABLE-200303210630]# Do I need a more recent snapshot than that? I'm using the same test file: /htdocs/common/test/junk/junk.php: <?php echo "begin\n"; f(); // undefined function; fatal error echo "end\n"; ?> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/22796 -- Edit this bug report at http://bugs.php.net/?id=22796&edit=1