Skip to content

Commit c20e350

Browse files
remicolletavsej
authored andcommitted
Fixes for PHP 7.3
Closes #22 Change-Id: Iee5a516dc8a66b9c326374a677c5f37237b29997 Reviewed-on: http://review.couchbase.org/96049 Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com> Tested-by: Build Bot <build@couchbase.com>
1 parent 3a846b4 commit c20e350

File tree

5 files changed

+48
-16
lines changed

5 files changed

+48
-16
lines changed

src/couchbase/bucket_manager.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ PHP_METHOD(BucketManager, insertDesignDocument)
117117
return;
118118
}
119119

120-
path_len = spprintf(&path, 0, "/_design/%*s", name_len, name);
120+
path_len = spprintf(&path, 0, "/_design/%*s", (int)name_len, name);
121121

122122
cmd.type = LCB_HTTP_TYPE_VIEW;
123123
cmd.method = LCB_HTTP_METHOD_GET;
@@ -187,7 +187,7 @@ PHP_METHOD(BucketManager, upsertDesignDocument)
187187

188188
cmd.type = LCB_HTTP_TYPE_VIEW;
189189
cmd.method = LCB_HTTP_METHOD_PUT;
190-
path_len = spprintf(&path, 0, "/_design/%*s", name_len, name);
190+
path_len = spprintf(&path, 0, "/_design/%*s", (int)name_len, name);
191191
LCB_CMD_SET_KEY(&cmd, path, path_len);
192192
cmd.content_type = PCBC_CONTENT_TYPE_JSON;
193193

@@ -239,7 +239,7 @@ PHP_METHOD(BucketManager, removeDesignDocument)
239239

240240
cmd.type = LCB_HTTP_TYPE_VIEW;
241241
cmd.method = LCB_HTTP_METHOD_DELETE;
242-
path_len = spprintf(&path, 0, "/_design/%*s", name_len, name);
242+
path_len = spprintf(&path, 0, "/_design/%*s", (int)name_len, name);
243243
LCB_CMD_SET_KEY(&cmd, path, path_len);
244244
cmd.content_type = PCBC_CONTENT_TYPE_FORM;
245245
pcbc_http_request(return_value, obj->conn->lcb, &cmd, 1 TSRMLS_CC);
@@ -264,7 +264,7 @@ PHP_METHOD(BucketManager, getDesignDocument)
264264

265265
cmd.type = LCB_HTTP_TYPE_VIEW;
266266
cmd.method = LCB_HTTP_METHOD_GET;
267-
path_len = spprintf(&path, 0, "/_design/%*s", name_len, name);
267+
path_len = spprintf(&path, 0, "/_design/%*s", (int)name_len, name);
268268
LCB_CMD_SET_KEY(&cmd, path, path_len);
269269
cmd.content_type = PCBC_CONTENT_TYPE_FORM;
270270
pcbc_http_request(return_value, obj->conn->lcb, &cmd, 1 TSRMLS_CC);

