From 9c0ab0fe577924d75324092eed989dc09675c04f Mon Sep 17 00:00:00 2001 From: t-matsuno Date: Thu, 19 Sep 2024 12:26:43 +0900 Subject: [PATCH] fix: simplify hook_strtotime --- ext/hook.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/ext/hook.c b/ext/hook.c index 1f2af89..ba9e3a9 100644 --- a/ext/hook.c +++ b/ext/hook.c @@ -699,25 +699,12 @@ static void hook_strtotime(INTERNAL_FUNCTION_PARAMETERS) return; } - if (is_fixed_ret == 2) { - CALL_ORIGINAL_FUNCTION(strtotime); - } else { - /* Call original function with params. */ - zval *params = NULL; - uint32_t param_count = 0; - zend_parse_parameters(ZEND_NUM_ARGS(), "+", ¶ms, ¶m_count); - ZVAL_LONG(¶ms[1], get_shifted_time(NULL)); - CALL_ORIGINAL_FUNCTION_WITH_PARAMS(strtotime, params, param_count); - } - - /* Apply interval. */ - timelib_time *t = timelib_time_ctor(); - timelib_rel_time interval; - timelib_unixtime2gmt(t, Z_LVAL_P(return_value)); - get_shift_interval(&interval); - apply_interval(&t, &interval); - RETVAL_LONG(timelib_date_to_int(t, NULL)); - timelib_time_dtor(t); + /* Call original function based on shifted time */ + zval *params = NULL; + uint32_t param_count = 0; + zend_parse_parameters(ZEND_NUM_ARGS(), "+", ¶ms, ¶m_count); + ZVAL_LONG(¶ms[1], get_shifted_time(NULL)); + CALL_ORIGINAL_FUNCTION_WITH_PARAMS(strtotime, params, param_count); } #if HAVE_GETTIMEOFDAY