]> granicus.if.org Git - php/commitdiff
Fixed bug #49627 (error_log to specified file does not log time according to date...
authorDmitry Stogov <dmitry@php.net>
Mon, 5 Oct 2009 13:56:49 +0000 (13:56 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 5 Oct 2009 13:56:49 +0000 (13:56 +0000)
NEWS
ext/date/php_date.c
main/main.c
main/php_globals.h

diff --git a/NEWS b/NEWS
index 50cc72f7f9acdceaec25249ae9695bc026539eb7..96aac69db96f6a1317094dc2947b8ac43196a1b0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@
 - Fixed bug #49698 (Unexpected change in strnatcasecmp()). (Rasmus)
 - Fixed bug #49647 (DOMUserData does not exist). (Rob)
 - Fixed bug #49630 (imap_listscan function missing). (Felipe)
+- Fixed bug #49627 (error_log to specified file does not log time according
+  to date.timezone). (Dmitry)
 - Fixed bug #49578 (make install-pear fails). (Hannes)
 - Fixed bug #49536 (mb_detect_encoding() returns incorrect results when
   mbstring.strict_mode is turned on). (Moriyoshi)
index ac344a1e1e7853494e447ec73875d7892ceeabc2..e4771975b1c136fcd1d324b0a56deecf5301b005 100644 (file)
@@ -596,7 +596,17 @@ static char* guess_timezone(const timelib_tzdb *tzdb TSRMLS_DC)
                return env;
        }
        /* Check config setting for default timezone */
-       if (DATEG(default_timezone) && (strlen(DATEG(default_timezone)) > 0) && timelib_timezone_id_is_valid(DATEG(default_timezone), tzdb)) {
+       if (!DATEG(default_timezone)) {
+               /* Special case: ext/date wasn't initialized yet */
+               zval ztz;
+               
+               if (SUCCESS == zend_get_configuration_directive("date.timezone", sizeof("date.timezone"), &ztz) &&
+                   Z_TYPE(ztz) == IS_STRING &&
+                   Z_STRLEN(ztz) > 0 &&
+                   timelib_timezone_id_is_valid(Z_STRVAL(ztz), tzdb)) {
+                       return Z_STRVAL(ztz);
+               }
+       } else if (*DATEG(default_timezone) && timelib_timezone_id_is_valid(DATEG(default_timezone), tzdb)) {
                return DATEG(default_timezone);
        }
 #if HAVE_TM_ZONE
index cfb8b531de48d169d5a5b795f8913757fde502ba..c47dffed3f151937fa69a4b95719e29b622ef63d 100644 (file)
@@ -489,11 +489,18 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
        int fd = -1;
        time_t error_time;
 
+       if (PG(in_error_log)) {
+               /* prevent recursive invocation */
+               return;
+       }
+       PG(in_error_log) = 1;
+
        /* Try to use the specified logging location. */
        if (PG(error_log) != NULL) {
 #ifdef HAVE_SYSLOG_H
                if (!strcmp(PG(error_log), "syslog")) {
                        php_syslog(LOG_NOTICE, "%.500s", log_message);
+                       PG(in_error_log) = 0;
                        return;
                }
 #endif
@@ -504,7 +511,7 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
                        char *error_time_str;
 
                        time(&error_time);
-                       error_time_str = php_format_date("d-M-Y H:i:s", 11, error_time, php_during_module_startup() TSRMLS_CC);
+                       error_time_str = php_format_date("d-M-Y H:i:s", 11, error_time, 1 TSRMLS_CC);
                        len = spprintf(&tmp, 0, "[%s] %s%s", error_time_str, log_message, PHP_EOL);
 #ifdef PHP_WIN32
                        php_flock(fd, 2);
@@ -513,6 +520,7 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
                        efree(tmp);
                        efree(error_time_str);
                        close(fd);
+                       PG(in_error_log) = 0;
                        return;
                }
        }
@@ -522,6 +530,7 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
        if (sapi_module.log_message) {
                sapi_module.log_message(log_message);
        }
+       PG(in_error_log) = 0;
 }
 /* }}} */
 
@@ -1255,6 +1264,7 @@ int php_request_startup(TSRMLS_D)
 #endif
 
        zend_try {
+               PG(in_error_log) = 0;
                PG(during_request_startup) = 1;
 
                php_output_activate(TSRMLS_C);
index 363ea42eb1c01f15930b2107e708ae5e7babf98d..1f3c52bf4d12fd4e9c3391e844866cc172737ff6 100644 (file)
@@ -161,6 +161,7 @@ struct _php_core_globals {
 #endif
        long max_input_nesting_level;
        zend_bool in_user_include;
+       zend_bool in_error_log;
 };