summaryrefslogtreecommitdiffstats
path: root/pq-php81.patch
blob: 3d1fde6a0608599a68ab23a0d0b90a2ce17d38b6 (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
From c9082b82cd9275d2ff9027b108ea01ab88e70294 Mon Sep 17 00:00:00 2001
From: Michael Wallner <mike@php.net>
Date: Fri, 15 Jan 2021 13:38:41 +0100
Subject: [PATCH] fix PHP-master

---
 src/php_pq_params.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/php_pq_params.c b/src/php_pq_params.c
index a3ee6b8..259fbb9 100644
--- a/src/php_pq_params.c
+++ b/src/php_pq_params.c
@@ -307,7 +307,8 @@ static int apply_to_params(zval *zp, void *arg_ptr)
 {
 	struct apply_to_params_arg *arg = arg_ptr;
 
-	SEPARATE_ZVAL_IF_NOT_REF(zp);
+	ZVAL_DEREF(zp);
+	SEPARATE_ZVAL(zp);
 	php_pq_params_set_param(arg->params, arg->index++, zp);
 	return ZEND_HASH_APPLY_KEEP;
 }

From 320bae0144fab755d678317f7ec14f9cb3ae1869 Mon Sep 17 00:00:00 2001
From: Michael Wallner <mike@php.net>
Date: Wed, 10 Mar 2021 11:22:50 +0100
Subject: [PATCH] compatibility with master

---
 src/php_pq_misc.h | 14 +++++-----
 src/php_pqres.c   |  4 +--
 tests/res001.phpt | 67 ++++++++++++++++++++++++++---------------------
 3 files changed, 46 insertions(+), 39 deletions(-)

diff --git a/src/php_pq_misc.h b/src/php_pq_misc.h
index 07bd596..7ccda3e 100644
--- a/src/php_pq_misc.h
+++ b/src/php_pq_misc.h
@@ -40,13 +40,6 @@ extern char *php_pq_rtrim(char *e);
 /* R, W, RW */
 extern const char *php_pq_strmode(long mode);
 
-/* compare array index */
-#if PHP_VERSION_ID >= 80000
-extern int php_pq_compare_index(Bucket *lptr, Bucket *rptr);
-#else
-extern int php_pq_compare_index(const void *lptr, const void *rptr);
-#endif
-
 /* free zval ptr values (as hash dtor) */
 extern void php_pq_hash_ptr_dtor(zval *p);
 
@@ -63,6 +56,8 @@ extern HashTable *php_pq_parse_array(php_pqres_t *res, const char *val_str, size
 
 /* ZE compat */
 #if PHP_VERSION_ID >= 80000
+extern int php_pq_compare_index(Bucket *lptr, Bucket *rptr);
+
 # define php_pq_call_method(objval_ptr, method_name, num_args, ...) \
 		zend_call_method_with_ ## num_args ## _params( \
 				Z_OBJ_P(objval_ptr), Z_OBJCE_P(objval_ptr), NULL, \
@@ -77,6 +72,11 @@ extern HashTable *php_pq_parse_array(php_pqres_t *res, const char *val_str, size
 		(Z_OBJ_HT_P(objval_ptr)->cast_object && \
 				SUCCESS == Z_OBJ_HT_P(objval_ptr)->cast_object(Z_OBJ_P(objval_ptr), (retval_ptr), (cast_type)))
 #else
+
+extern int php_pq_compare_index(const void *lptr, const void *rptr);
+
+# define zend_ze_countable spl_ce_Countable
+
 # define php_pq_call_method(objval_ptr, method_name, num_args, ...) \
 		zend_call_method_with_ ## num_args ## _params( \
 				(objval_ptr), NULL, NULL, \
diff --git a/src/php_pqres.c b/src/php_pqres.c
index 7e51271..be3d039 100644
--- a/src/php_pqres.c
+++ b/src/php_pqres.c
@@ -1249,9 +1249,9 @@ PHP_MINIT_FUNCTION(pqres)
 	php_pqres_class_entry->create_object = php_pqres_create_object;
 	php_pqres_class_entry->get_iterator = php_pqres_iterator_init;
 #if PHP_VERSION_ID >= 80000
-	zend_class_implements(php_pqres_class_entry, 2, zend_ce_aggregate, spl_ce_Countable);
+	zend_class_implements(php_pqres_class_entry, 2, zend_ce_aggregate, zend_ce_countable);
 #else
-	zend_class_implements(php_pqres_class_entry, 2, zend_ce_traversable, spl_ce_Countable);
+	zend_class_implements(php_pqres_class_entry, 2, zend_ce_traversable, zend_ce_countable);
 #endif
 
 	memcpy(&php_pqres_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
diff --git a/tests/res001.phpt b/tests/res001.phpt
index b2a3667..a325247 100644
--- a/tests/res001.phpt
+++ b/tests/res001.phpt
@@ -19,7 +19,13 @@ class r extends pq\Result {
 	public $dummy = 2;
 }
 
-var_dump(new pq\Result, get_object_vars(new r));
+var_dump(new pq\Result);
+
+echo "Test\n";
+$v = get_object_vars(new r);
+ksort($v);
+var_dump($v);
+
 ?>
 Done
 --EXPECTF--
@@ -42,6 +48,27 @@ Warning: pq\Result not initialized in %s on line %d
 Warning: pq\Result not initialized in %s on line %d
 
 Warning: pq\Result not initialized in %s on line %d
+object(pq\Result)#%d (9) {
+  ["status"]=>
+  NULL
+  ["statusMessage"]=>
+  NULL
+  ["errorMessage"]=>
+  NULL
+  ["diag"]=>
+  NULL
+  ["numRows"]=>
+  int(0)
+  ["numCols"]=>
+  int(0)
+  ["affectedRows"]=>
+  int(0)
+  ["fetchType"]=>
+  int(0)
+  ["autoConvert"]=>
+  int(65535)
+}
+Test
 
 Warning: pq\Result not initialized in %s on line %d
 
@@ -62,46 +89,26 @@ Warning: pq\Result not initialized in %s on line %d
 Warning: pq\Result not initialized in %s on line %d
 
 Warning: pq\Result not initialized in %s on line %d
-object(pq\Result)#%d (9) {
-  ["status"]=>
-  NULL
-  ["statusMessage"]=>
-  NULL
-  ["errorMessage"]=>
-  NULL
-  ["diag"]=>
-  NULL
-  ["numRows"]=>
-  int(0)
-  ["numCols"]=>
-  int(0)
+array(10) {
   ["affectedRows"]=>
   int(0)
-  ["fetchType"]=>
-  int(0)
   ["autoConvert"]=>
   int(65535)
-}
-array(10) {
+  ["diag"]=>
+  NULL
   ["dummy"]=>
   int(2)
-  ["status"]=>
-  NULL
-  ["statusMessage"]=>
-  NULL
   ["errorMessage"]=>
   NULL
-  ["diag"]=>
-  NULL
-  ["numRows"]=>
+  ["fetchType"]=>
   int(0)
   ["numCols"]=>
   int(0)
-  ["affectedRows"]=>
-  int(0)
-  ["fetchType"]=>
+  ["numRows"]=>
   int(0)
-  ["autoConvert"]=>
-  int(65535)
+  ["status"]=>
+  NULL
+  ["statusMessage"]=>
+  NULL
 }
 Done

From 7109996c98ad7df145d88693167023b7b9be9f8c Mon Sep 17 00:00:00 2001
From: Michael Wallner <mike@php.net>
Date: Wed, 10 Mar 2021 13:33:17 +0100
Subject: [PATCH] typo

---
 src/php_pq_misc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/php_pq_misc.h b/src/php_pq_misc.h
index 7ccda3e..1285d8e 100644
--- a/src/php_pq_misc.h
+++ b/src/php_pq_misc.h
@@ -75,7 +75,7 @@ extern int php_pq_compare_index(Bucket *lptr, Bucket *rptr);
 
 extern int php_pq_compare_index(const void *lptr, const void *rptr);
 
-# define zend_ze_countable spl_ce_Countable
+# define zend_ce_countable spl_ce_Countable
 
 # define php_pq_call_method(objval_ptr, method_name, num_args, ...) \
 		zend_call_method_with_ ## num_args ## _params( \

From 54542ca3e96ba72090f188692995047ae70d5d28 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 11 Jun 2021 10:01:07 +0200
Subject: [PATCH] fix prototype for 8.1

---
 src/php_pq_misc.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/php_pq_misc.c b/src/php_pq_misc.c
index 3e334c6..9e622b4 100644
--- a/src/php_pq_misc.c
+++ b/src/php_pq_misc.c
@@ -131,6 +131,13 @@ void php_pq_hash_ptr_dtor(zval *p)
 
 zend_class_entry *php_pqdt_class_entry;
 
+#if PHP_VERSION_ID >= 80100
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_pqdt_jsonserialize, 0, 0, IS_MIXED, 0)
+#else
+#define ai_pqdt_jsonserialize ai_pqdt_to_string
+#endif
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(ai_pqdt_to_string, 0, 0, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(pqdt, __toString)
@@ -142,7 +149,11 @@ static PHP_METHOD(pqdt, __toString)
 	RETVAL_ZVAL(&rv, 1, 1);
 }
 
+#if PHP_VERSION_ID >= 80100
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_TYPE_MASK_EX(ai_pqdt_create_from_format, 0, 2, DateTime, MAY_BE_FALSE)
+#else
 ZEND_BEGIN_ARG_INFO_EX(ai_pqdt_create_from_format, 0, 0, 2)
+#endif
 	ZEND_ARG_INFO(0, format)
 	ZEND_ARG_INFO(0, datetime)
 #if PHP_VERSION_ID >= 70200
@@ -171,7 +182,7 @@ static PHP_METHOD(pqdt, createFromFormat)
 static zend_function_entry php_pqdt_methods[] = {
 	PHP_ME(pqdt, createFromFormat, ai_pqdt_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
 	PHP_ME(pqdt, __toString, ai_pqdt_to_string, ZEND_ACC_PUBLIC)
-	PHP_MALIAS(pqdt, jsonSerialize, __toString, ai_pqdt_to_string, ZEND_ACC_PUBLIC)
+	PHP_MALIAS(pqdt, jsonSerialize, __toString, ai_pqdt_jsonserialize, ZEND_ACC_PUBLIC)
 	{0}
 };