]> 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 3b8f12216fcf101c676c5b49b0f9c1a492235b19..c4fd137f4c4c317bf985d5328524ad660ebed200 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,10 @@ PHP                                                                        NEWS
     resource). (Laruence)
   . Fixed bug #55759 (memory leak when using built-in server). (Laruence)
 
+- Improved PHP-FPM SAPI:
+  . enhance error log when the primary script can't be open. FR #60199. (fat)
+
+
 11 Nov 2011, PHP 5.4.0 RC1
 - General improvements:
   . Changed silent conversion of array to string to produce a notice. (Patrick)
index 6ad53df4f19fc06a8f6431f18449c42dc9dc0c67..fd453668eeaf1774a30f6d6bf9243013da049a78 100644 (file)
@@ -1785,6 +1785,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();
 
@@ -1810,7 +1811,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;
@@ -1822,9 +1825,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");
@@ -1846,6 +1856,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);
                        }