Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.3 #22

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/couchbase/bucket_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ PHP_METHOD(BucketManager, insertDesignDocument)
return;
}

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

cmd.type = LCB_HTTP_TYPE_VIEW;
cmd.method = LCB_HTTP_METHOD_GET;
Expand Down Expand Up @@ -187,7 +187,7 @@ PHP_METHOD(BucketManager, upsertDesignDocument)

cmd.type = LCB_HTTP_TYPE_VIEW;
cmd.method = LCB_HTTP_METHOD_PUT;
path_len = spprintf(&path, 0, "/_design/%*s", name_len, name);
path_len = spprintf(&path, 0, "/_design/%*s", (int)name_len, name);
LCB_CMD_SET_KEY(&cmd, path, path_len);
cmd.content_type = PCBC_CONTENT_TYPE_JSON;

Expand Down Expand Up @@ -239,7 +239,7 @@ PHP_METHOD(BucketManager, removeDesignDocument)

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

cmd.type = LCB_HTTP_TYPE_VIEW;
cmd.method = LCB_HTTP_METHOD_GET;
path_len = spprintf(&path, 0, "/_design/%*s", name_len, name);
path_len = spprintf(&path, 0, "/_design/%*s", (int)name_len, name);
LCB_CMD_SET_KEY(&cmd, path, path_len);
cmd.content_type = PCBC_CONTENT_TYPE_FORM;
pcbc_http_request(return_value, obj->conn->lcb, &cmd, 1 TSRMLS_CC);
Expand Down
14 changes: 7 additions & 7 deletions src/couchbase/cluster_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ PHP_METHOD(ClusterManager, removeBucket)
if (rv == FAILURE) {
return;
}
path_len = spprintf(&path, 0, "/pools/default/buckets/%*s", name_len, name);
path_len = spprintf(&path, 0, "/pools/default/buckets/%*s", (int)name_len, name);
cmd.type = LCB_HTTP_TYPE_MANAGEMENT;
cmd.method = LCB_HTTP_METHOD_DELETE;
LCB_CMD_SET_KEY(&cmd, path, path_len);
Expand Down Expand Up @@ -208,10 +208,10 @@ PHP_METHOD(ClusterManager, getUser)
}
switch (domain) {
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_LOCAL:
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", name_len, name);
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", (int)name_len, name);
break;
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_EXTERNAL:
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", name_len, name);
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", (int)name_len, name);
break;
default:
throw_pcbc_exception("Invalid arguments.", LCB_EINVAL);
Expand Down Expand Up @@ -244,10 +244,10 @@ PHP_METHOD(ClusterManager, removeUser)
}
switch (domain) {
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_LOCAL:
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", name_len, name);
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", (int)name_len, name);
break;
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_EXTERNAL:
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", name_len, name);
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", (int)name_len, name);
break;
default:
throw_pcbc_exception("Invalid arguments.", LCB_EINVAL);
Expand Down Expand Up @@ -293,10 +293,10 @@ PHP_METHOD(ClusterManager, upsertUser)
user = Z_USER_SETTINGS_OBJ_P(settings);
switch (domain) {
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_LOCAL:
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", name_len, name);
path_len = spprintf(&path, 0, "/settings/rbac/users/local/%*s", (int)name_len, name);
break;
case PCBC_CLUSTER_MANAGER_RBAC_DOMAIN_EXTERNAL:
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", name_len, name);
path_len = spprintf(&path, 0, "/settings/rbac/users/external/%*s", (int)name_len, name);
break;
default:
throw_pcbc_exception("Invalid arguments.", LCB_EINVAL);
Expand Down
2 changes: 1 addition & 1 deletion src/couchbase/mutation_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void pcbc_mutation_state_export_for_n1ql(pcbc_mutation_state_t *obj, zval *scan_
add_next_index_long(PCBC_P(pair), PCBC_MUTATION_TOKEN_SEQ(token));
snprintf(buf, 21, "%llu", (unsigned long long)PCBC_MUTATION_TOKEN_ID(token));
ADD_NEXT_INDEX_STRING(PCBC_P(pair), buf);
snprintf(buf, 21, "%d\0", (int)PCBC_MUTATION_TOKEN_VB(token));
snprintf(buf, 21, "%d", (int)PCBC_MUTATION_TOKEN_VB(token));
#if PHP_VERSION_ID >= 70000
zend_hash_str_update(Z_ARRVAL_P(bucket_group), buf, strlen(buf), PCBC_P(pair) TSRMLS_CC);
#else
Expand Down
8 changes: 4 additions & 4 deletions src/couchbase/n1ql_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ PHP_METHOD(N1qlQuery, scanCap)
}

PCBC_READ_PROPERTY(options, pcbc_n1ql_query_ce, getThis(), "options", 0);
spprintf(&val, 0, "%d", scan_cap);
spprintf(&val, 0, "%ld", scan_cap);
ADD_ASSOC_STRING(options, "scan_cap", val);
efree(val);

Expand All @@ -195,7 +195,7 @@ PHP_METHOD(N1qlQuery, pipelineBatch)
}

PCBC_READ_PROPERTY(options, pcbc_n1ql_query_ce, getThis(), "options", 0);
spprintf(&val, 0, "%d", pipeline_batch);
spprintf(&val, 0, "%ld", pipeline_batch);
ADD_ASSOC_STRING(options, "pipeline_batch", val);
efree(val);

Expand All @@ -216,7 +216,7 @@ PHP_METHOD(N1qlQuery, pipelineCap)
}

PCBC_READ_PROPERTY(options, pcbc_n1ql_query_ce, getThis(), "options", 0);
spprintf(&val, 0, "%d", pipeline_cap);
spprintf(&val, 0, "%ld", pipeline_cap);
ADD_ASSOC_STRING(options, "pipeline_cap", val);
efree(val);

Expand All @@ -237,7 +237,7 @@ PHP_METHOD(N1qlQuery, maxParallelism)
}

PCBC_READ_PROPERTY(options, pcbc_n1ql_query_ce, getThis(), "options", 0);
spprintf(&val, 0, "%d", max_parallelism);
spprintf(&val, 0, "%ld", max_parallelism);
ADD_ASSOC_STRING(options, "max_parallelism", val);
efree(val);

Expand Down
32 changes: 32 additions & 0 deletions src/couchbase/pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,19 @@ static lcb_error_t pcbc_normalize_connstr(lcb_type_t type, char *connstr, const
// 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, ':');
Expand All @@ -175,7 +183,11 @@ static lcb_error_t pcbc_normalize_connstr(lcb_type_t type, char *connstr, const
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);
Expand All @@ -186,23 +198,39 @@ static lcb_error_t pcbc_normalize_connstr(lcb_type_t type, char *connstr, const
}
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, ':');
smart_str_append_long(&buf, (long)url->port);
}
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);
Expand Down Expand Up @@ -257,7 +285,11 @@ static lcb_error_t 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) {
Expand Down