Skip to content

Commit b797818

Browse files
committed
Simplify based on feedback from nikic
1 parent bc32061 commit b797818

File tree

4 files changed

+8
-74
lines changed

4 files changed

+8
-74
lines changed

ext/oci8/oci8.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,11 +1455,7 @@ void php_oci_column_hash_dtor(zval *data)
14551455
if (GC_REFCOUNT(column->descid) == 1)
14561456
zend_list_close(column->descid);
14571457
else {
1458-
#if PHP_VERSION_ID < 70300
1459-
GC_REFCOUNT(column->descid)--;
1460-
#else
14611458
GC_DELREF(column->descid);
1462-
#endif
14631459
}
14641460
}
14651461

@@ -1882,11 +1878,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
18821878
(memcmp(ZSTR_VAL(tmp->hash_key), ZSTR_VAL(hashed_details.s),
18831879
ZSTR_LEN(tmp->hash_key)) == 0)) {
18841880
connection = tmp;
1885-
#if PHP_VERSION_ID < 70300
1886-
++GC_REFCOUNT(connection->id);
1887-
#else
18881881
GC_ADDREF(connection->id);
1889-
#endif
18901882
}
18911883
} else {
18921884
PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection);
@@ -1896,11 +1888,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
18961888
* decremented in the persistent helper
18971889
*/
18981890
if (OCI_G(old_oci_close_semantics)) {
1899-
#if PHP_VERSION_ID < 70300
1900-
++GC_REFCOUNT(connection->id);
1901-
#else
19021891
GC_ADDREF(connection->id);
1903-
#endif
19041892
}
19051893
}
19061894
smart_str_free(&hashed_details);
@@ -1911,11 +1899,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
19111899
} else {
19121900
/* we do not ping non-persistent connections */
19131901
smart_str_free(&hashed_details);
1914-
#if PHP_VERSION_ID < 70300
1915-
++GC_REFCOUNT(connection->id);
1916-
#else
19171902
GC_ADDREF(connection->id);
1918-
#endif
19191903
return connection;
19201904
}
19211905
} /* is_open is true? */
@@ -2069,11 +2053,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
20692053
* refcount is decremented in the persistent helper
20702054
*/
20712055
if (OCI_G(old_oci_close_semantics)) {
2072-
#if PHP_VERSION_ID < 70300
2073-
++GC_REFCOUNT(connection->id);
2074-
#else
20752056
GC_ADDREF(connection->id);
2076-
#endif
20772057
}
20782058
#if PHP_VERSION_ID < 70300
20792059
zend_hash_update_mem(&EG(persistent_list), connection->hash_key, (void *)&new_le, sizeof(zend_resource));
@@ -2474,11 +2454,7 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode)
24742454

