|
|
|
@ -590,6 +590,7 @@ static PHP_GINIT_FUNCTION(date) |
|
|
|
{ |
|
|
|
date_globals->default_timezone = NULL; |
|
|
|
date_globals->timezone = NULL; |
|
|
|
date_globals->tzcache = NULL; |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
@ -608,7 +609,7 @@ PHP_RINIT_FUNCTION(date) |
|
|
|
efree(DATEG(timezone)); |
|
|
|
} |
|
|
|
DATEG(timezone) = NULL; |
|
|
|
zend_hash_init(&DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0); |
|
|
|
DATEG(tzcache) = NULL; |
|
|
|
|
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|
@ -621,8 +622,11 @@ PHP_RSHUTDOWN_FUNCTION(date) |
|
|
|
efree(DATEG(timezone)); |
|
|
|
} |
|
|
|
DATEG(timezone) = NULL; |
|
|
|
zend_hash_destroy(&DATEG(tzcache)); |
|
|
|
|
|
|
|
if(DATEG(tzcache)) { |
|
|
|
zend_hash_destroy(DATEG(tzcache)); |
|
|
|
FREE_HASHTABLE(DATEG(tzcache)); |
|
|
|
DATEG(tzcache) = NULL; |
|
|
|
} |
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
@ -804,13 +808,18 @@ static timelib_tzinfo *php_date_parse_tzfile(char *formal_tzname, const timelib_ |
|
|
|
{ |
|
|
|
timelib_tzinfo *tzi, **ptzi; |
|
|
|
|
|
|
|
if (zend_hash_find(&DATEG(tzcache), formal_tzname, strlen(formal_tzname) + 1, (void **) &ptzi) == SUCCESS) { |
|
|
|
if(!DATEG(tzcache)) { |
|
|
|
ALLOC_HASHTABLE(DATEG(tzcache)); |
|
|
|
zend_hash_init(DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0); |
|
|
|
} |
|
|
|
|
|
|
|
if (zend_hash_find(DATEG(tzcache), formal_tzname, strlen(formal_tzname) + 1, (void **) &ptzi) == SUCCESS) { |
|
|
|
return *ptzi; |
|
|
|
} |
|
|
|
|
|
|
|
tzi = timelib_parse_tzfile(formal_tzname, tzdb); |
|
|
|
if (tzi) { |
|
|
|
zend_hash_add(&DATEG(tzcache), formal_tzname, strlen(formal_tzname) + 1, (void *) &tzi, sizeof(timelib_tzinfo*), NULL); |
|
|
|
zend_hash_add(DATEG(tzcache), formal_tzname, strlen(formal_tzname) + 1, (void *) &tzi, sizeof(timelib_tzinfo*), NULL); |
|
|
|
} |
|
|
|
return tzi; |
|
|
|
} |
|
|
|
@ -906,7 +915,7 @@ PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D) |
|
|
|
{ |
|
|
|
char *tz; |
|
|
|
timelib_tzinfo *tzi; |
|
|
|
|
|
|
|
|
|
|
|
tz = guess_timezone(DATE_TIMEZONEDB TSRMLS_CC); |
|
|
|
tzi = php_date_parse_tzfile(tz, DATE_TIMEZONEDB TSRMLS_CC); |
|
|
|
if (! tzi) { |
|
|
|
|