src/couchbase/cluster_manager.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ PHP_METHOD(ClusterManager, removeBucket)
124124
if (rv == FAILURE) {
125125
return;
126126
}
127-
path_len = spprintf(&path, 0, "/pools/default/buckets/%*s", name_len, name);
127+
path_len = spprintf(&path, 0, "/pools/default/buckets/%*s", (int)name_len, name);
128128
cmd.type = LCB_HTTP_TYPE_MANAGEMENT;
129129
cmd.method = LCB_HTTP_METHOD_DELETE;
130130
LCB_CMD_SET_KEY(&cmd, path, path_len);
@@ -208,10 +208,10 @@ PHP_METHOD(ClusterManager, getUser)
208208
}
209209
switch (domain) {
210210
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_LOCAL:
211-
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", name_len, name);
211+
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", (int)name_len, name);
212212
break;
213213
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_EXTERNAL:
214-
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", name_len, name);
214+
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", (int)name_len, name);
215215
break;
216216
default:
217217
throw_pcbc_exception("Invalid arguments.", LCB_EINVAL);
@@ -244,10 +244,10 @@ PHP_METHOD(ClusterManager, removeUser)
244244
}
245245
switch (domain) {
246246
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_LOCAL:
247-
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", name_len, name);
247+
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", (int)name_len, name);
248248
break;
249249
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_EXTERNAL:
250-
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", name_len, name);
250+
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", (int)name_len, name);
251251
break;
252252
default:
253253
throw_pcbc_exception("Invalid arguments.", LCB_EINVAL);
@@ -293,10 +293,10 @@ PHP_METHOD(ClusterManager, upsertUser)
293293
user = Z_USER_SETTINGS_OBJ_P(settings);
294294
switch (domain) {
295295
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_LOCAL:
296-
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", name_len, name);
296+
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", (int)name_len, name);
297297
break;
298298
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_EXTERNAL:
299-
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", name_len, name);
299+
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", (int)name_len, name);
300300
break;
301301
default:
302302
throw_pcbc_exception("Invalid arguments.", LCB_EINVAL);

src/couchbase/mutation_state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void pcbc_mutation_state_export_for_n1ql(pcbc_mutation_state_t *obj, zval *scan_
205205
add_next_index_long(PCBC_P(pair), PCBC_MUTATION_TOKEN_SEQ(token));
206206
snprintf(buf, 21, "%llu", (unsigned long long)PCBC_MUTATION_TOKEN_ID(token));
207207
ADD_NEXT_INDEX_STRING(PCBC_P(pair), buf);
208-
snprintf(buf, 21, "%d\0", (int)PCBC_MUTATION_TOKEN_VB(token));
208+
snprintf(buf, 21, "%d", (int)PCBC_MUTATION_TOKEN_VB(token));
209209
#if PHP_VERSION_ID >= 70000
210210
zend_hash_str_update(Z_ARRVAL_P(bucket_group), buf, strlen(buf), PCBC_P(pair) TSRMLS_CC);
211211
#else

src/couchbase/n1ql_query.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ PHP_METHOD(N1qlQuery, scanCap)
174174
}
175175

176176
PCBC_READ_PROPERTY(options, pcbc_n1ql_query_ce, getThis(), "options", 0);
177-
spprintf(&val, 0, "%d", scan_cap);
177+
spprintf(&val, 0, "%ld", scan_cap);
178178
ADD_ASSOC_STRING(options, "scan_cap", val);
179179
efree(val);
180180

@@ -195,7 +195,7 @@ PHP_METHOD(N1qlQuery, pipelineBatch)
195195
}
196196

197197
PCBC_READ_PROPERTY(options, pcbc_n1ql_query_ce, getThis(), "options", 0);
198-
spprintf(&val, 0, "%d", pipeline_batch);
198+
spprintf(&val, 0, "%ld", pipeline_batch);
199199
ADD_ASSOC_STRING(options, "pipeline_batch", val);
200200
efree(val);
201201

@@ -216,7 +216,7 @@ PHP_METHOD(N1qlQuery, pipelineCap)
216216
}
217217

218218
PCBC_READ_PROPERTY(options, pcbc_n1ql_query_ce, getThis(), "options", 0);
219-
spprintf(&val, 0, "%d", pipeline_cap);
219+
spprintf(&val, 0, "%ld", pipeline_cap);
220220
ADD_ASSOC_STRING(options, "pipeline_cap", val);
221221
efree(val);
222222

@@ -237,7 +237,7 @@ PHP_METHOD(N1qlQuery, maxParallelism)
237237
}
238238

239239
PCBC_READ_PROPERTY(options, pcbc_n1ql_query_ce, getThis(), "options", 0);
240-
spprintf(&val, 0, "%d", max_parallelism);
240+
spprintf(&val, 0, "%ld", max_parallelism);
241241
ADD_ASSOC_STRING(options, "max_parallelism", val);
242242
efree(val);
243243

