ID: 22796 User updated by: gk at proliberty dot com -Summary: Error messages go to stdout; lost with -r option Reported By: gk at proliberty dot com Status: Open Bug Type: CGI related Operating System: linux RH 7.2 PHP Version: 4CVS-2003-03-19 (stable) New Comment:
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. Previous Comments: ------------------------------------------------------------------------ [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"; ?> ------------------------------------------------------------------------ [2003-03-21 17:13:42] [EMAIL PROTECTED] Try this with latest stable snapshot: # rm config.cache # ./configure --disable-all --disable-cgi && make clean && make # sapi/cli/php -n -r "require('test.php');" I think you're just doing something wrong / have something setup very differently in your server.. ------------------------------------------------------------------------ [2003-03-21 13:42:24] gk at proliberty dot com I have tried your suggestion same test file and with: php4-STABLE-200303210630 (March 21) I get the same results: [EMAIL PROTECTED] junk]$ php -n -r 'require("junk.php");' begin [EMAIL PROTECTED] junk]$ php -r 'require("junk.php");' begin [EMAIL PROTECTED] junk]$ php junk.php begin Fatal error: Call to undefined function: f() in /usr/local/apache/htdocs/common/test/junk/junk.php on line 3 [EMAIL PROTECTED] junk]$ Perhaps the difference is in our configure options. Mine are: ./configure --with-dom --with-zlib-dir=/usr/include --with-mysql=/usr/local/mysql --with-apxs=/usr/local/apache/bin/apxs --with-xml --enable-track-vars Please let me know if we need to split this but into two: have you tested the issue of error messages not going to /dev/stderr or only the -r issue? ------------------------------------------------------------------------ [2003-03-20 18:33:17] [EMAIL PROTECTED] I can not reproduce this with the latest stable snapshot: # php -n -r 'require("test.php");' begin /home/jani/test.php(3) : Fatal error - Call to undefined function: f() Try this. ('-n' is for not using any php.ini) ------------------------------------------------------------------------ [2003-03-20 01:57:17] gk at proliberty dot com I am using GNU bash, version 2.05.8(1)-release (i386-redhat-linux-gnu) It isn't just FATAL messages that are lost with -r option, warnings also vanish into the bit-bucket. #FILE: junk.php <?php include("non_existent_file"); ?> #OUTPUT: [EMAIL PROTECTED] junk]$ php -r 'include("junk.php");' [EMAIL PROTECTED] junk]$ php junk.php Warning: main(non_existent_file): failed to open stream: No such file or directory in /usr/local/apache/htdocs/common/test/junk/junk.php on line 3 Warning: main(): Failed opening 'non_existent_file' for inclusion (include_path='.:/usr/local/apache/htdocs/common/php:/usr/local/lib/php') in /usr/local/apache/htdocs/common/test/junk/junk.php on line 3 [EMAIL PROTECTED] junk]$ ------------------------------------------------------------------------ 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