From 12f9939b790a02ca3f22b91813029e78208f2c24 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 7 Oct 2013 17:23:11 -0700 Subject: [PATCH] Bump mininum requirements for PHP OCI8 2.0 to PHP 5.2 and Oracle client library 10.2 (Note this will connect to Oracle Database 8.1.7 onwards). Use the older OCI8 1.4 from PECL if using an earlier PHP version or older Oracle client library support is necessary. --- ext/oci8/config.m4 | 25 ++++-------------------- ext/oci8/config.w32 | 2 -- ext/oci8/oci8.c | 40 +++----------------------------------- ext/oci8/oci8_collection.c | 12 ------------ ext/oci8/oci8_interface.c | 12 ------------ ext/oci8/oci8_lob.c | 38 ------------------------------------ ext/oci8/package.xml | 25 ++++++++++++++---------- ext/oci8/php_oci8_int.h | 4 ---- 8 files changed, 22 insertions(+), 136 deletions(-) diff --git a/ext/oci8/config.m4 b/ext/oci8/config.m4 index 3873a2205a..0d08d21c29 100644 --- a/ext/oci8/config.m4 +++ b/ext/oci8/config.m4 @@ -208,8 +208,8 @@ if test "$PHP_OCI8" != "no"; then IFS=$ac_IFS oci8_php_version=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3` - if test "$oci8_php_version" -lt "4003009"; then - AC_MSG_ERROR([You need at least PHP 4.3.9 to be able to use this version of OCI8. PHP $php_version found]) + if test "$oci8_php_version" -lt "5002000"; then + AC_MSG_ERROR([You need at least PHP 5.2.0 to be able to use this version of OCI8. PHP $php_version found]) else AC_MSG_RESULT([$php_version, ok]) fi @@ -332,24 +332,8 @@ if test "$PHP_OCI8" != "no"; then AC_OCI8_ORACLE_VERSION($OCI8_DIR) case $OCI8_ORACLE_VERSION in - 7.3|8.0|8.1) - AC_MSG_ERROR([Oracle client libraries < 9.2 are not supported]) - ;; - - 9.0) - PHP_CHECK_LIBRARY(clntsh, OCIEnvNlsCreate, - [ - OCI8_ORACLE_VERSION=9.2 - ], - [ - AC_MSG_ERROR([Oracle client libraries < 9.2 are not supported]) - ], [ - -L$OCI8_DIR/$OCI8_LIB_DIR $OCI8_SHARED_LIBADD - ]) - ;; - - *) - AC_DEFINE(HAVE_OCI_LOB_READ2,1,[Defined to 1 if OCI8 configuration located Oracle's OCILobRead2 function]) + 7.3|8.0|8.1|9.0) + AC_MSG_ERROR([Oracle client libraries < 10 are not supported]) ;; esac @@ -425,7 +409,6 @@ if test "$PHP_OCI8" != "no"; then PHP_ADD_LIBPATH($PHP_OCI8_INSTANT_CLIENT, OCI8_SHARED_LIBADD) AC_DEFINE(HAVE_OCI_INSTANT_CLIENT,1,[Defined to 1 if OCI8 configuration located Oracle's Instant Client libraries]) - AC_DEFINE(HAVE_OCI_LOB_READ2,1,[Defined to 1 if OCI8 configuration located Oracle's OCILobRead2 function]) PHP_NEW_EXTENSION(oci8, oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c, $ext_shared) AC_DEFINE(HAVE_OCI8,1,[Defined to 1 if the PHP OCI8 extension for Oracle Database is configured]) diff --git a/ext/oci8/config.w32 b/ext/oci8/config.w32 index ac573a8af3..750f163950 100644 --- a/ext/oci8/config.w32 +++ b/ext/oci8/config.w32 @@ -29,8 +29,6 @@ if (PHP_OCI8_12C != "no") { AC_DEFINE('HAVE_OCI8', 1); AC_DEFINE('HAVE_OCI_INSTANT_CLIENT', 1); - AC_DEFINE('HAVE_OCI_LOB_READ2', 1); - } else { WARNING("oci8-12c not enabled: Oracle Database client libraries or Oracle Database 12c Instant Client not found"); PHP_OCI8_12C = "no" diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index eeb1ade7bb..f8abacf3e6 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -39,12 +39,9 @@ #if HAVE_OCI8 -#if PHP_MAJOR_VERSION > 5 -#error This version of the PHP OCI8 extension is not compatible with PHP 6 or later -#elif PHP_MAJOR_VERSION < 5 -#ifdef ZTS -#error The PHP OCI8 extension does not support ZTS mode in PHP 4 -#endif +/* 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) +#error Use PHP OCI8 1.4 for your version of PHP #endif #include "php_oci8.h" @@ -66,11 +63,8 @@ #endif ZEND_DECLARE_MODULE_GLOBALS(oci) -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) -/* This "if" allows PECL builds from this file to be portable to older PHP releases */ static PHP_GINIT_FUNCTION(oci); static PHP_GSHUTDOWN_FUNCTION(oci); -#endif /* Allow PHP 5.3 branch to be used in PECL for 5.x compatible builds */ #ifndef Z_ADDREF_P @@ -1055,16 +1049,11 @@ zend_module_entry oci8_module_entry = { PHP_RSHUTDOWN(oci), /* per-request shutdown function */ PHP_MINFO(oci), /* information function */ PHP_OCI8_VERSION, -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) - /* This check allows PECL builds from this file to be portable to older PHP releases */ PHP_MODULE_GLOBALS(oci), /* globals descriptor */ PHP_GINIT(oci), /* globals ctor */ PHP_GSHUTDOWN(oci), /* globals dtor */ NULL, /* post deactivate */ STANDARD_MODULE_PROPERTIES_EX -#else - STANDARD_MODULE_PROPERTIES -#endif }; /* }}} */ @@ -1183,12 +1172,7 @@ static void php_oci_cleanup_global_handles(TSRMLS_D) * * Zerofill globals during module init */ -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) -/* This check allows PECL builds from this file to be portable to older PHP releases */ static PHP_GINIT_FUNCTION(oci) -#else -static void php_oci_init_globals(zend_oci_globals *oci_globals TSRMLS_DC) -#endif { memset(oci_globals, 0, sizeof(zend_oci_globals)); } @@ -1198,12 +1182,7 @@ static void php_oci_init_globals(zend_oci_globals *oci_globals TSRMLS_DC) * * Called for thread shutdown in ZTS, after module shutdown for non-ZTS */ -/* This check allows PECL builds from this file to be portable to older PHP releases */ -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) static PHP_GSHUTDOWN_FUNCTION(oci) -#else -static void php_oci_shutdown_globals(zend_oci_globals *oci_globals TSRMLS_DC) -#endif { php_oci_cleanup_global_handles(TSRMLS_C); } @@ -1214,12 +1193,6 @@ PHP_MINIT_FUNCTION(oci) zend_class_entry oci_lob_class_entry; zend_class_entry oci_coll_class_entry; -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) - /* This check allows PECL builds from this file to be portable to older PHP releases */ - /* this is handled by new globals management code */ -#else - ZEND_INIT_MODULE_GLOBALS(oci, php_oci_init_globals, php_oci_shutdown_globals); -#endif REGISTER_INI_ENTRIES(); le_statement = zend_register_list_destructors_ex(php_oci_statement_list_dtor, NULL, "oci8 statement", module_number); @@ -1331,13 +1304,6 @@ PHP_RINIT_FUNCTION(oci) PHP_MSHUTDOWN_FUNCTION(oci) { -/* Work around PHP_GSHUTDOWN_FUNCTION not being called in older versions of PHP */ -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 2) || (PHP_MAJOR_VERSION < 5) -#ifndef ZTS - php_oci_cleanup_global_handles(TSRMLS_C); -#endif -#endif - OCI_G(shutdown) = 1; UNREGISTER_INI_ENTRIES(); diff --git a/ext/oci8/oci8_collection.c b/ext/oci8/oci8_collection.c index 320e90a5b8..35b70fa7af 100644 --- a/ext/oci8/oci8_collection.c +++ b/ext/oci8/oci8_collection.c @@ -361,13 +361,7 @@ int php_oci_collection_append_number(php_oci_collection *collection, char *numbe php_oci_connection *connection = collection->connection; sword errstatus; -#if (PHP_MAJOR_VERSION == 4 && PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION < 10) - /* minimum PHP version ext/oci8/config.m4 accepts is 4.3.9 */ - element_double = strtod(number, NULL); -#else - /* zend_strtod was introduced in PHP 4.3.10 */ element_double = zend_strtod(number, NULL); -#endif PHP_OCI_CALL_RETURN(errstatus, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); @@ -666,13 +660,7 @@ int php_oci_collection_element_set_number(php_oci_collection *collection, long i php_oci_connection *connection = collection->connection; sword errstatus; -#if (PHP_MAJOR_VERSION == 4 && PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION < 10) - /* minimum PHP version ext/oci8/config.m4 accepts is 4.3.9 */ - element_double = strtod(number, NULL); -#else - /* zend_strtod was introduced in PHP 4.3.10 */ element_double = zend_strtod(number, NULL); -#endif PHP_OCI_CALL_RETURN(errstatus, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c index a452c1a7e2..ccaed79742 100644 --- a/ext/oci8/oci8_interface.c +++ b/ext/oci8/oci8_interface.c @@ -1429,13 +1429,7 @@ PHP_FUNCTION(oci_fetch_all) if (flags & PHP_OCI_NUM) { zend_hash_next_index_insert(Z_ARRVAL_P(row), &element, sizeof(zval*), NULL); } else { /* default to ASSOC */ -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) - /* zend_symtable_update is only available in 5.2+ */ zend_symtable_update(Z_ARRVAL_P(row), columns[ i ]->name, columns[ i ]->name_len+1, &element, sizeof(zval*), NULL); -#else - /* This code path means Bug #45458 will remain broken when OCI8 is built with PHP 4 */ - zend_hash_update(Z_ARRVAL_P(row), columns[ i ]->name, columns[ i ]->name_len+1, &element, sizeof(zval*), NULL); -#endif } } @@ -1467,13 +1461,7 @@ PHP_FUNCTION(oci_fetch_all) MAKE_STD_ZVAL(tmp); array_init(tmp); -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) - /* zend_symtable_update is only available in 5.2+ */ zend_symtable_update(Z_ARRVAL_P(array), columns[ i ]->name, columns[ i ]->name_len+1, (void *) &tmp, sizeof(zval*), (void **) &(outarrs[ i ])); -#else - /* This code path means Bug #45458 will remain broken when OCI8 is built with PHP 4 */ - zend_hash_update(Z_ARRVAL_P(array), columns[ i ]->name, columns[ i ]->name_len+1, (void *) &tmp, sizeof(zval*), (void **) &(outarrs[ i ])); -#endif } } diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c index 8d14dc3f50..4f58c65737 100644 --- a/ext/oci8/oci8_lob.c +++ b/ext/oci8/oci8_lob.c @@ -165,11 +165,7 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D /* {{{ php_oci_lob_callback() Append LOB portion to a memory buffer */ -#if defined(HAVE_OCI_LOB_READ2) sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, oraub8 len, ub1 piece, dvoid **changed_bufpp, oraub8 *changed_lenp) -#else -sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece) -#endif { ub4 lenp = (ub4) len; php_oci_lob_ctx *ctx = (php_oci_lob_ctx *)ctxp; @@ -251,14 +247,9 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini int buffer_size = PHP_OCI_LOB_BUFFER_SIZE; php_oci_lob_ctx ctx; ub1 *bufp; -#if defined(HAVE_OCI_LOB_READ2) oraub8 bytes_read, offset = 0; oraub8 requested_len = read_length; /* this is by default */ oraub8 chars_read = 0; -#else - int bytes_read, offset = 0; - int requested_len = read_length; /* this is by default */ -#endif int is_clob = 0; sb4 bytes_per_char = 1; sword errstatus; @@ -336,7 +327,6 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini ctx.alloc_len = (requested_len + 1) * bytes_per_char; *data = ecalloc(bytes_per_char, requested_len + 1); -#ifdef HAVE_OCI_LOB_READ2 if (is_clob) { chars_read = requested_len; bytes_read = 0; @@ -374,34 +364,6 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini } else { offset = descriptor->lob_current_position + bytes_read; } - -#else - - bytes_read = requested_len; - buffer_size = (requested_len < buffer_size ) ? requested_len : buffer_size; /* optimize buffer size */ - buffer_size = php_oci_lob_calculate_buffer(descriptor, buffer_size TSRMLS_CC); /* use chunk size */ - - bufp = (ub1 *) ecalloc(1, buffer_size); - PHP_OCI_CALL_RETURN(errstatus, OCILobRead, - ( - connection->svc, - connection->err, - descriptor->descriptor, - &bytes_read, /* IN/OUT bytes toread/read */ - offset + 1, /* offset (starts with 1) */ - (dvoid *) bufp, - (ub4) buffer_size, /* size of buffer */ - (dvoid *)&ctx, - (OCICallbackLobRead) php_oci_lob_callback, /* callback... */ - (ub2) descriptor->charset_id, /* The character set ID of the buffer data. */ - (ub1) descriptor->charset_form /* The character set form of the buffer data. */ - ) - ); - - efree(bufp); - offset = descriptor->lob_current_position + bytes_read; - -#endif if (errstatus != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); diff --git a/ext/oci8/package.xml b/ext/oci8/package.xml index 1161b031f3..d2c49726a8 100644 --- a/ext/oci8/package.xml +++ b/ext/oci8/package.xml @@ -8,12 +8,15 @@ http://pear.php.net/dtd/package-2.0.xsd"> Extension for Oracle Database - This extension allows you to access Oracle Database. OCI8 2.0 can - be built with PHP 4.3.9 onwards. OCI8 can be linked with Oracle - Database 9.2, 10, 11, or 12.1 client libraries. Oracle's standard - cross-version connectivity applies. For example PHP linked with - Oracle Database 11.2 client libraries can connect to Oracle - Database 9.2 onwards. +The PHP OCI8 extension gives access to Oracle Database. The extension +can be linked with Oracle client libraries from Oracle Database 10.2, +11, or 12.1. These libraries are found in the database installation, +or in the free Oracle Instant Client. Oracle's standard cross-version +connectivity applies. For example, PHP OCI8 linked with Instant +Client 11.2 can connect to Oracle Database 9.2 onwards. PHP OCI8 2.0 +can be built with PHP 5.2 onwards. Use the older PHP OCI8 1.4.10 when +using PHP 4.3.9 through to PHP 5.1.x, or when only Oracle Database 9.2 +client libraries are available. Christopher Jones @@ -40,7 +43,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> no - 2013-09-27 + 2013-10-08 @@ -53,7 +56,10 @@ http://pear.php.net/dtd/package-2.0.xsd"> PHP - - no notes yet +Bump mininum requirements for PHP OCI8 2.0 to PHP 5.2 and Oracle +client library 10.2 (Note this will connect to Oracle Database 8.1.7 +onwards). Use the older OCI8 1.4 if an earlier PHP version or older +Oracle client library support is necessary. @@ -438,8 +444,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - 4.3.9 - 6.0.0 + 5.2.0 1.4.0b1 diff --git a/ext/oci8/php_oci8_int.h b/ext/oci8/php_oci8_int.h index 2d4ff26947..e50983d75e 100644 --- a/ext/oci8/php_oci8_int.h +++ b/ext/oci8/php_oci8_int.h @@ -438,11 +438,7 @@ int php_oci_lob_append(php_oci_descriptor *descriptor_dest, php_oci_descriptor * int php_oci_lob_truncate(php_oci_descriptor *descriptor, long new_lob_length TSRMLS_DC); int php_oci_lob_erase(php_oci_descriptor *descriptor, long offset, ub4 length, ub4 *bytes_erased TSRMLS_DC); int php_oci_lob_is_equal(php_oci_descriptor *descriptor_first, php_oci_descriptor *descriptor_second, boolean *result TSRMLS_DC); -#if defined(HAVE_OCI_LOB_READ2) sb4 php_oci_lob_callback(dvoid *ctxp, CONST dvoid *bufxp, oraub8 len, ub1 piece, dvoid **changed_bufpp, oraub8 *changed_lenp); -#else -sb4 php_oci_lob_callback(dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece); -#endif /* }}} */ /* {{{ collection related prototypes */ -- 2.40.0