]> granicus.if.org Git - php/commitdiff
Some cleanup in OCI8 extension for PHP 8
authorGeorge Peter Banyard <girgias@php.net>
Wed, 20 May 2020 14:20:33 +0000 (16:20 +0200)
committerChristopher Jones <sixd@php.net>
Wed, 22 Jul 2020 07:29:30 +0000 (17:29 +1000)
ext/oci8/oci8.c
ext/oci8/oci8_collection.c
ext/oci8/oci8_failover.c
ext/oci8/oci8_interface.c
ext/oci8/oci8_lob.c
ext/oci8/oci8_statement.c
ext/oci8/php_oci8.h
ext/oci8/php_oci8_int.h

index 8196e90608fe7dc85de82cd7e0be4c7481d4ef54..06ea6adcc797d290a03f96186b2a87f1138f9061 100644 (file)
@@ -33,7 +33,7 @@
 #include "php_ini.h"
 #include "zend_smart_str.h"
 
-#if HAVE_OCI8
+#ifdef HAVE_OCI8
 
 /* PHP 5.2 is the minimum supported version for OCI8 2.0 */
 #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
 
        /* 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);
 
@@ -1303,11 +1299,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
                if (OCI_G(old_oci_close_semantics)) {
                        GC_ADDREF(connection->id);
                }
-#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) {
@@ -2135,9 +2127,6 @@ 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;
@@ -2184,14 +2173,7 @@ 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) {
index b6a363da1b6e365e809ace23d8c9d7685a6ff95f..8f1d06d6aff97d198b3fb538f846645088018a2f 100644 (file)
@@ -31,7 +31,7 @@
 #include "ext/standard/info.h"
 #include "php_ini.h"
 
-#if HAVE_OCI8
+#ifdef HAVE_OCI8
 
 #include "php_oci8.h"
 #include "php_oci8_int.h"
@@ -50,11 +50,7 @@ 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,
index 7854defdbc6339e86bf8a77c0fb1a1751005846d..1d9c4e58cf11ba3f8f587df6e60f947540daf812 100644 (file)
@@ -33,7 +33,7 @@
 #include "ext/standard/info.h"
 #include "php_ini.h"
 
-#if HAVE_OCI8
+#ifdef HAVE_OCI8
 
 #include "php_oci8.h"
 #include "php_oci8_int.h"
index 58e069eb5d4437841e0ca7bb4bb651580df6ed83..689ac1c2e0b18fd7884edeecd3070b25bcf06873 100644 (file)
@@ -31,7 +31,7 @@
 #include "ext/standard/info.h"
 #include "php_ini.h"
 
-#if HAVE_OCI8
+#ifdef HAVE_OCI8
 
 #include "php_oci8.h"
 #include "php_oci8_int.h"
@@ -48,38 +48,18 @@ PHP_FUNCTION(oci_register_taf_callback)
        zval *callback;
        zend_string *callback_name;
 
+       /* TODO Use ZPP callable */
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|z!", &z_connection, &callback) == FAILURE) {
                RETURN_THROWS();
        }
 
        if (callback) {
-#if PHP_MAJOR_VERSION > 7 || (PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION >= 2)
                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
        }
 
        PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
@@ -152,18 +132,10 @@ 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;
        }
 
@@ -1365,11 +1337,7 @@ 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
                                }
                        }
 
@@ -1408,11 +1376,7 @@ 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
                        }
                }
 
index 2c5598673f1eb077c8e73dced9044600a04e5e92..7fb6fb73f854bb2468ba7d00ceb4d6a61e7da0db 100644 (file)
@@ -31,7 +31,7 @@
 #include "ext/standard/info.h"
 #include "php_ini.h"
 
-#if HAVE_OCI8
+#ifdef HAVE_OCI8
 
 #include "php_oci8.h"
 #include "php_oci8_int.h"
index c64fb35083f24e48085efef762b5b1dfe344b9b1..e16e38713d4568a023b778bbb7d428d21171e815 100644 (file)
@@ -31,7 +31,7 @@
 #include "ext/standard/info.h"
 #include "php_ini.h"
 
-#if HAVE_OCI8
+#ifdef HAVE_OCI8
 
 #include "php_oci8.h"
 #include "php_oci8_int.h"
@@ -995,12 +995,7 @@ 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;
@@ -1265,11 +1260,7 @@ 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
@@ -1717,11 +1708,7 @@ 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;
index d9be44ce8773a49a64e7f548204c0752d4ca2d35..c1ebf7b86e0c14d2a51eaea0344b0ba2b0ebecf8 100644 (file)
@@ -23,7 +23,7 @@
    +----------------------------------------------------------------------+
 */
 
-#if HAVE_OCI8
+#ifdef HAVE_OCI8
 # ifndef PHP_OCI8_H
 #  define PHP_OCI8_H
 
index 60d9b32fe05aebeea2cafb01791c1e7560a5fb3d..825437bc5704d0a36b2f1f7c966cad49cd6b2eb9 100644 (file)
@@ -23,7 +23,7 @@
    +----------------------------------------------------------------------+
 */
 
-#if HAVE_OCI8
+#ifdef HAVE_OCI8
 # ifndef PHP_OCI8_INT_H
 #  define PHP_OCI8_INT_H