summaryrefslogtreecommitdiffstats
path: root/APM-pr44.patch
blob: c3256c5e8082bf37828fbf484595f6cef5f9a1ee (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
From e4dd42a5ed8d410fd718f53d9f3f72bd91b4b0b1 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Sat, 23 Jul 2016 13:45:43 +0200
Subject: [PATCH 1/3] Fix build with PHP 7.1

- zend_print_zval_r_ex have been removed from 7.1
- zend_print_zval_r_to_str have been added in 7.1
- make apm_write static (not used anywhere else)
- move extract_data declaration
---
 apm.c     | 16 +++++++++++++++-
 php_apm.h | 10 +---------
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/apm.c b/apm.c
index 624369c..e45200f 100644
--- a/apm.c
+++ b/apm.c
@@ -94,7 +94,8 @@ static int apm_end_silence_opcode_handler(ZEND_USER_OPCODE_HANDLER_ARGS)
 	return ZEND_USER_OPCODE_DISPATCH;
 }
 
-int apm_write(const char *str,
+#if PHP_VERSION_ID <  70100
+static int apm_write(const char *str,
 #if PHP_VERSION_ID >= 70000
 size_t
 #else
@@ -107,6 +108,7 @@ length)
 	smart_str_0(APM_G(buffer));
 	return length;
 }
+#endif
 
 void (*old_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
 
@@ -596,8 +598,14 @@ void extract_data(TSRMLS_D)
 		zend_is_auto_global_compat("_COOKIE");
 		if (FETCH_HTTP_GLOBALS(COOKIE)) {
 			if (Z_ARRVAL_P(tmp)->nNumOfElements > 0) {
+#if PHP_VERSION_ID >= 70100
+				zend_string *tmpstr;
+				tmpstr = zend_print_zval_r_to_str(tmp, 0);
+				smart_str_append(&APM_RD(cookies), tmpstr);
+#else
 				APM_G(buffer) = &APM_RD(cookies);
 				zend_print_zval_r_ex(apm_write, tmp, 0 TSRMLS_CC);
+#endif
 				APM_RD(cookies_found) = 1;
 			}
 		}
@@ -606,8 +614,14 @@ void extract_data(TSRMLS_D)
 		zend_is_auto_global_compat("_POST");
 		if (FETCH_HTTP_GLOBALS(POST)) {
 			if (Z_ARRVAL_P(tmp)->nNumOfElements > 0) {
+#if PHP_VERSION_ID >= 70100
+				zend_string *tmpstr;
+				tmpstr = zend_print_zval_r_to_str(tmp, 0);
+				smart_str_append(&APM_RD(post_vars), tmpstr);
+#else
 				APM_G(buffer) = &APM_RD(post_vars);
 				zend_print_zval_r_ex(apm_write, tmp, 0 TSRMLS_CC);
+#endif
 				APM_RD(post_vars_found) = 1;
 			}
 		}
diff --git a/php_apm.h b/php_apm.h
index 4a5ee24..3fe29e3 100644
--- a/php_apm.h
+++ b/php_apm.h
@@ -368,14 +368,6 @@ ZEND_END_MODULE_GLOBALS(apm)
 # define add_assoc_long_compat(array, key, value) add_assoc_long_ex((array), (key), (sizeof(key)), (value));
 #endif
 
-int apm_write(const char *str,
-#if PHP_VERSION_ID >= 70000
-size_t
-#else
-uint
-#endif
-length);
-
+void extract_data(TSRMLS_D);
 #endif
 
-void extract_data(TSRMLS_D);

From 6109488d4b35ccb0c9b56b79986e8b5375c8f1a6 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Sat, 23 Jul 2016 13:55:05 +0200
Subject: [PATCH 2/3] Declare module dependencies (only json for socket driver)

---
 apm.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/apm.c b/apm.c
index e45200f..1b21dd0 100644
--- a/apm.c
+++ b/apm.c
@@ -124,8 +124,17 @@ struct timeval begin_tp;
 struct rusage begin_usg;
 #endif
 
+static const zend_module_dep apm_deps[] = {
+#ifdef APM_DRIVER_SOCKET
+	ZEND_MOD_REQUIRED("json")
+#endif
+	ZEND_MOD_END
+};
+
 zend_module_entry apm_module_entry = {
-	STANDARD_MODULE_HEADER,
+	STANDARD_MODULE_HEADER_EX,
+	NULL,
+	apm_deps,
 	"apm",
 	NULL,
 	PHP_MINIT(apm),

From 95e6fd6fb69abce62b0e1c6a1d2a9f80f463a687 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Sat, 23 Jul 2016 14:05:15 +0200
Subject: [PATCH 3/3] memleak

---
 apm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/apm.c b/apm.c
index 1b21dd0..99157b1 100644
--- a/apm.c
+++ b/apm.c
@@ -611,6 +611,7 @@ void extract_data(TSRMLS_D)
 				zend_string *tmpstr;
 				tmpstr = zend_print_zval_r_to_str(tmp, 0);
 				smart_str_append(&APM_RD(cookies), tmpstr);
+				zend_string_release(tmpstr);
 #else
 				APM_G(buffer) = &APM_RD(cookies);
 				zend_print_zval_r_ex(apm_write, tmp, 0 TSRMLS_CC);
@@ -627,6 +628,7 @@ void extract_data(TSRMLS_D)
 				zend_string *tmpstr;
 				tmpstr = zend_print_zval_r_to_str(tmp, 0);
 				smart_str_append(&APM_RD(post_vars), tmpstr);
+				zend_string_release(tmpstr);
 #else
 				APM_G(buffer) = &APM_RD(post_vars);
 				zend_print_zval_r_ex(apm_write, tmp, 0 TSRMLS_CC);