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
|
From 82f7fa12daef81f4a9b3c923c848a53dcc1b3b23 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 22 Jun 2018 13:57:47 +0200
Subject: [PATCH] fix for PHP 7.3 + fix build warnings
---
php7/memcache.c | 14 +++++++++++++-
php7/memcache_binary_protocol.c | 9 ++-------
php7/memcache_pool.c | 2 --
php7/memcache_session.c | 19 ++++++++++++++++++-
4 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/php7/memcache.c b/php7/memcache.c
index f5b5c34..3a6c000 100644
--- a/php7/memcache.c
+++ b/php7/memcache.c
@@ -621,7 +621,6 @@ static void php_mmc_numeric(INTERNAL_FUNCTION_PARAMETERS, int deleted, int inver
if (Z_TYPE_P(keys) == IS_ARRAY) {
zval *key;
- zend_ulong key_index;
if (deleted) {
/* changed to true/false by mmc_numeric_response_handler */
@@ -728,7 +727,12 @@ mmc_t *mmc_find_persistent(const char *host, int host_len, unsigned short port,
mmc = mmc_server_new(host, host_len, port, udp_port, 1, timeout, retry_interval);
le->type = le_memcache_server;
le->ptr = mmc;
+#if PHP_VERSION_ID < 70300
GC_REFCOUNT(le) = 1;
+#else
+ GC_SET_REFCOUNT(le, 1);
+#endif
+
/* register new persistent connection */
if (zend_hash_str_update_mem(&EG(persistent_list), key, key_len, le, sizeof(*le)) == NULL) {
@@ -786,7 +790,11 @@ static mmc_t *php_mmc_pool_addserver(
pool->failure_callback = &php_mmc_failure_callback;
list_res = zend_register_resource(pool, le_memcache_pool);
add_property_resource(mmc_object, "connection", list_res);
+#if PHP_VERSION_ID < 70300
GC_REFCOUNT(list_res)++;
+#else
+ GC_ADDREF(list_res);
+#endif
}
else {
pool = zend_fetch_resource_ex(connection, "connection", le_memcache_pool);
@@ -870,7 +878,11 @@ static void php_mmc_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool persistent)
mmc_object = return_value;
object_init_ex(mmc_object, memcache_ce);
add_property_resource(mmc_object, "connection", list_res);
+#if PHP_VERSION_ID < 70300
GC_REFCOUNT(list_res)++;
+#else
+ GC_ADDREF(list_res);
+#endif
} else {
RETVAL_TRUE;
}
diff --git a/php7/memcache_binary_protocol.c b/php7/memcache_binary_protocol.c
index d1926cc..dfd8060 100644
--- a/php7/memcache_binary_protocol.c
+++ b/php7/memcache_binary_protocol.c
@@ -239,7 +239,6 @@ static int mmc_request_parse_response(mmc_t *mmc, mmc_request_t *request) /*
{
mmc_response_header_t *header;
mmc_binary_request_t *req = (mmc_binary_request_t *)request;
- size_t size_header = sizeof(mmc_response_header_t);
header = (mmc_response_header_t *)mmc_stream_get(request->io, sizeof(mmc_response_header_t));
@@ -564,7 +563,7 @@ static int mmc_binary_store(
return status;
}
- header = (mmc_store_request_header_t *)(request->sendbuf.value.c + prevlen);
+ header = (mmc_store_append_header_t *)(request->sendbuf.value.c + prevlen);
mmc_pack_header(&(header->base), op, 0, key_len, sizeof(mmc_store_append_header_t) - sizeof(mmc_request_header_t), request->sendbuf.value.len - valuelen);
header->base.cas = htonll(cas);
@@ -631,7 +630,6 @@ static void mmc_binary_mutate(mmc_request_t *request, zval *zkey, const char *ke
{
mmc_mutate_request_header_t header;
mmc_binary_request_t *req = (mmc_binary_request_t *)request;
- const size_t request_header_size = sizeof(mmc_request_header_t);
uint8_t op;
request->parse = mmc_request_parse_response;
@@ -720,12 +718,10 @@ static void mmc_binary_stats(mmc_request_t *request, const char *type, long slab
static void mmc_set_sasl_auth_data(mmc_pool_t *pool, mmc_request_t *request, const char *user, const char *password) /* {{{ */
{
- const char *key = "PLAIN";
const unsigned int key_len = 5;
- int prevlen, valuelen;
+ int prevlen;
mmc_sasl_request_header *header;
mmc_binary_request_t *req = (mmc_binary_request_t *)request;
- unsigned int flags = 0;
request->parse = mmc_request_parse_response;
req->next_parse_handler = mmc_request_read_response;
@@ -740,7 +736,6 @@ static void mmc_set_sasl_auth_data(mmc_pool_t *pool, mmc_request_t *request, con
/* append key and data */
smart_string_appendl(&(request->sendbuf.value), "PLAIN", 5);
- valuelen = request->sendbuf.value.len;
/* initialize header */
header = (mmc_sasl_request_header *)(request->sendbuf.value.c + prevlen);
diff --git a/php7/memcache_pool.c b/php7/memcache_pool.c
index 3aea80c..f6e016b 100644
--- a/php7/memcache_pool.c
+++ b/php7/memcache_pool.c
@@ -44,7 +44,6 @@ ZEND_DECLARE_MODULE_GLOBALS(memcache)
MMC_POOL_INLINE void mmc_buffer_alloc(mmc_buffer_t *buffer, unsigned int size) /*
ensures space for an additional size bytes {{{ */
{
- register size_t newlen;
smart_string_alloc((&(buffer->value)), size, 0);
}
/* }}} */
@@ -432,7 +431,6 @@ int mmc_unpack_value(
{
char *data = NULL;
unsigned long data_len;
- int rv;
zval object;
diff --git a/php7/memcache_session.c b/php7/memcache_session.c
index dd2434a..98cfde1 100644
--- a/php7/memcache_session.c
+++ b/php7/memcache_session.c
@@ -102,7 +102,11 @@ PS_OPEN_FUNC(memcache)
if (url->query != NULL) {
array_init(¶ms);
+#if PHP_VERSION_ID < 70300
sapi_module.treat_data(PARSE_STRING, estrdup(url->query), ¶ms);
+#else
+ sapi_module.treat_data(PARSE_STRING, estrdup(ZSTR_VAL(url->query)), ¶ms);
+#endif
if ((param = zend_hash_str_find(Z_ARRVAL(params), "persistent", sizeof("persistent")-1)) != NULL) {
convert_to_boolean_ex(param);
@@ -132,9 +136,15 @@ PS_OPEN_FUNC(memcache)
zval_ptr_dtor(¶ms);
}
+#if PHP_VERSION_ID < 70300
if (url->scheme && url->path && !strcmp(url->scheme, "file")) {
char *host;
int host_len = spprintf(&host, 0, "unix://%s", url->path);
+#else
+ if (url->scheme && url->path && !strcmp(ZSTR_VAL(url->scheme), "file")) {
+ char *host;
+ int host_len = spprintf(&host, 0, "unix://%s", ZSTR_VAL(url->path));
+#endif
/* chop off trailing :0 port specifier */
if (!strcmp(host + host_len - 2, ":0")) {
@@ -158,14 +168,21 @@ PS_OPEN_FUNC(memcache)
return FAILURE;
}
+#if PHP_VERSION_ID < 70300
if (persistent) {
mmc = mmc_find_persistent(url->host, strlen(url->host), url->port, udp_port, timeout, retry_interval);
}
else {
mmc = mmc_server_new(url->host, strlen(url->host), url->port, udp_port, 0, timeout, retry_interval);
}
+#else
+ if (persistent) {
+ mmc = mmc_find_persistent(ZSTR_VAL(url->host), ZSTR_LEN(url->host), url->port, udp_port, timeout, retry_interval);
+ } else {
+ mmc = mmc_server_new(ZSTR_VAL(url->host), ZSTR_LEN(url->host), url->port, udp_port, 0, timeout, retry_interval);
+ }
+#endif
}
-
mmc_pool_add(pool, mmc, weight);
php_url_free(url);
}
|