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
|
From 0c905da0d119291f0ce33379e7360a160c9e1699 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 7 Dec 2020 08:06:16 +0100
Subject: [PATCH] restore compatibility with PHP 7.2
---
src/couchbase/cluster.c | 4 ++++
src/couchbase/pool.c | 32 ++++++++++++++++++++++++++++++++
src/couchbase/result.c | 8 ++++++++
3 files changed, 44 insertions(+)
diff --git a/src/couchbase/cluster.c b/src/couchbase/cluster.c
index 478cc3a..0c64366 100644
--- a/src/couchbase/cluster.c
+++ b/src/couchbase/cluster.c
@@ -66,7 +66,11 @@ static void pcbc_cluster_connection_init(zval *return_value, pcbc_cluster_t *clu
if (PCBCG(allow_fallback_to_bucket)) {
url = php_url_parse(cluster->connstr);
if (url && url->path) {
+#if PHP_VERSION_ID < 70300
+ bucket = url->path;
+#else
bucket = ZSTR_VAL(url->path);
+#endif
while (*bucket == '/') {
bucket++;
}
diff --git a/src/couchbase/pool.c b/src/couchbase/pool.c
index 9dfac11..3f5d8bd 100644
--- a/src/couchbase/pool.c
+++ b/src/couchbase/pool.c
@@ -266,11 +266,19 @@ static lcb_STATUS pcbc_normalize_connstr(lcb_INSTANCE_TYPE type, char *connstr,
// rebuild connection string with username as the bucket
smart_str buf = {0};
if (url->scheme) {
+#if PHP_VERSION_ID < 70300
+ smart_str_appends(&buf, url->scheme);
+#else
smart_str_appendl(&buf, ZSTR_VAL(url->scheme), ZSTR_LEN(url->scheme));
+#endif
smart_str_appendl(&buf, "://", 3);
}
if (url->host) {
+#if PHP_VERSION_ID < 70300
+ smart_str_appends(&buf, url->host);
+#else
smart_str_appendl(&buf, ZSTR_VAL(url->host), ZSTR_LEN(url->host));
+#endif
}
if (url->port) {
smart_str_appendc(&buf, ':');
@@ -280,7 +288,11 @@ static lcb_STATUS pcbc_normalize_connstr(lcb_INSTANCE_TYPE type, char *connstr,
smart_str_appends(&buf, bucketname);
if (url->query) {
smart_str_appendc(&buf, '?');
+#if PHP_VERSION_ID < 70300
+ smart_str_appends(&buf, url->query);
+#else
smart_str_appendl(&buf, ZSTR_VAL(url->query), ZSTR_LEN(url->query));
+#endif
}
smart_str_0(&buf);
PCBC_SMARTSTR_DUP(buf, *normalized);
@@ -291,15 +303,27 @@ static lcb_STATUS pcbc_normalize_connstr(lcb_INSTANCE_TYPE type, char *connstr,
}
break;
case LCB_TYPE_CLUSTER:
+#if PHP_VERSION_ID < 70300
+ if (url->path != NULL && url->path[0] != '\0') {
+#else
if (url->path != NULL && ZSTR_VAL(url->path)[0] != '\0') {
+#endif
// strip bucket from the connection string
smart_str buf = {0};
if (url->scheme) {
+#if PHP_VERSION_ID < 70300
+ smart_str_appends(&buf, url->scheme);
+#else
smart_str_appendl(&buf, ZSTR_VAL(url->scheme), ZSTR_LEN(url->scheme));
+#endif
smart_str_appendl(&buf, "://", 3);
}
if (url->host) {
+#if PHP_VERSION_ID < 70300
+ smart_str_appends(&buf, url->host);
+#else
smart_str_appendl(&buf, ZSTR_VAL(url->host), ZSTR_LEN(url->host));
+#endif
}
if (url->port) {
smart_str_appendc(&buf, ':');
@@ -307,7 +331,11 @@ static lcb_STATUS pcbc_normalize_connstr(lcb_INSTANCE_TYPE type, char *connstr,
}
if (url->query) {
smart_str_appendc(&buf, '?');
+#if PHP_VERSION_ID < 70300
+ smart_str_appends(&buf, url->query);
+#else
smart_str_appendl(&buf, ZSTR_VAL(url->query), ZSTR_LEN(url->query));
+#endif
}
smart_str_0(&buf);
PCBC_SMARTSTR_DUP(buf, *normalized);
@@ -361,7 +389,11 @@ static lcb_STATUS pcbc_connection_cache(smart_str *plist_key, pcbc_connection_t
zend_resource res;
res.type = pcbc_res_couchbase;
res.ptr = conn;
+#if PHP_VERSION_ID < 70300
+ GC_REFCOUNT(&res) = 1;
+#else
GC_SET_REFCOUNT(&res, 1);
+#endif
if (zend_hash_str_update_mem(&EG(persistent_list), PCBC_SMARTSTR_VAL(*plist_key), PCBC_SMARTSTR_LEN(*plist_key),
&res, sizeof(res)) == NULL) {
diff --git a/src/couchbase/result.c b/src/couchbase/result.c
index 506a1d8..015c286 100644
--- a/src/couchbase/result.c
+++ b/src/couchbase/result.c
@@ -18,6 +18,14 @@
#include <ext/date/php_date.h>
+/* PHP_VERSION_ID < 70300 */
+#ifndef ZVAL_COPY_DEREF
+#define ZVAL_COPY_DEREF(z,v) do { \
+ ZVAL_DEREF(v); \
+ ZVAL_COPY(z, v); \
+ } while (0)
+#endif
+
// clang-format off
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(ai_MutationToken_partitionId, IS_LONG, 1)
ZEND_END_ARG_INFO()
|