From b52a9ec52e796b3e340a7193cdccd4e11e182b6b Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 28 Feb 2019 11:46:40 +0100 Subject: test build for pending PR --- 45.patch | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 45.patch (limited to '45.patch') diff --git a/45.patch b/45.patch new file mode 100644 index 0000000..4ba34e6 --- /dev/null +++ b/45.patch @@ -0,0 +1,184 @@ +From 53d972905a9f36edd86daf7381e5a9d3f99a962c Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 28 Feb 2019 11:34:36 +0100 +Subject: [PATCH] fix for ZTS + +--- + timecop_php7.c | 61 ++++++++++++++++++++++++++++---------------------- + 1 file changed, 34 insertions(+), 27 deletions(-) + +diff --git a/timecop_php7.c b/timecop_php7.c +index 8d7faec..ea912f2 100644 +--- a/timecop_php7.c ++++ b/timecop_php7.c +@@ -311,12 +311,17 @@ static inline void _call_php_function_with_2_params(const char *function_name, z + static void _call_php_function_with_3_params(const char *function_name, zval *retval_ptr, zval *arg1, zval *arg2, zval *arg3); + static inline void _call_php_function_with_params(const char *function_name, zval *retval_ptr, uint32_t param_count, zval params[]); + ++static const zend_module_dep timecop_module_deps[] = { ++ ZEND_MOD_REQUIRED("Date") ++ ZEND_MOD_END ++}; ++ + /* {{{ timecop_module_entry + */ + zend_module_entry timecop_module_entry = { +-#if ZEND_MODULE_API_NO >= 20010901 +- STANDARD_MODULE_HEADER, +-#endif ++ STANDARD_MODULE_HEADER_EX, ++ NULL, ++ timecop_module_deps, + "timecop", + timecop_functions, + PHP_MINIT(timecop), +@@ -355,6 +360,14 @@ PHP_MINIT_FUNCTION(timecop) + ZEND_INIT_MODULE_GLOBALS(timecop, timecop_globals_ctor, NULL); + REGISTER_INI_ENTRIES(); + register_timecop_classes(); ++ ++ if (TIMECOP_G(func_override)) { ++ if (SUCCESS != timecop_func_override() || ++ SUCCESS != timecop_class_override()) { ++ return FAILURE; ++ } ++ } ++ + return SUCCESS; + } + /* }}} */ +@@ -364,6 +377,12 @@ PHP_MINIT_FUNCTION(timecop) + PHP_MSHUTDOWN_FUNCTION(timecop) + { + UNREGISTER_INI_ENTRIES(); ++ ++ if (TIMECOP_G(func_override)) { ++ timecop_func_override_clear(); ++ timecop_class_override_clear(); ++ } ++ + return SUCCESS; + } + /* }}} */ +@@ -375,13 +394,6 @@ PHP_RINIT_FUNCTION(timecop) + ZEND_TSRMLS_CACHE_UPDATE(); + #endif + +- if (TIMECOP_G(func_override)) { +- if (SUCCESS != timecop_func_override() || +- SUCCESS != timecop_class_override()) { +- return FAILURE; +- } +- } +- + return SUCCESS; + } + /* }}} */ +@@ -389,11 +401,6 @@ PHP_RINIT_FUNCTION(timecop) + /* {{{ PHP_RSHUTDOWN_FUNCTION(timecop) */ + PHP_RSHUTDOWN_FUNCTION(timecop) + { +- if (TIMECOP_G(func_override)) { +- timecop_func_override_clear(); +- timecop_class_override_clear(); +- } +- + if (Z_TYPE(TIMECOP_G(orig_request_time)) == IS_NULL) { + restore_request_time(); + } +@@ -496,14 +503,14 @@ static int timecop_func_override() + + p = &(timecop_override_func_table[0]); + while (p->orig_func != NULL) { +- zf_orig = zend_hash_str_find_ptr(EG(function_table), p->orig_func, strlen(p->orig_func)); ++ zf_orig = zend_hash_str_find_ptr(CG(function_table), p->orig_func, strlen(p->orig_func)); + if (zf_orig == NULL) { + /* Do nothing. Because some functions are introduced by optional extensions. */ + p++; + continue; + } + +- zf_ovrd = zend_hash_str_find_ptr(EG(function_table), p->ovrd_func, strlen(p->ovrd_func)); ++ zf_ovrd = zend_hash_str_find_ptr(CG(function_table), p->ovrd_func, strlen(p->ovrd_func)); + if (zf_ovrd == NULL) { + php_error_docref("https://github.com/hnw/php-timecop", E_WARNING, + "timecop couldn't find function %s.", p->ovrd_func); +@@ -511,7 +518,7 @@ static int timecop_func_override() + continue; + } + +- zf_save = zend_hash_str_find_ptr(EG(function_table), p->save_func, strlen(p->save_func)); ++ zf_save = zend_hash_str_find_ptr(CG(function_table), p->save_func, strlen(p->save_func)); + if (zf_save != NULL) { + php_error_docref("https://github.com/hnw/php-timecop", E_WARNING, + "timecop couldn't create function %s because already exists.", +@@ -523,12 +530,12 @@ static int timecop_func_override() + TIMECOP_ASSERT(zf_orig->type == ZEND_INTERNAL_FUNCTION); + TIMECOP_ASSERT(zf_ovrd->type == ZEND_INTERNAL_FUNCTION); + +- zend_hash_str_add_mem(EG(function_table), p->save_func, strlen(p->save_func), ++ zend_hash_str_add_mem(CG(function_table), p->save_func, strlen(p->save_func), + zf_orig, sizeof(zend_internal_function)); + function_add_ref(zf_orig); + + GUARD_FUNCTION_ARG_INFO_BEGIN(zf_orig); +- zend_hash_str_update_mem(EG(function_table), p->orig_func, strlen(p->orig_func), ++ zend_hash_str_update_mem(CG(function_table), p->orig_func, strlen(p->orig_func), + zf_ovrd, sizeof(zend_internal_function)); + GUARD_FUNCTION_ARG_INFO_END(); + function_add_ref(zf_ovrd); +@@ -546,7 +553,7 @@ static int timecop_class_override() + + p = &(timecop_override_class_table[0]); + while (p->orig_class != NULL) { +- ce_orig = zend_hash_str_find_ptr(EG(class_table), p->orig_class, strlen(p->orig_class)); ++ ce_orig = zend_hash_str_find_ptr(CG(class_table), p->orig_class, strlen(p->orig_class)); + if (ce_orig == NULL) { + php_error_docref("https://github.com/hnw/php-timecop", E_WARNING, + "timecop couldn't find class %s.", p->orig_class); +@@ -554,7 +561,7 @@ static int timecop_class_override() + continue; + } + +- ce_ovrd = zend_hash_str_find_ptr(EG(class_table), p->ovrd_class, strlen(p->ovrd_class)); ++ ce_ovrd = zend_hash_str_find_ptr(CG(class_table), p->ovrd_class, strlen(p->ovrd_class)); + if (ce_ovrd == NULL) { + php_error_docref("https://github.com/hnw/php-timecop", E_WARNING, + "timecop couldn't find class %s.", p->ovrd_class); +@@ -626,9 +633,9 @@ static int timecop_func_override_clear() + + p = &(timecop_override_func_table[0]); + while (p->orig_func != NULL) { +- zf_orig = zend_hash_str_find_ptr(EG(function_table), ++ zf_orig = zend_hash_str_find_ptr(CG(function_table), + p->save_func, strlen(p->save_func)); +- zf_ovld = zend_hash_str_find_ptr(EG(function_table), ++ zf_ovld = zend_hash_str_find_ptr(CG(function_table), + p->orig_func, strlen(p->orig_func)); + if (zf_orig == NULL || zf_ovld == NULL) { + p++; +@@ -636,13 +643,13 @@ static int timecop_func_override_clear() + } + + GUARD_FUNCTION_ARG_INFO_BEGIN(zf_ovld); +- zend_hash_str_update_mem(EG(function_table), p->orig_func, strlen(p->orig_func), ++ zend_hash_str_update_mem(CG(function_table), p->orig_func, strlen(p->orig_func), + zf_orig, sizeof(zend_internal_function)); + GUARD_FUNCTION_ARG_INFO_END(); + function_add_ref(zf_orig); + + GUARD_FUNCTION_ARG_INFO_BEGIN(zf_orig); +- zend_hash_str_del(EG(function_table), p->save_func, strlen(p->save_func)); ++ zend_hash_str_del(CG(function_table), p->save_func, strlen(p->save_func)); + GUARD_FUNCTION_ARG_INFO_END(); + + p++; +@@ -658,7 +665,7 @@ static int timecop_class_override_clear() + + p = &(timecop_override_class_table[0]); + while (p->orig_class != NULL) { +- ce_orig = zend_hash_str_find_ptr(EG(class_table), ++ ce_orig = zend_hash_str_find_ptr(CG(class_table), + p->orig_class, strlen(p->orig_class)); + if (ce_orig == NULL) { + php_error_docref("https://github.com/hnw/php-timecop", E_WARNING, -- cgit