Skip to content

Commit c9aeff5

Browse files
committed
Some cleanup in OCI8 extension for PHP 8
1 parent be0d912 commit c9aeff5

8 files changed

+9
-80
lines changed

ext/oci8/oci8.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "php_ini.h"
3434
#include "zend_smart_str.h"
3535

36-
#if HAVE_OCI8
36+
#ifdef HAVE_OCI8
3737

3838
/* PHP 5.2 is the minimum supported version for OCI8 2.0 */
3939
#if PHP_MAJOR_VERSION < 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION <= 1)
@@ -1289,10 +1289,6 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
12891289

12901290
/* add to the appropriate hash */
12911291
if (connection->is_persistent) {
1292-
#if PHP_VERSION_ID < 70300
1293-
new_le.ptr = connection;
1294-
new_le.type = le_pconnection;
1295-
#endif
12961292
connection->used_this_request = 1;
12971293
PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection);
12981294

@@ -1303,11 +1299,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
13031299
if (OCI_G(old_oci_close_semantics)) {
13041300
GC_ADDREF(connection->id);
13051301
}
1306-
#if PHP_VERSION_ID < 70300
1307-
zend_hash_update_mem(&EG(persistent_list), connection->hash_key, (void *)&new_le, sizeof(zend_resource));
1308-
#else
13091302
zend_register_persistent_resource_ex(connection->hash_key, connection, le_pconnection);
1310-
#endif
13111303
OCI_G(num_persistent)++;
13121304
OCI_G(num_links)++;
13131305
} else if (!exclusive) {
@@ -2135,9 +2127,6 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char *
21352127
{
21362128
smart_str spool_hashed_details = {0};
21372129
php_oci_spool *session_pool = NULL;
2138-
#if PHP_VERSION_ID < 70300
2139-
zend_resource spool_le = {{0}};
2140-
#endif
21412130
zend_resource *spool_out_le = NULL;
21422131
zend_bool iserror = 0;
21432132
zval *spool_out_zv = NULL;
@@ -2184,14 +2173,7 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char *
21842173
iserror = 1;
21852174
goto exit_get_spool;
21862175
}
2187-
#if PHP_VERSION_ID < 70300
2188-
spool_le.ptr = session_pool;
2189-
spool_le.type = le_psessionpool;
2190-
PHP_OCI_REGISTER_RESOURCE(session_pool, le_psessionpool);
2191-
zend_hash_update_mem(&EG(persistent_list), session_pool->spool_hash_key, (void *)&spool_le, sizeof(zend_resource));
2192-
#else
21932176
zend_register_persistent_resource_ex(session_pool->spool_hash_key, session_pool, le_psessionpool);
2194-
#endif
21952177
} else if (spool_out_le->type == le_psessionpool &&
21962178
ZSTR_LEN(((php_oci_spool *)(spool_out_le->ptr))->spool_hash_key) == ZSTR_LEN(spool_hashed_details.s) &&
21972179
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) {

ext/oci8/oci8_collection.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "ext/standard/info.h"
3232
#include "php_ini.h"
3333

34-
#if HAVE_OCI8
34+
#ifdef HAVE_OCI8
3535

3636
#include "php_oci8.h"
3737
#include "php_oci8_int.h"
@@ -50,11 +50,7 @@ php_oci_collection *php_oci_collection_create(php_oci_connection *connection, ch
5050

5151
collection->connection = connection;
5252
collection->collection = NULL;
53-
#if PHP_VERSION_ID < 70300
54-
++GC_REFCOUNT(collection->connection->id);
55-
#else
5653
GC_ADDREF(collection->connection->id);
57-
#endif
5854

5955
/* get type handle by name */
6056
PHP_OCI_CALL_RETURN(errstatus, OCITypeByName,

ext/oci8/oci8_failover.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "ext/standard/info.h"
3434
#include "php_ini.h"
3535

36-
#if HAVE_OCI8
36+
#ifdef HAVE_OCI8
3737

3838
#include "php_oci8.h"
3939
#include "php_oci8_int.h"

ext/oci8/oci8_interface.c

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "ext/standard/info.h"
3232
#include "php_ini.h"
3333

34-
#if HAVE_OCI8
34+
#ifdef HAVE_OCI8
3535

3636
#include "php_oci8.h"
3737
#include "php_oci8_int.h"
@@ -48,38 +48,18 @@ PHP_FUNCTION(oci_register_taf_callback)
4848
zval *callback;
4949
zend_string *callback_name;
5050

51+
/* TODO Use ZPP callable */
5152
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|z!", &z_connection, &callback) == FAILURE) {
5253
RETURN_THROWS();
5354
}
5455

5556
if (callback) {
56-
#if PHP_MAJOR_VERSION > 7 || (PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION >= 2)
5757
if (!zend_is_callable(callback, 0, 0)) {
5858
callback_name = zend_get_callable_name(callback);
5959
php_error_docref(NULL, E_WARNING, "Function '%s' is not callable", ZSTR_VAL(callback_name));
60-
#if PHP_VERSION_ID < 70300
6160
zend_string_release(callback_name);
62-
#else
63-
zend_string_release_ex(callback_name, 0);
64-
#endif
65-
RETURN_FALSE;
66-
}
67-
#else
68-
if (!zend_is_callable(callback, 0, &callback_name)) {
69-
php_error_docref(NULL, E_WARNING, "Function '%s' is not callable", ZSTR_VAL(callback_name));
70-
#if PHP_VERSION_ID < 70300
71-
zend_string_release(callback_name);
72-
#else
73-
zend_string_release_ex(callback_name, 0);
74-
#endif
7561
RETURN_FALSE;
7662
}
77-
#if PHP_VERSION_ID < 70300
78-
zend_string_release(callback_name);
79-
#else
80-
zend_string_release_ex(callback_name, 0);
81-
#endif
82-
#endif
8363
}
8464

8565
PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
@@ -152,18 +132,10 @@ PHP_FUNCTION(oci_define_by_name)
152132
/* if (zend_hash_add(statement->defines, name, name_len, define, sizeof(php_oci_define), (void **)&tmp_define) == SUCCESS) { */
153133
zvtmp = zend_string_init(name, name_len, 0);
154134
if ((define = zend_hash_add_new_ptr(statement->defines, zvtmp, define)) != NULL) {
155-
#if PHP_VERSION_ID < 70300
156-
zend_string_release(zvtmp);
157-
#else
158135
zend_string_release_ex(zvtmp, 0);
159-
#endif
160136
} else {
161137
efree(define);
162-
#if PHP_VERSION_ID < 70300
163-
zend_string_release(zvtmp);
164-
#else
165138
zend_string_release_ex(zvtmp, 0);
166-
#endif
167139
RETURN_FALSE;
168140
}
169141

@@ -1365,11 +1337,7 @@ PHP_FUNCTION(oci_fetch_all)
13651337
zend_string *zvtmp;
13661338
zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
13671339
zend_symtable_update(Z_ARRVAL(row), zvtmp, &element);
1368-
#if PHP_VERSION_ID < 70300
1369-
zend_string_release(zvtmp);
1370-
#else
13711340
zend_string_release_ex(zvtmp, 0);
1372-
#endif
13731341
}
13741342
}
13751343

