#28074 [Csd->Opn]: Fast CGI standard compliance : stderr should be written in a FCGI stderr stream

From: Date: Thu, 21 Apr 2005 09:43:52 +0000
Subject: #28074 [Csd->Opn]: Fast CGI standard compliance : stderr should be written in a FCGI stderr stream
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-77978@lists.php.net to get a copy of this message
ID: 28074 Updated by: sas@php.net Reported By: bogus_idp at yahoo dot fr -Status: Closed +Status: Open Bug Type: CGI related Operating System: * PHP Version: 4CVS, 5CVS (2005-01-10) New Comment: This is an ugly change for users who redirect PHP's stderr to a log file due to file permissions (PHP is not allowed to open the log file). Instead of writing to the log file, the Apache log now contains tons of rows like this: [Thu Apr 21 11:18:27 2005] [error] [client 129.0.10.119] FastCGI: server "/home/www/PHP/php/bin/php" stderr: array ( [Thu Apr 21 11:18:27 2005] [error] [client 129.0.10.119] FastCGI: server "/home/www/PHP/php/bin/php" stderr: 'rcs' => [Thu Apr 21 11:18:27 2005] [error] [client 129.0.10.119] FastCGI: server "/home/www/PHP/php/bin/php" stderr: array ( etc. This needs to be addressed -- make logging to fastcgi's stderr optional. Previous Comments: ------------------------------------------------------------------------ [2005-01-10 16:39:37] sniper@php.net This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. ------------------------------------------------------------------------ [2005-01-10 16:01:29] chris at ex-parrot dot com This one turns out to be easy to fix, thus: --- cgi_main.c.orig Mon Jan 10 14:57:04 2005 +++ cgi_main.c Mon Jan 10 14:53:44 2005 @@ -481,7 +481,14 @@ static void sapi_cgi_log_message(char *message) { - fprintf(stderr, "%s\n", message); +#if PHP_FASTCGI + if (!FCGX_IsCGI()) { + FCGX_Request *request = (FCGX_Request *)SG(server_context); + FCGX_FPrintF( request->err, "%s\n", message ); + /* ignore return code */ + } else +#endif /* PHP_FASTCGI */ + fprintf(stderr, "%s\n", message); } static int sapi_cgi_deactivate(TSRMLS_D) However, there is another similar bug, which is that a stream opened on "php://stderr" should also direct its output to the FCGI error stream (rather than just to file descriptor #2). -- Chris Lightfoot ------------------------------------------------------------------------ [2004-04-20 15:55:00] derick@php.net Assigning to Shane, the maintainer of this SAPI module. ------------------------------------------------------------------------ [2004-04-20 12:03:30] bogus_idp at yahoo dot fr Description: ------------ The Fast CGI standard require that error be reported through the FastCGI connection as a Stderr data stream. But PHP Fast CGI processes still write errors to original stderr (file handle 3) which prevent from clean standard centralized FCGI logging, especially when the Fast CGI PHP process is not started by the web server (remote Fast CGI). In most cases, it makes debugging PHP scripts impossible. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28074&edit=1

« previous php.bugs (#77978) next »