summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Jones <sixd@php.net>2018-09-24 20:05:54 +1000
committerChristopher Jones <sixd@php.net>2018-09-24 20:05:54 +1000
commit91954c24da379946786e21e10f2a5d1a3306f64f (patch)
tree4663383c441becfbb8f8673f663eeff553ad536b
parent57eb25b393366c8650b2cf85ef12ea76d01bdd95 (diff)
downloadphp-git-91954c24da379946786e21e10f2a5d1a3306f64f.tar.gz
Make usable for PECL OCI8 release for PHP 7.x
-rw-r--r--ext/oci8/oci8.c45
-rw-r--r--ext/oci8/oci8_collection.c4
-rw-r--r--ext/oci8/oci8_interface.c28
-rw-r--r--ext/oci8/oci8_lob.c4
-rw-r--r--ext/oci8/oci8_statement.c46
5 files changed, 125 insertions, 2 deletions
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index 1a02187e53..63fb334c99 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -1454,8 +1454,13 @@ void php_oci_column_hash_dtor(zval *data)
if (column->descid) {
if (GC_REFCOUNT(column->descid) == 1)
zend_list_close(column->descid);
- else
+ else {
+#if PHP_VERSION_ID < 70300
GC_REFCOUNT(column->descid)--;
+#else
+ GC_DELREF(column->descid);
+#endif
+ }
}
if (column->data) {
@@ -1536,7 +1541,7 @@ sb4 php_oci_error(OCIError *err_p, sword errstatus)
case OCI_ERROR:
errcode = php_oci_fetch_errmsg(err_p, errbuf, sizeof(errbuf));
if (errcode) {
- php_error_docref(NULL, E_WARNING, "%s", errbuf, sizeof(errbuf));
+ php_error_docref(NULL, E_WARNING, "%s", errbuf);
} else {
php_error_docref(NULL, E_WARNING, "failed to fetch error message");
}
@@ -1877,7 +1882,11 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
(memcmp(ZSTR_VAL(tmp->hash_key), ZSTR_VAL(hashed_details.s),
ZSTR_LEN(tmp->hash_key)) == 0)) {
connection = tmp;
+#if PHP_VERSION_ID < 70300
++GC_REFCOUNT(connection->id);
+#else
+ GC_ADDREF(connection->id);
+#endif
}
} else {
PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection);
@@ -1887,7 +1896,11 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
* decremented in the persistent helper
*/
if (OCI_G(old_oci_close_semantics)) {
+#if PHP_VERSION_ID < 70300
++GC_REFCOUNT(connection->id);
+#else
+ GC_ADDREF(connection->id);
+#endif
}
}
smart_str_free(&hashed_details);
@@ -1898,7 +1911,11 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
} else {
/* we do not ping non-persistent connections */
smart_str_free(&hashed_details);
+#if PHP_VERSION_ID < 70300
++GC_REFCOUNT(connection->id);
+#else
+ GC_ADDREF(connection->id);
+#endif
return connection;
}
} /* is_open is true? */
@@ -2040,8 +2057,10 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
/* add to the appropriate hash */
if (connection->is_persistent) {
+#if PHP_VERSION_ID < 70300
new_le.ptr = connection;
new_le.type = le_pconnection;
+#endif
connection->used_this_request = 1;
PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection);
@@ -2050,9 +2069,17 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
* refcount is decremented in the persistent helper
*/
if (OCI_G(old_oci_close_semantics)) {
+#if PHP_VERSION_ID < 70300
++GC_REFCOUNT(connection->id);
+#else
+ GC_ADDREF(connection->id);
+#endif
}
+#if PHP_VERSION_ID < 70300
zend_hash_update_mem(&EG(persistent_list), connection->hash_key, (void *)&new_le, sizeof(zend_resource));
+#else
+ zend_register_persistent_resource_ex(connection->hash_key, connection, le_pconnection);
+#endif
OCI_G(num_persistent)++;
OCI_G(num_links)++;
} else if (!exclusive) {
@@ -2447,7 +2474,11 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode)
if (column->is_cursor) { /* REFCURSOR -> simply return the statement id */
ZVAL_RES(value, column->stmtid);
+#if PHP_VERSION_ID < 70300
++GC_REFCOUNT(column->stmtid);
+#else
+ GC_ADDREF(column->stmtid);
+#endif
} else if (column->is_descr) {
if (column->data_type != SQLT_RDD) {
@@ -2491,7 +2522,11 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode)
/* return the locator */
object_init_ex(value, oci_lob_class_entry_ptr);
add_property_resource(value, "descriptor", column->descid);
+#if PHP_VERSION_ID < 70300
++GC_REFCOUNT(column->descid);
+#else
+ GC_ADDREF(column->descid);
+#endif
}
} else {
switch (column->retcode) {
@@ -2873,7 +2908,9 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char *
{
smart_str spool_hashed_details = {0};
php_oci_spool *session_pool = NULL;
+#if PHP_VERSION_ID < 70300
zend_resource spool_le = {{0}};
+#endif
zend_resource *spool_out_le = NULL;
zend_bool iserror = 0;
zval *spool_out_zv = NULL;
@@ -2920,10 +2957,14 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char *
iserror = 1;
goto exit_get_spool;
}
+#if PHP_VERSION_ID < 70300
spool_le.ptr = session_pool;
spool_le.type = le_psessionpool;
PHP_OCI_REGISTER_RESOURCE(session_pool, le_psessionpool);
zend_hash_update_mem(&EG(persistent_list), session_pool->spool_hash_key, (void *)&spool_le, sizeof(zend_resource));
+#else
+ zend_register_persistent_resource_ex(session_pool->spool_hash_key, session_pool, le_psessionpool);
+#endif
} else if (spool_out_le->type == le_psessionpool &&
ZSTR_LEN(((php_oci_spool *)(spool_out_le->ptr))->spool_hash_key) == ZSTR_LEN(spool_hashed_details.s) &&
memcmp(ZSTR_VAL(((php_oci_spool *)(spool_out_le->ptr))->spool_hash_key), ZSTR_VAL(spool_hashed_details.s), ZSTR_LEN(spool_hashed_details.s)) == 0) {
diff --git a/ext/oci8/oci8_collection.c b/ext/oci8/oci8_collection.c
index 3744a84b9b..7ddda06bb2 100644
--- a/ext/oci8/oci8_collection.c
+++ b/ext/oci8/oci8_collection.c
@@ -52,7 +52,11 @@ php_oci_collection *php_oci_collection_create(php_oci_connection *connection, ch
collection->connection = connection;
collection->collection = NULL;
+#if PHP_VERSION_ID < 70300
++GC_REFCOUNT(collection->connection->id);
+#else
+ GC_ADDREF(collection->connection->id);
+#endif
/* get type handle by name */
PHP_OCI_CALL_RETURN(errstatus, OCITypeByName,
diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c
index cd17386b5f..82cb30bfbf 100644
--- a/ext/oci8/oci8_interface.c
+++ b/ext/oci8/oci8_interface.c
@@ -60,16 +60,28 @@ PHP_FUNCTION(oci_register_taf_callback)
if (!zend_is_callable(callback, 0, 0)) {
callback_name = zend_get_callable_name(callback);
php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(callback_name));
+#if PHP_VERSION_ID < 70300
zend_string_release(callback_name);
+#else
+ zend_string_release_ex(callback_name, 0);
+#endif
RETURN_FALSE;
}
#else
if (!zend_is_callable(callback, 0, &callback_name)) {
php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(callback_name));
+#if PHP_VERSION_ID < 70300
zend_string_release(callback_name);
+#else
+ zend_string_release_ex(callback_name, 0);
+#endif
RETURN_FALSE;
}
+#if PHP_VERSION_ID < 70300
zend_string_release(callback_name);
+#else
+ zend_string_release_ex(callback_name, 0);
+#endif
#endif
}
@@ -141,10 +153,18 @@ PHP_FUNCTION(oci_define_by_name)
/* if (zend_hash_add(statement->defines, name, name_len, define, sizeof(php_oci_define), (void **)&tmp_define) == SUCCESS) { */
zvtmp = zend_string_init(name, name_len, 0);
if ((define = zend_hash_add_new_ptr(statement->defines, zvtmp, define)) != NULL) {
+#if PHP_VERSION_ID < 70300
zend_string_release(zvtmp);
+#else
+ zend_string_release_ex(zvtmp, 0);
+#endif
} else {
efree(define);
+#if PHP_VERSION_ID < 70300
zend_string_release(zvtmp);
+#else
+ zend_string_release_ex(zvtmp, 0);
+#endif
RETURN_FALSE;
}
@@ -1472,7 +1492,11 @@ PHP_FUNCTION(oci_fetch_all)
zend_string *zvtmp;
zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
zend_symtable_update(Z_ARRVAL(row), zvtmp, &element);
+#if PHP_VERSION_ID < 70300
zend_string_release(zvtmp);
+#else
+ zend_string_release_ex(zvtmp, 0);
+#endif
}
}
@@ -1507,7 +1531,11 @@ PHP_FUNCTION(oci_fetch_all)
array_init(&tmp);
zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
outarrs[ i ] = zend_symtable_update(Z_ARRVAL_P(array), zvtmp, &tmp);
+#if PHP_VERSION_ID < 70300
zend_string_release(zvtmp);
+#else
+ zend_string_release_ex(zvtmp, 0);
+#endif
}
}
diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c
index f80aeae787..1a44389951 100644
--- a/ext/oci8/oci8_lob.c
+++ b/ext/oci8/oci8_lob.c
@@ -67,7 +67,11 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, zend_lon
descriptor = ecalloc(1, sizeof(php_oci_descriptor));
descriptor->type = (ub4) type;
descriptor->connection = connection;
+#if PHP_VERSION_ID < 70300
++GC_REFCOUNT(descriptor->connection->id);
+#else
+ GC_ADDREF(descriptor->connection->id);
+#endif
PHP_OCI_CALL_RETURN(errstatus, OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0));
diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c
index a0635fb7e6..31b5a48cb8 100644
--- a/ext/oci8/oci8_statement.c
+++ b/ext/oci8/oci8_statement.c
@@ -111,7 +111,11 @@ php_oci_statement *php_oci_statement_create(php_oci_connection *connection, char
statement->impres_child_stmt = NULL;
statement->impres_count = 0;
statement->impres_flag = PHP_OCI_IMPRES_UNKNOWN; /* may or may not have Implicit Result Set children */
+#if PHP_VERSION_ID < 70300
++GC_REFCOUNT(statement->connection->id);
+#else
+ GC_ADDREF(statement->connection->id);
+#endif
if (OCI_G(default_prefetch) >= 0) {
php_oci_statement_set_prefetch(statement, (ub4)OCI_G(default_prefetch));
@@ -171,8 +175,13 @@ php_oci_statement *php_oci_get_implicit_resultset(php_oci_statement *statement)
statement2->has_descr = 0;
statement2->stmttype = 0;
+#if PHP_VERSION_ID < 70300
GC_REFCOUNT(statement->id)++;
GC_REFCOUNT(statement2->connection->id)++;
+#else
+ GC_ADDREF(statement->id);
+ GC_ADDREF(statement2->connection->id);
+#endif
php_oci_statement_set_prefetch(statement2, statement->prefetch_count);
@@ -433,7 +442,11 @@ sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **buf
return OCI_ERROR;
}
nested_stmt->parent_stmtid = outcol->statement->id;
+#if PHP_VERSION_ID < 70300
++GC_REFCOUNT(outcol->statement->id);
+#else
+ GC_ADDREF(outcol->statement->id);
+#endif
outcol->nested_statement = nested_stmt;
outcol->stmtid = nested_stmt->id;
@@ -595,11 +608,15 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode)
for (counter = 1; counter <= colcount; counter++) {
outcol = (php_oci_out_column *) ecalloc(1, sizeof(php_oci_out_column));
+#if PHP_VERSION_ID < 70300
if ((outcol = zend_hash_index_update_ptr(statement->columns, counter, outcol)) == NULL) {
FREE_HASHTABLE(statement->columns);
/* out of memory */
return 1;
}
+#else
+ outcol = zend_hash_index_update_ptr(statement->columns, counter, outcol);
+#endif
/* get column */
PHP_OCI_CALL_RETURN(errstatus, OCIParamGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, statement->err, (dvoid**)&param, counter));
@@ -993,8 +1010,12 @@ int php_oci_bind_post_exec(zval *data)
* binds, php_oci_bind_out_callback() should have allocated a
* new string that we can modify here.
*/
+#if PHP_VERSION_ID < 70300
SEPARATE_STRING(zv);
Z_STR_P(zv) = zend_string_extend(Z_STR_P(zv), Z_STRLEN_P(zv)+1, 0);
+#else
+ ZVAL_NEW_STR(zv, zend_string_extend(Z_STR_P(zv), Z_STRLEN_P(zv)+1, 0));
+#endif
Z_STRVAL_P(zv)[ Z_STRLEN_P(zv) ] = '\0';
} else if (Z_TYPE_P(zv) == IS_ARRAY) {
int i;
@@ -1257,7 +1278,11 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, size_t name_l
zvtmp = zend_string_init(name, name_len, 0);
bindp = (php_oci_bind *) ecalloc(1, sizeof(php_oci_bind));
bindp = zend_hash_update_ptr(statement->binds, zvtmp, bindp);
+#if PHP_VERSION_ID < 70300
zend_string_release(zvtmp);
+#else
+ zend_string_release_ex(zvtmp, 0);
+#endif
}
/* Make sure the minimum of value_sz is 1 to avoid ORA-3149
@@ -1528,6 +1553,7 @@ php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAME
return NULL;
}
} else {
+#if PHP_VERSION_ID < 70300
zval tmp;
/* NB: for PHP4 compat only, it should be using 'Z' instead */
tmp = *column_index;
@@ -1540,6 +1566,17 @@ php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAME
return NULL;
}
zval_ptr_dtor(&tmp);
+#else
+ zend_long tmp;
+ /* NB: for PHP4 compat only, it should be using 'Z' instead */
+
+ tmp = zval_get_long(column_index);
+ column = php_oci_statement_get_column(statement, tmp, NULL, 0);
+ if (!column) {
+ php_error_docref(NULL, E_WARNING, "Invalid column index \"" ZEND_LONG_FMT "\"", tmp);
+ return NULL;
+ }
+#endif
}
return column;
}
@@ -1602,8 +1639,13 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, size_t
ZEND_ASSERT(Z_ISREF_P(var));
val = Z_REFVAL_P(var);
+#if PHP_VERSION_ID < 70300
SEPARATE_ZVAL_NOREF(val);
convert_to_array(val);
+#else
+ convert_to_array(val);
+ SEPARATE_ARRAY(val);
+#endif
if (maxlength < -1) {
php_error_docref(NULL, E_WARNING, "Invalid max length value (" ZEND_LONG_FMT ")", maxlength);
@@ -1706,7 +1748,11 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, size_t
zvtmp = zend_string_init(name, name_len, 0);
zend_hash_update_ptr(statement->binds, zvtmp, bind);
+#if PHP_VERSION_ID < 70300
zend_string_release(zvtmp);
+#else
+ zend_string_release_ex(zvtmp, 0);
+#endif
statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return 0;