24752455
if (column->is_cursor) { /* REFCURSOR -> simply return the statement id */
24762456
ZVAL_RES(value, column->stmtid);
2477-
#if PHP_VERSION_ID < 70300
2478-
++GC_REFCOUNT(column->stmtid);
2479-
#else
24802457
GC_ADDREF(column->stmtid);
2481-
#endif
24822458
} else if (column->is_descr) {
24832459

24842460
if (column->data_type != SQLT_RDD) {
@@ -2522,11 +2498,7 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode)
25222498
/* return the locator */
25232499
object_init_ex(value, oci_lob_class_entry_ptr);
25242500
add_property_resource(value, "descriptor", column->descid);
2525-
#if PHP_VERSION_ID < 70300
2526-
++GC_REFCOUNT(column->descid);
2527-
#else
25282501
GC_ADDREF(column->descid);
2529-
#endif
25302502
}
25312503
} else {
25322504
switch (column->retcode) {

ext/oci8/oci8_lob.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, zend_lon
6767
descriptor = ecalloc(1, sizeof(php_oci_descriptor));
6868
descriptor->type = (ub4) type;
6969
descriptor->connection = connection;
70-
#if PHP_VERSION_ID < 70300
71-
++GC_REFCOUNT(descriptor->connection->id);
72-
#else
7370
GC_ADDREF(descriptor->connection->id);
74-
#endif
7571

7672
PHP_OCI_CALL_RETURN(errstatus, OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0));
7773

ext/oci8/oci8_statement.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,7 @@ php_oci_statement *php_oci_statement_create(php_oci_connection *connection, char
111111
statement->impres_child_stmt = NULL;
112112
statement->impres_count = 0;
113113
statement->impres_flag = PHP_OCI_IMPRES_UNKNOWN; /* may or may not have Implicit Result Set children */
114-
#if PHP_VERSION_ID < 70300
115-
++GC_REFCOUNT(statement->connection->id);
116-
#else
117114
GC_ADDREF(statement->connection->id);
118-
#endif
119115

120116
if (OCI_G(default_prefetch) >= 0) {
121117
php_oci_statement_set_prefetch(statement, (ub4)OCI_G(default_prefetch));
@@ -175,13 +171,8 @@ php_oci_statement *php_oci_get_implicit_resultset(php_oci_statement *statement)
175171
statement2->has_descr = 0;
176172
statement2->stmttype = 0;
177173

178-
#if PHP_VERSION_ID < 70300
179-
GC_REFCOUNT(statement->id)++;
180-
GC_REFCOUNT(statement2->connection->id)++;
181-
#else
182174
GC_ADDREF(statement->id);
183175
GC_ADDREF(statement2->connection->id);
184-
#endif
185176

186177
php_oci_statement_set_prefetch(statement2, statement->prefetch_count);
187178

@@ -442,11 +433,7 @@ sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **buf
442433
return OCI_ERROR;
443434
}
444435
nested_stmt->parent_stmtid = outcol->statement->id;
445-
#if PHP_VERSION_ID < 70300
446-
++GC_REFCOUNT(outcol->statement->id);
447-
#else
448436
GC_ADDREF(outcol->statement->id);
449-
#endif
450437
outcol->nested_statement = nested_stmt;
451438
outcol->stmtid = nested_stmt->id;
452439

@@ -608,15 +595,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode)
608595
for (counter = 1; counter <= colcount; counter++) {
609596
outcol = (php_oci_out_column *) ecalloc(1, sizeof(php_oci_out_column));
610597

611-
#if PHP_VERSION_ID < 70300
612-
if ((outcol = zend_hash_index_update_ptr(statement->columns, counter, outcol)) == NULL) {
613-
FREE_HASHTABLE(statement->columns);
614-
/* out of memory */
615-
return 1;
616-
}
617-
#else
618598
outcol = zend_hash_index_update_ptr(statement->columns, counter, outcol);
619-
#endif
620599

621600
/* get column */
622601
PHP_OCI_CALL_RETURN(errstatus, OCIParamGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, statement->err, (dvoid**)&param, counter));
@@ -1553,30 +1532,14 @@ php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAME
15531532
return NULL;
15541533
}
15551534
} else {
1556-
#if PHP_VERSION_ID < 70300
1557-
zval tmp;
1558-
/* NB: for PHP4 compat only, it should be using 'Z' instead */
1559-
tmp = *column_index;
1560-
zval_copy_ctor(&tmp);
1561-
convert_to_long(&tmp);
1562-
column = php_oci_statement_get_column(statement, Z_LVAL(tmp), NULL, 0);
1563-
if (!column) {
1564-
php_error_docref(NULL, E_WARNING, "Invalid column index \"" ZEND_LONG_FMT "\"", Z_LVAL(tmp));
1565-
zval_ptr_dtor(&tmp);
1566-
return NULL;
1567-
}
1568-
zval_ptr_dtor(&tmp);
1569-
#else
15701535
zend_long tmp;
1571-
/* NB: for PHP4 compat only, it should be using 'Z' instead */
15721536

15731537
tmp = zval_get_long(column_index);
15741538
column = php_oci_statement_get_column(statement, tmp, NULL, 0);
15751539
if (!column) {
15761540
php_error_docref(NULL, E_WARNING, "Invalid column index \"" ZEND_LONG_FMT "\"", tmp);
15771541
return NULL;
15781542
}
1579-
#endif
15801543
}
15811544
return column;
15821545
}
@@ -1639,13 +1602,8 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, size_t
16391602

16401603
ZEND_ASSERT(Z_ISREF_P(var));
16411604
val = Z_REFVAL_P(var);
1642-
#if PHP_VERSION_ID < 70300
1643-
SEPARATE_ZVAL_NOREF(val);
1644-
convert_to_array(val);
1645-
#else
16461605
convert_to_array(val);
16471606
SEPARATE_ARRAY(val);
1648-
#endif
16491607

16501608
if (maxlength < -1) {
16511609
php_error_docref(NULL, E_WARNING, "Invalid max length value (" ZEND_LONG_FMT ")", maxlength);

ext/oci8/php_oci8_int.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,14 @@ int php_oci_unregister_taf_callback(php_oci_connection *connection);
545545
#define OCI_G(v) (oci_globals.v)
546546
#endif
547547

548+
/* Allow install from PECL on PHP < 7.3 */
549+
#ifndef GC_ADDREF
550+
# define GC_ADDREF(p) (++GC_REFCOUNT(p))
551+
#endif
552+
#ifndef GC_DELREF
553+
# define GC_DELREF(p) (GC_REFCOUNT(p)--)
554+
#endif
555+
548556
ZEND_EXTERN_MODULE_GLOBALS(oci)
549557

550558
# endif /* !PHP_OCI8_INT_H */

0 commit comments

Comments
 (0)