php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28074 Fast CGI standard compliance : stderr should be written in a FCGI stderr stream
Submitted: 2004-04-20 12:03 UTC Modified: 2005-04-28 15:17 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bogus_idp at yahoo dot fr Assigned:
Status: Closed Package: CGI/CLI related
PHP Version: 4CVS, 5CVS (2005-01-10) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bogus_idp at yahoo dot fr
New email:
PHP Version: OS:

 

 [2004-04-20 12:03 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-10 16:01 UTC] 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
 [2005-04-21 11:43 UTC] sas@php.net
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.

 [2005-04-28 12:58 UTC] sniper@php.net
Feel free to fix it then.

 [2005-04-28 15:17 UTC] sniper@php.net
Added fastcgi.logging php.ini option to make it possible for people like Sascha to disable this.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 16:01:33 2024 UTC