Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zend_error_cb usage in PHP >= 8.1 #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/ErrorHook.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down