@@ -1408,11 +1376,7 @@ PHP_FUNCTION(oci_fetch_all)
14081376
array_init(&tmp);
14091377
zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
14101378
outarrs[ i ] = zend_symtable_update(Z_ARRVAL_P(array), zvtmp, &tmp);
1411-
#if PHP_VERSION_ID < 70300
1412-
zend_string_release(zvtmp);
1413-
#else
14141379
zend_string_release_ex(zvtmp, 0);
1415-
#endif
14161380
}
14171381
}
14181382

ext/oci8/oci8_lob.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "ext/standard/info.h"
3232
#include "php_ini.h"
3333

34-
#if HAVE_OCI8
34+
#ifdef HAVE_OCI8
3535

3636
#include "php_oci8.h"
3737
#include "php_oci8_int.h"

ext/oci8/oci8_statement.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "ext/standard/info.h"
3232
#include "php_ini.h"
3333

34-
#if HAVE_OCI8
34+
#ifdef HAVE_OCI8
3535

3636
#include "php_oci8.h"
3737
#include "php_oci8_int.h"
@@ -995,12 +995,7 @@ int php_oci_bind_post_exec(zval *data)
995995
* binds, php_oci_bind_out_callback() should have allocated a
996996
* new string that we can modify here.
997997
*/
998-
#if PHP_VERSION_ID < 70300
999-
SEPARATE_STRING(zv);
1000-
Z_STR_P(zv) = zend_string_extend(Z_STR_P(zv), Z_STRLEN_P(zv)+1, 0);
1001-
#else
1002998
ZVAL_NEW_STR(zv, zend_string_extend(Z_STR_P(zv), Z_STRLEN_P(zv)+1, 0));
1003-
#endif
1004999
Z_STRVAL_P(zv)[ Z_STRLEN_P(zv) ] = '\0';
10051000
} else if (Z_TYPE_P(zv) == IS_ARRAY) {
10061001
int i;
@@ -1265,11 +1260,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, size_t name_l
12651260
zvtmp = zend_string_init(name, name_len, 0);
12661261
bindp = (php_oci_bind *) ecalloc(1, sizeof(php_oci_bind));
12671262
bindp = zend_hash_update_ptr(statement->binds, zvtmp, bindp);
1268-
#if PHP_VERSION_ID < 70300
12691263
zend_string_release(zvtmp);
1270-
#else
1271-
zend_string_release_ex(zvtmp, 0);
1272-
#endif
12731264
}
12741265

12751266
/* Make sure the minimum of value_sz is 1 to avoid ORA-3149
@@ -1717,11 +1708,7 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, size_t
17171708

17181709
zvtmp = zend_string_init(name, name_len, 0);
17191710
zend_hash_update_ptr(statement->binds, zvtmp, bind);
1720-
#if PHP_VERSION_ID < 70300
17211711
zend_string_release(zvtmp);
1722-
#else
1723-
zend_string_release_ex(zvtmp, 0);
1724-
#endif
17251712

17261713
statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */
17271714
return 0;

ext/oci8/php_oci8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
+----------------------------------------------------------------------+
2424
*/
2525

26-
#if HAVE_OCI8
26+
#ifdef HAVE_OCI8
2727
# ifndef PHP_OCI8_H
2828
# define PHP_OCI8_H
2929

ext/oci8/php_oci8_int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
+----------------------------------------------------------------------+
2424
*/
2525

26-
#if HAVE_OCI8
26+
#ifdef HAVE_OCI8
2727
# ifndef PHP_OCI8_INT_H
2828
# define PHP_OCI8_INT_H
2929

0 commit comments

Comments
 (0)