summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2005-12-20 19:54:10 +0000
committerDerick Rethans <derick@php.net>2005-12-20 19:54:10 +0000
commitf0a0f89a2cf6b31068b7b30d60b0b9115384c4aa (patch)
tree71763821aebbed7f43fe5efac0575b31f2a29d94
parent3782a4acf24ada6facde49ccbd590f5a20a0f664 (diff)
downloadphp-git-f0a0f89a2cf6b31068b7b30d60b0b9115384c4aa.tar.gz
- MFH: Fixed bug #35660 (AIX TZ variable format not understood, yields UTC
timezone).
-rw-r--r--NEWS2
-rw-r--r--ext/date/lib/parse_tz.c6
-rw-r--r--ext/date/lib/timelib.h1
-rw-r--r--ext/date/php_date.c29
-rw-r--r--ext/date/tests/date_default_timezone_get-1.phpt4
-rw-r--r--ext/date/tests/date_default_timezone_get-2.phpt2
-rw-r--r--ext/date/tests/date_default_timezone_set-1.phpt4
7 files changed, 29 insertions, 19 deletions
diff --git a/NEWS b/NEWS
index 68cf139dcc..2402864544 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,8 @@ PHP NEWS
only). (Tony)
- Fixed bug #35690 (pack() tries to allocate huge memory block when packing
float values to strings). (Tony)
+- Fixed bug #35660 (AIX TZ variable format not understood, yields UTC
+ timezone). (Derick)
- Fixed bug #35655 (whitespace following end of heredoc is lost). (Ilia)
- Fixed bug #35630 (strtotime() crashes on certain relative identifiers).
(Ilia)
diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c
index f4eaee36b5..0980af07cc 100644
--- a/ext/date/lib/parse_tz.c
+++ b/ext/date/lib/parse_tz.c
@@ -238,6 +238,12 @@ timelib_tzdb_index_entry *timelib_timezone_builtin_identifiers_list(int *count)
return timezonedb_idx_builtin;
}
+int timelib_timezone_id_is_valid(char *timezone, timelib_tzdb *tzdb)
+{
+ char *tzf;
+ return (seek_to_tz_position((char**) &tzf, timezone, tzdb));
+}
+
timelib_tzinfo *timelib_parse_tzfile(char *timezone, timelib_tzdb *tzdb)
{
char *tzf;
diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h
index 0b2f0fe0ee..b73a31bfa1 100644
--- a/ext/date/lib/timelib.h
+++ b/ext/date/lib/timelib.h
@@ -67,6 +67,7 @@ void timelib_update_from_sse(timelib_time *tm);
void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz);
/* From parse_tz.c */
+int timelib_timezone_id_is_valid(char *timezone, timelib_tzdb *tzdb);
timelib_tzinfo *timelib_parse_tzfile(char *timezone, timelib_tzdb *tzdb);
int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz);
timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *tz);
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 67f8e22bf1..690ec5a869 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -99,7 +99,7 @@ zend_function_entry date_funcs_timezone[] = {
static void date_register_classes(TSRMLS_D);
#endif
-static char* guess_timezone(TSRMLS_D);
+static char* guess_timezone(timelib_tzdb *tzdb TSRMLS_DC);
/* }}} */
ZEND_DECLARE_MODULE_GLOBALS(date)
@@ -225,7 +225,9 @@ PHP_RSHUTDOWN_FUNCTION(date)
#define DATE_TZ_ERRMSG \
"It is not safe to rely on the system's timezone settings. Please use " \
"the date.timezone setting, the TZ environment variable or the " \
- "date_default_timezone_set() function. "
+ "date_default_timezone_set() function. In case you used any of those " \
+ "methods and you are still getting this warning, you most likely " \
+ "misspelled the timezone identifier. "
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(date)
@@ -271,7 +273,7 @@ PHP_MINFO_FUNCTION(date)
php_info_print_table_row(2, "date/time support", "enabled");
php_info_print_table_row(2, "Timezone Database Version", tzdb->version);
php_info_print_table_row(2, "Timezone Database", php_date_global_timezone_db_enabled ? "external" : "internal");
- php_info_print_table_row(2, "Default timezone", guess_timezone(TSRMLS_C));
+ php_info_print_table_row(2, "Default timezone", guess_timezone(tzdb TSRMLS_CC));
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
@@ -296,21 +298,21 @@ static timelib_tzinfo *php_date_parse_tzfile(char *formal_tzname, timelib_tzdb *
/* }}} */
/* {{{ Helper functions */
-static char* guess_timezone(TSRMLS_D)
+static char* guess_timezone(timelib_tzdb *tzdb TSRMLS_DC)
{
char *env;
/* Checking configure timezone */
- if (DATEG(timezone) && (strlen(DATEG(timezone)) > 0)) {
+ if (DATEG(timezone) && (strlen(DATEG(timezone)) > 0) && timelib_timezone_id_is_valid(DATEG(timezone), tzdb)) {
return DATEG(timezone);
}
/* Check environment variable */
env = getenv("TZ");
- if (env && *env) {
+ if (env && *env && timelib_timezone_id_is_valid(env, tzdb)) {
return env;
}
/* Check config setting for default timezone */
- if (DATEG(default_timezone) && (strlen(DATEG(default_timezone)) > 0)) {
+ if (DATEG(default_timezone) && (strlen(DATEG(default_timezone)) > 0) && timelib_timezone_id_is_valid(DATEG(default_timezone), tzdb)) {
return DATEG(default_timezone);
}
#if HAVE_TM_ZONE
@@ -376,15 +378,10 @@ PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D)
char *tz;
timelib_tzinfo *tzi;
- tz = guess_timezone(TSRMLS_C);
+ tz = guess_timezone(DATE_TIMEZONEDB TSRMLS_CC);
tzi = php_date_parse_tzfile(tz, DATE_TIMEZONEDB TSRMLS_CC);
if (! tzi) {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Timezone setting (date.timezone) or TZ environment variable contains an unknown timezone");
- tzi = php_date_parse_tzfile("UTC", DATE_TIMEZONEDB TSRMLS_CC);
-
- if (! tzi) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Timezone database is corrupt - this should *never* happen!");
- }
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Timezone database is corrupt - this should *never* happen!");
}
return tzi;
}
@@ -1633,6 +1630,10 @@ PHP_FUNCTION(date_default_timezone_set)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &zone, &zone_len) == FAILURE) {
RETURN_FALSE;
}
+ if (!timelib_timezone_id_is_valid(zone, DATE_TIMEZONEDB)) {
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Timezone ID '%s' is invalid", zone);
+ RETURN_FALSE;
+ }
if (DATEG(timezone)) {
efree(DATEG(timezone));
DATEG(timezone) = NULL;
diff --git a/ext/date/tests/date_default_timezone_get-1.phpt b/ext/date/tests/date_default_timezone_get-1.phpt
index d3508290ad..b6494658e4 100644
--- a/ext/date/tests/date_default_timezone_get-1.phpt
+++ b/ext/date/tests/date_default_timezone_get-1.phpt
@@ -9,8 +9,8 @@ date.timezone=
echo date('e'), "\n";
?>
--EXPECTF--
-Strict Standards: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_get-1.php on line 3
+Strict Standards: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_get-1.php on line 3
UTC
-Strict Standards: date(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_get-1.php on line 4
+Strict Standards: date(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_get-1.php on line 4
UTC
diff --git a/ext/date/tests/date_default_timezone_get-2.phpt b/ext/date/tests/date_default_timezone_get-2.phpt
index 3fef097885..73013a7626 100644
--- a/ext/date/tests/date_default_timezone_get-2.phpt
+++ b/ext/date/tests/date_default_timezone_get-2.phpt
@@ -8,5 +8,5 @@ date.timezone=CEST
echo date_default_timezone_get(), "\n";
?>
--EXPECTF--
-Notice: date_default_timezone_get(): Timezone setting (date.timezone) or TZ environment variable contains an unknown timezone in %sdate_default_timezone_get-2.php on line 3
+Strict Standards: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_get-2.php on line 3
UTC
diff --git a/ext/date/tests/date_default_timezone_set-1.phpt b/ext/date/tests/date_default_timezone_set-1.phpt
index 78face70a7..3c7a9aa4d6 100644
--- a/ext/date/tests/date_default_timezone_set-1.phpt
+++ b/ext/date/tests/date_default_timezone_set-1.phpt
@@ -18,9 +18,9 @@ date.timezone=
echo date(DATE_ISO8601, $date4), "\n";
?>
--EXPECTF--
-Strict Standards: strtotime(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_set-1.php on line 3
+Strict Standards: strtotime(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_set-1.php on line 3
-Strict Standards: strtotime(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_set-1.php on line 4
+Strict Standards: strtotime(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_set-1.php on line 4
America/Indiana/Knox
2005-01-12T03:00:00-0500
2005-07-12T03:00:00-0500