src/couchbase/pool.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,19 @@ static lcb_error_t pcbc_normalize_connstr(lcb_type_t type, char *connstr, const
156156
// rebuild connection string with username as the bucket
157157
smart_str buf = {0};
158158
if (url->scheme) {
159+
#if PHP_VERSION_ID < 70300
159160
smart_str_appends(&buf, url->scheme);
161+
#else
162+
smart_str_appendl(&buf, ZSTR_VAL(url->scheme), ZSTR_LEN(url->scheme));
163+
#endif
160164
smart_str_appendl(&buf, "://", 3);
161165
}
162166
if (url->host) {
167+
#if PHP_VERSION_ID < 70300
163168
smart_str_appends(&buf, url->host);
169+
#else
170+
smart_str_appendl(&buf, ZSTR_VAL(url->host), ZSTR_LEN(url->host));
171+
#endif
164172
}
165173
if (url->port) {
166174
smart_str_appendc(&buf, ':');
@@ -170,7 +178,11 @@ static lcb_error_t pcbc_normalize_connstr(lcb_type_t type, char *connstr, const
170178
smart_str_appends(&buf, bucketname);
171179
if (url->query) {
172180
smart_str_appendc(&buf, '?');
181+
#if PHP_VERSION_ID < 70300
173182
smart_str_appends(&buf, url->query);
183+
#else
184+
smart_str_appendl(&buf, ZSTR_VAL(url->query), ZSTR_LEN(url->query));
185+
#endif
174186
}
175187
smart_str_0(&buf);
176188
PCBC_SMARTSTR_DUP(buf, *normalized);
@@ -181,23 +193,39 @@ static lcb_error_t pcbc_normalize_connstr(lcb_type_t type, char *connstr, const
181193
}
182194
break;
183195
case LCB_TYPE_CLUSTER:
196+
#if PHP_VERSION_ID < 70300
184197
if (url->path != NULL && url->path[0] != '\0') {
198+
#else
199+
if (url->path != NULL && ZSTR_VAL(url->path)[0] != '\0') {
200+
#endif
185201
// strip bucket from the connection string
186202
smart_str buf = {0};
187203
if (url->scheme) {
204+
#if PHP_VERSION_ID < 70300
188205
smart_str_appends(&buf, url->scheme);
206+
#else
207+
smart_str_appendl(&buf, ZSTR_VAL(url->scheme), ZSTR_LEN(url->scheme));
208+
#endif
189209
smart_str_appendl(&buf, "://", 3);
190210
}
191211
if (url->host) {
212+
#if PHP_VERSION_ID < 70300
192213
smart_str_appends(&buf, url->host);
214+
#else
215+
smart_str_appendl(&buf, ZSTR_VAL(url->host), ZSTR_LEN(url->host));
216+
#endif
193217
}
194218
if (url->port) {
195219
smart_str_appendc(&buf, ':');
196220
smart_str_append_long(&buf, (long)url->port);
197221
}
198222
if (url->query) {
199223
smart_str_appendc(&buf, '?');
224+
#if PHP_VERSION_ID < 70300
200225
smart_str_appends(&buf, url->query);
226+
#else
227+
smart_str_appendl(&buf, ZSTR_VAL(url->query), ZSTR_LEN(url->query));
228+
#endif
201229
}
202230
smart_str_0(&buf);
203231
PCBC_SMARTSTR_DUP(buf, *normalized);
@@ -252,7 +280,11 @@ static lcb_error_t pcbc_connection_cache(smart_str *plist_key, pcbc_connection_t
252280
zend_resource res;
253281
res.type = pcbc_res_couchbase;
254282
res.ptr = conn;
283+
#if PHP_VERSION_ID < 70300
255284
GC_REFCOUNT(&res) = 1;
285+
#else
286+
GC_SET_REFCOUNT(&res, 1);
287+
#endif
256288

257289
if (zend_hash_str_update_mem(&EG(persistent_list), PCBC_SMARTSTR_VAL(*plist_key), PCBC_SMARTSTR_LEN(*plist_key),
258290
&res, sizeof(res)) == NULL) {

0 commit comments

Comments
 (0)