Skip to content

Commit

Permalink
Move date timezone cache destruction to post deactivate
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
derickr committed Jul 19, 2021
1 parent bcb89c7 commit 26b1572
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ zend_module_entry date_module_entry = {
PHP_MODULE_GLOBALS(date), /* globals descriptor */
PHP_GINIT(date), /* globals ctor */
NULL, /* globals dtor */
NULL, /* post deactivate */
ZEND_MODULE_POST_ZEND_DEACTIVATE_N(date), /* post deactivate */
STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
Expand Down Expand Up @@ -743,19 +743,26 @@ PHP_RSHUTDOWN_FUNCTION(date)
efree(DATEG(timezone));
}
DATEG(timezone) = NULL;
if(DATEG(tzcache)) {

return SUCCESS;
}
/* }}} */

ZEND_MODULE_POST_ZEND_DEACTIVATE_D(date)
{
if (DATEG(tzcache)) {
zend_hash_destroy(DATEG(tzcache));
FREE_HASHTABLE(DATEG(tzcache));
DATEG(tzcache) = NULL;
}

if (DATEG(last_errors)) {
timelib_error_container_dtor(DATEG(last_errors));
DATEG(last_errors) = NULL;
}

return SUCCESS;
}
/* }}} */

#define DATE_TIMEZONEDB php_date_global_timezone_db ? php_date_global_timezone_db : timelib_builtin_db()

Expand Down
1 change: 1 addition & 0 deletions ext/date/php_date.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ PHP_RSHUTDOWN_FUNCTION(date);
PHP_MINIT_FUNCTION(date);
PHP_MSHUTDOWN_FUNCTION(date);
PHP_MINFO_FUNCTION(date);
ZEND_MODULE_POST_ZEND_DEACTIVATE_D(date);

typedef struct _php_date_obj php_date_obj;
typedef struct _php_timezone_obj php_timezone_obj;
Expand Down

0 comments on commit 26b1572

Please sign in to comment.