]> granicus.if.org Git - php/commitdiff
- FR #60199 (enhance FPM error log when the primary script can't be open)
authorJérôme Loyet <fat@php.net>
Tue, 15 Nov 2011 22:29:59 +0000 (22:29 +0000)
committerJérôme Loyet <fat@php.net>
Tue, 15 Nov 2011 22:29:59 +0000 (22:29 +0000)
NEWS
sapi/fpm/fpm/fpm_main.c

diff --git a/NEWS b/NEWS
index 1d574c1a94c5052909f91eb75d3fc750d9f13567..074b6f71e0606a803d234476c0621f0c3ebc0af0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ PHP                                                                        NEWS
 
 - PHP-FPM SAPI:
   . Fixed bug #60179 (php_flag and php_value does not work properly). (fat)
+  . enhance error log when the primary script can't be open. FR #60199. (fat)
 
 - Intl:
   . Fixed bug #60192 (SegFault when Collator not constructed
index f6fdc6e8b9f6de41efc4f40d21fa33f8740e3d4a..1d3488a1b80a33491938161bd8380380f98b9b10 100644 (file)
@@ -1787,6 +1787,7 @@ consult the installation file that came with this distribution, or visit \n\
                        SG(server_context) = (void *) &request;
                        init_request_info(TSRMLS_C);
                        CG(interactive) = 0;
+                       char *primary_script = NULL;
 
                        fpm_request_info();
 
@@ -1812,7 +1813,9 @@ consult the installation file that came with this distribution, or visit \n\
                        /* If path_translated is NULL, terminate here with a 404 */
                        if (!SG(request_info).path_translated) {
                                zend_try {
+                                       zlog(ZLOG_DEBUG, "Primary script unknown");
                                        SG(sapi_headers).http_response_code = 404;
+                                       PUTS("File not found.\n");
                                } zend_catch {
                                } zend_end_try();
                                goto fastcgi_request_done;
@@ -1824,9 +1827,16 @@ consult the installation file that came with this distribution, or visit \n\
                                goto fastcgi_request_done;
                        }
 
+                       /* 
+                        * have to duplicate SG(request_info).path_translated to be able to log errrors
+                        * php_fopen_primary_script seems to delete SG(request_info).path_translated on failure
+                        */
+                       primary_script = estrdup(SG(request_info).path_translated);
+
                        /* path_translated exists, we can continue ! */
                        if (php_fopen_primary_script(&file_handle TSRMLS_CC) == FAILURE) {
                                zend_try {
+                                       zlog(ZLOG_ERROR, "Unable to open primary script: %s (%s)", primary_script, strerror(errno));
                                        if (errno == EACCES) {
                                                SG(sapi_headers).http_response_code = 403;
                                                PUTS("Access denied.\n");
@@ -1848,6 +1858,10 @@ consult the installation file that came with this distribution, or visit \n\
                        php_execute_script(&file_handle TSRMLS_CC);
 
 fastcgi_request_done:
+                       if (primary_script) {
+                               efree(primary_script);
+                       }
+
                        if (request_body_fd != -1) {
                                close(request_body_fd);
                        }