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
|
From 4f50ecec5a1cfda6689c41fd0691526cf74cdde7 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 13 Nov 2020 08:49:03 +0100
Subject: [PATCH] fix for PHP 8
---
skywalking.cc | 7 +++++--
src/sky_plugin_hyperf_guzzle.cc | 16 ++++++++++++++--
src/sky_plugin_redis.cc | 8 ++++----
3 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/skywalking.cc b/skywalking.cc
index 31eda51..e27808f 100644
--- a/skywalking.cc
+++ b/skywalking.cc
@@ -190,8 +190,11 @@ zend_module_dep skywalking_deps[] = {
ZEND_MOD_END
};
+ZEND_BEGIN_ARG_INFO_EX(arginfo_skywalking_trace_id, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
const zend_function_entry skywalking_functions[] = {
- PHP_FE (skywalking_trace_id, NULL)
+ PHP_FE (skywalking_trace_id, arginfo_skywalking_trace_id)
PHP_FE_END
};
@@ -215,4 +218,4 @@ zend_module_entry skywalking_module_entry = {
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(skywalking)
-#endif
\ No newline at end of file
+#endif
diff --git a/src/sky_plugin_hyperf_guzzle.cc b/src/sky_plugin_hyperf_guzzle.cc
index ad851e0..68ded0a 100644
--- a/src/sky_plugin_hyperf_guzzle.cc
+++ b/src/sky_plugin_hyperf_guzzle.cc
@@ -29,18 +29,30 @@ Span *sky_plugin_hyperf_guzzle(zend_execute_data *execute_data, const std::strin
if (arg_count >= 1) {
zval *request = ZEND_CALL_ARG(execute_data, 1);
zval uri;
+#if PHP_VERSION_ID < 80000
zend_call_method(request, Z_OBJCE_P(request), nullptr, ZEND_STRL("geturi"), &uri, 0, nullptr, nullptr);
+#else
+ zend_call_method(Z_OBJ_P(request), Z_OBJCE_P(request), nullptr, ZEND_STRL("geturi"), &uri, 0, nullptr, nullptr);
+#endif
if (!Z_ISUNDEF(uri)) {
zval scheme, host, port, path, query, to_string;
int _port = 80;
+#if PHP_VERSION_ID < 80000
zend_call_method(&uri, Z_OBJCE_P(&uri), nullptr, ZEND_STRL("getscheme"), &scheme, 0, nullptr, nullptr);
zend_call_method(&uri, Z_OBJCE_P(&uri), nullptr, ZEND_STRL("gethost"), &host, 0, nullptr, nullptr);
zend_call_method(&uri, Z_OBJCE_P(&uri), nullptr, ZEND_STRL("getport"), &port, 0, nullptr, nullptr);
zend_call_method(&uri, Z_OBJCE_P(&uri), nullptr, ZEND_STRL("getpath"), &path, 0, nullptr, nullptr);
zend_call_method(&uri, Z_OBJCE_P(&uri), nullptr, ZEND_STRL("getquery"), &query, 0, nullptr, nullptr);
zend_call_method(&uri, Z_OBJCE_P(&uri), nullptr, ZEND_STRL("__tostring"), &to_string, 0, nullptr, nullptr);
-
+#else
+ zend_call_method(Z_OBJ(uri), Z_OBJCE(uri), nullptr, ZEND_STRL("getscheme"), &scheme, 0, nullptr, nullptr);
+ zend_call_method(Z_OBJ(uri), Z_OBJCE(uri), nullptr, ZEND_STRL("gethost"), &host, 0, nullptr, nullptr);
+ zend_call_method(Z_OBJ(uri), Z_OBJCE(uri), nullptr, ZEND_STRL("getport"), &port, 0, nullptr, nullptr);
+ zend_call_method(Z_OBJ(uri), Z_OBJCE(uri), nullptr, ZEND_STRL("getpath"), &path, 0, nullptr, nullptr);
+ zend_call_method(Z_OBJ(uri), Z_OBJCE(uri), nullptr, ZEND_STRL("getquery"), &query, 0, nullptr, nullptr);
+ zend_call_method(Z_OBJ(uri), Z_OBJCE(uri), nullptr, ZEND_STRL("__tostring"), &to_string, 0, nullptr, nullptr);
+#endif
if (!Z_ISUNDEF(scheme) && Z_TYPE(scheme) == IS_STRING) {
if (strcmp(Z_STRVAL(scheme), "http") == 0 || strcmp(Z_STRVAL(scheme), "https") == 0) {
@@ -74,4 +86,4 @@ Span *sky_plugin_hyperf_guzzle(zend_execute_data *execute_data, const std::strin
}
return nullptr;
-}
\ No newline at end of file
+}
diff --git a/src/sky_plugin_redis.cc b/src/sky_plugin_redis.cc
index 450e5d7..003b517 100644
--- a/src/sky_plugin_redis.cc
+++ b/src/sky_plugin_redis.cc
@@ -80,8 +80,8 @@ std::string sky_plugin_redis_peer(zend_execute_data *execute_data) {
zend_call_method(command, Z_OBJCE_P(command), nullptr, ZEND_STRL("gethost"), &host, 0, nullptr, nullptr);
zend_call_method(command, Z_OBJCE_P(command), nullptr, ZEND_STRL("getport"), &port, 0, nullptr, nullptr);
#else
- zend_call_method(Z_OBJCE_P(command), Z_OBJCE_P(command), nullptr, ZEND_STRL("gethost"), &host, 0, nullptr, nullptr);
- zend_call_method(Z_OBJCE_P(command), Z_OBJCE_P(command), nullptr, ZEND_STRL("getport"), &port, 0, nullptr, nullptr);
+ zend_call_method(Z_OBJ_P(command), Z_OBJCE_P(command), nullptr, ZEND_STRL("gethost"), &host, 0, nullptr, nullptr);
+ zend_call_method(Z_OBJ_P(command), Z_OBJCE_P(command), nullptr, ZEND_STRL("getport"), &port, 0, nullptr, nullptr);
#endif
if (!Z_ISUNDEF(host) && !Z_ISUNDEF(port) && Z_TYPE(host) == IS_STRING) {
@@ -136,7 +136,7 @@ std::string sky_plugin_redis_bit_count_cmd(zend_execute_data *execute_data, std:
uint32_t arg_count = ZEND_CALL_NUM_ARGS(execute_data);
if (arg_count >= 1) {
- for (int i = 1; i <= 3; ++i) {
+ for (uint32_t i = 1; i <= 3; ++i) {
if (i <= arg_count) {
zval *value = ZEND_CALL_ARG(execute_data, i);
if (Z_TYPE_P(value) == IS_LONG) {
@@ -154,4 +154,4 @@ std::string sky_plugin_redis_bit_count_cmd(zend_execute_data *execute_data, std:
return cmd;
}
return "";
-}
\ No newline at end of file
+}
|