summaryrefslogtreecommitdiffstats
path: root/seaslog-php81.patch
blob: e94dd76d5686ab7ace4d9a17e825f35f0017d878 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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 <remi@remirepo.net>
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