From 68a767e4cef28be8293810fd75b8621179aa8226 Mon Sep 17 00:00:00 2001 From: Carl <631929063@qq.com> Date: Fri, 23 Jul 2021 21:25:18 +0800 Subject: [PATCH] Fix seaslog_error_cb error type --- src/ErrorHook.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ErrorHook.c b/src/ErrorHook.c index f23874f..9ae19bf 100644 --- a/src/ErrorHook.c +++ b/src/ErrorHook.c @@ -43,7 +43,7 @@ static void process_event_error(const char *event_type, int type, char * error_f #if PHP_VERSION_ID < 80000 void seaslog_error_cb(int type, const char *error_filename, const SEASLOG_UINT error_lineno, const char *format, va_list args) #else -void seaslog_error_cb(int type, const char *error_filename, const SEASLOG_UINT error_lineno,zend_string *message) +void seaslog_error_cb(int orig_type, const char *error_filename, const SEASLOG_UINT error_lineno,zend_string *message) #endif { TSRMLS_FETCH(); @@ -52,7 +52,7 @@ void seaslog_error_cb(int type, const char *error_filename, const SEASLOG_UINT e #if PHP_VERSION_ID < 80000 return old_error_cb(type, error_filename, error_lineno, format, args); #else - return old_error_cb(type, error_filename, error_lineno, message); + return old_error_cb(orig_type, error_filename, error_lineno, message); #endif } @@ -71,6 +71,7 @@ void seaslog_error_cb(int type, const char *error_filename, const SEASLOG_UINT e va_end(args_copy); #else char *msg = ZSTR_VAL(message); + int type = orig_type & E_ALL; #endif if (type == E_ERROR || type == E_PARSE || type == E_CORE_ERROR || type == E_COMPILE_ERROR || type == E_USER_ERROR || type == E_RECOVERABLE_ERROR) { @@ -100,7 +101,7 @@ void seaslog_error_cb(int type, const char *error_filename, const SEASLOG_UINT e #if PHP_VERSION_ID < 80000 return old_error_cb(type, error_filename, error_lineno, format, args); #else - return old_error_cb(type, error_filename, error_lineno, message); + return old_error_cb(orig_type, error_filename, error_lineno, message); #endif } From 1677e6dc5d363c4a7d443a312beffa15c31c635e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 19 Feb 2024 16:01:36 +0100 Subject: [PATCH] Fix zend_error_cb usage in PHP >= 8.1 --- src/ErrorHook.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/ErrorHook.c b/src/ErrorHook.c index 9ae19bf..06b35ee 100644 --- a/src/ErrorHook.c +++ b/src/ErrorHook.c @@ -19,11 +19,13 @@ #if PHP_VERSION_ID < 80000 void (*old_error_cb)(int type, const char *error_filename, const SEASLOG_UINT error_lineno, const char *format, va_list args); -#else +#elif PHP_VERSION_ID < 80100 void (*old_error_cb)(int type, const char *error_filename, const SEASLOG_UINT error_lineno, zend_string *message); +#else +void (*old_error_cb)(int type, zend_string *error_filename, const SEASLOG_UINT error_lineno, zend_string *message); #endif -static void process_event_error(const char *event_type, int type, char * error_filename, SEASLOG_UINT error_lineno, char * msg TSRMLS_DC) +static void process_event_error(const char *event_type, int type, const char * error_filename, SEASLOG_UINT error_lineno, char * msg TSRMLS_DC) { char *event_str; int event_str_len; @@ -42,8 +44,10 @@ static void process_event_error(const char *event_type, int type, char * error_f #if PHP_VERSION_ID < 80000 void seaslog_error_cb(int type, const char *error_filename, const SEASLOG_UINT error_lineno, const char *format, va_list args) -#else +#elif PHP_VERSION_ID < 80100 void seaslog_error_cb(int orig_type, const char *error_filename, const SEASLOG_UINT error_lineno,zend_string *message) +#else +void seaslog_error_cb(int orig_type, zend_string *error_filename, const SEASLOG_UINT error_lineno,zend_string *message) #endif { TSRMLS_FETCH(); @@ -77,21 +81,33 @@ void seaslog_error_cb(int orig_type, const char *error_filename, const SEASLOG_U { if (SEASLOG_G(trace_error)) { - process_event_error("Error", type, (char *) error_filename, error_lineno, msg TSRMLS_CC); +#if PHP_VERSION_ID < 80100 + process_event_error("Error", type, error_filename, error_lineno, msg TSRMLS_CC); +#else + process_event_error("Error", type, ZSTR_VAL(error_filename), error_lineno, msg); +#endif } } else if (type == E_WARNING || type == E_CORE_WARNING || type == E_COMPILE_WARNING || type == E_USER_WARNING) { if (SEASLOG_G(trace_warning)) { - process_event_error("Warning", type, (char *) error_filename, error_lineno, msg TSRMLS_CC); +#if PHP_VERSION_ID < 80100 + process_event_error("Warning", type, error_filename, error_lineno, msg TSRMLS_CC); +#else + process_event_error("Warning", type, ZSTR_VAL(error_filename), error_lineno, msg); +#endif } } else if (type == E_NOTICE || type == E_USER_NOTICE || type == E_STRICT || type == E_DEPRECATED || type == E_USER_DEPRECATED) { if (SEASLOG_G(trace_notice)) { - process_event_error("Notice", type, (char *) error_filename, error_lineno, msg TSRMLS_CC); +#if PHP_VERSION_ID < 80100 + process_event_error("Notice", type, error_filename, error_lineno, msg TSRMLS_CC); +#else + process_event_error("Notice", type, ZSTR_VAL(error_filename), error_lineno, msg); +#endif } } #if PHP_VERSION_ID < 80000 -- 2.43.2