Skip to content

Commit 26b1572

Browse files
committed
Move date timezone cache destruction to post deactivate
Some extensions try to use the date features in their own shutdown, most notably some logging functions. Because of that, move the cache tear down until after these resources have been cleaned up.
1 parent bcb89c7 commit 26b1572

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

ext/date/php_date.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ zend_module_entry date_module_entry = {
698698
PHP_MODULE_GLOBALS(date), /* globals descriptor */
699699
PHP_GINIT(date), /* globals ctor */
700700
NULL, /* globals dtor */
701-
NULL, /* post deactivate */
701+
ZEND_MODULE_POST_ZEND_DEACTIVATE_N(date), /* post deactivate */
702702
STANDARD_MODULE_PROPERTIES_EX
703703
};
704704
/* }}} */
@@ -743,19 +743,26 @@ PHP_RSHUTDOWN_FUNCTION(date)
743743
efree(DATEG(timezone));
744744
}
745745
DATEG(timezone) = NULL;
746-
if(DATEG(tzcache)) {
746+
747+
return SUCCESS;
748+
}
749+
/* }}} */
750+
751+
ZEND_MODULE_POST_ZEND_DEACTIVATE_D(date)
752+
{
753+
if (DATEG(tzcache)) {
747754
zend_hash_destroy(DATEG(tzcache));
748755
FREE_HASHTABLE(DATEG(tzcache));
749756
DATEG(tzcache) = NULL;
750757
}
758+
751759
if (DATEG(last_errors)) {
752760
timelib_error_container_dtor(DATEG(last_errors));
753761
DATEG(last_errors) = NULL;
754762
}
755763

756764
return SUCCESS;
757765
}
758-
/* }}} */
759766

760767
#define DATE_TIMEZONEDB php_date_global_timezone_db ? php_date_global_timezone_db : timelib_builtin_db()
761768

ext/date/php_date.h

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ PHP_RSHUTDOWN_FUNCTION(date);
123123
PHP_MINIT_FUNCTION(date);
124124
PHP_MSHUTDOWN_FUNCTION(date);
125125
PHP_MINFO_FUNCTION(date);
126+
ZEND_MODULE_POST_ZEND_DEACTIVATE_D(date);
126127

127128
typedef struct _php_date_obj php_date_obj;
128129
typedef struct _php_timezone_obj php_timezone_obj;

0 commit comments

Comments
 (0)