From b7031ba743fd8ca8f6e64df871054b796a979da0 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 12 Aug 2015 21:57:16 +1000 Subject: [PATCH] Further PHP 7 compat for OCI8 --- ext/oci8/oci8.c | 42 ++++++++++++++-------- ext/oci8/oci8_collection.c | 2 +- ext/oci8/oci8_interface.c | 48 ++++++++++++++----------- ext/oci8/oci8_lob.c | 28 +++++++-------- ext/oci8/oci8_statement.c | 38 ++++++++++---------- ext/oci8/php_oci8_int.h | 8 +++-- ext/oci8/tests/coll_002.phpt | 2 +- ext/oci8/tests/coll_002_func.phpt | 2 +- ext/oci8/tests/coll_006.phpt | 2 +- ext/oci8/tests/coll_006_func.phpt | 2 +- ext/oci8/tests/define4.phpt | 2 +- ext/oci8/tests/imp_res_get_close_1.phpt | 6 ++-- ext/oci8/tests/lob_014.phpt | 2 +- ext/oci8/tests/lob_021.phpt | 4 +-- ext/oci8/tests/lob_041.phpt | 2 +- ext/oci8/tests/old_oci_close1.phpt | 4 +-- 16 files changed, 109 insertions(+), 85 deletions(-) diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 9eae15e346..a1c693a388 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -1120,7 +1120,7 @@ static void php_oci_init_global_handles(void) OCIErrorGet(OCI_G(env), (ub4)1, NULL, &ora_error_code, tmp_buf, (ub4)PHP_OCI_ERRBUF_LEN, (ub4)OCI_HTYPE_ERROR); if (ora_error_code) { - int tmp_buf_len = strlen((char *)tmp_buf); + int tmp_buf_len = (int) strlen((char *)tmp_buf); if (tmp_buf_len > 0 && tmp_buf[tmp_buf_len - 1] == '\n') { tmp_buf[tmp_buf_len - 1] = '\0'; @@ -1701,7 +1701,7 @@ sb4 php_oci_fetch_errmsg(OCIError *error_handle, text *error_buf, size_t error_b PHP_OCI_CALL(OCIErrorGet, (error_handle, (ub4)1, NULL, &error_code, error_buf, (ub4)error_buf_size, (ub4)OCI_HTYPE_ERROR)); if (error_code) { - int err_buf_len = strlen((char *)error_buf); + int err_buf_len = (int) strlen((char *)error_buf); if (err_buf_len && error_buf[err_buf_len - 1] == '\n') { error_buf[err_buf_len - 1] = '\0'; @@ -1768,7 +1768,7 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus charset = NULL; } - connection = php_oci_do_connect_ex(username, username_len, password, password_len, NULL, 0, dbname, dbname_len, charset, session_mode, persistent, exclusive); + connection = php_oci_do_connect_ex(username, (int) username_len, password, (int) password_len, NULL, 0, dbname, (int) dbname_len, charset, session_mode, persistent, exclusive); #ifdef HAVE_OCI8_DTRACE if (DTRACE_OCI8_CONNECT_RETURN_ENABLED()) { @@ -1937,11 +1937,11 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char le = Z_RES_P(zvp); found = 1; if (le->type == le_index_ptr) { - void *ptr; + zend_resource *ptr; - ptr = le->ptr; /* PHPNG TODO */ - if (ptr && (le->type == le_connection)) { - connection = (php_oci_connection *)ptr; + ptr = (zend_resource *) le->ptr; /* PHPNG TODO */ + if (ptr && (ptr->type == le_connection)) { + connection = (php_oci_connection *)ptr->ptr; } } } @@ -1960,7 +1960,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char * TODO: put in negative code for non-persistent stubs */ if (connection && connection->is_persistent && connection->is_stub) { - if (php_oci_create_session(connection, NULL, dbname, dbname_len, username, username_len, password, password_len, new_password, new_password_len, session_mode)) { + if (php_oci_create_session(connection, NULL, dbname, dbname_len, username, username_len, password, password_len, new_password, new_password_len, (int) session_mode)) { smart_str_free(&hashed_details); zend_hash_del(&EG(persistent_list), connection->hash_key); @@ -2142,13 +2142,13 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char * connect/password change */ if (!use_spool) { - if (php_oci_old_create_session(connection, dbname, dbname_len, username, username_len, password, password_len, new_password, new_password_len, session_mode)) { + if (php_oci_old_create_session(connection, dbname, dbname_len, username, username_len, password, password_len, new_password, new_password_len, (int) session_mode)) { php_oci_connection_close(connection); return NULL; } } else { /* create using the client-side session pool */ - if (php_oci_create_session(connection, session_pool, dbname, dbname_len, username, username_len, password, password_len, new_password, new_password_len, session_mode)) { + if (php_oci_create_session(connection, session_pool, dbname, dbname_len, username, username_len, password, password_len, new_password, new_password_len, (int) session_mode)) { php_oci_connection_close(connection); return NULL; } @@ -2521,7 +2521,7 @@ int php_oci_server_get_version(php_oci_connection *connection, char *version, si { sword errstatus; - PHP_OCI_CALL_RETURN(errstatus, OCIServerVersion, (connection->svc, connection->err, (text *)version, version_size, OCI_HTYPE_SVCCTX)); + PHP_OCI_CALL_RETURN(errstatus, OCIServerVersion, (connection->svc, connection->err, (text *)version, (ub4) version_size, OCI_HTYPE_SVCCTX)); if (errstatus != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, errstatus); @@ -2798,7 +2798,7 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg if (!(column->indicator == -1)) { zval element; - php_oci_column_to_zval(column, &element, fetch_mode); + php_oci_column_to_zval(column, &element, (int) fetch_mode); if (fetch_mode & PHP_OCI_NUM || !(fetch_mode & PHP_OCI_ASSOC)) { add_index_zval(return_value, i, &element); @@ -3118,7 +3118,14 @@ static OCIEnv *php_oci_create_env(ub2 charsetid) */ static int php_oci_old_create_session(php_oci_connection *connection, char *dbname, int dbname_len, char *username, int username_len, char *password, int password_len, char *new_password, int new_password_len, int session_mode) { - ub4 statement_cache_size = (OCI_G(statement_cache_size) > 0) ? OCI_G(statement_cache_size) : 0; + ub4 statement_cache_size = 0; + + if (OCI_G(statement_cache_size) > 0) { + if (OCI_G(statement_cache_size) > UB4MAXVAL-1) + statement_cache_size = (ub4) UB4MAXVAL-1; + else + statement_cache_size = (ub4) OCI_G(statement_cache_size); + } /* Create the OCI environment separate for each connection */ if (!(connection->env = php_oci_create_env(connection->charset))) { @@ -3306,7 +3313,14 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool ub4 purity = -2; /* Illegal value to initialize */ #endif time_t timestamp = time(NULL); - ub4 statement_cache_size = (OCI_G(statement_cache_size) > 0) ? OCI_G(statement_cache_size) : 0; + ub4 statement_cache_size = 0; + + if (OCI_G(statement_cache_size) > 0) { + if (OCI_G(statement_cache_size) > UB4MAXVAL-1) + statement_cache_size = (ub4) UB4MAXVAL-1; + else + statement_cache_size = (ub4) OCI_G(statement_cache_size); + } /* Persistent connections have private session pools */ if (connection->is_persistent && !connection->private_spool && diff --git a/ext/oci8/oci8_collection.c b/ext/oci8/oci8_collection.c index 7b648d48e6..a2164be8b5 100644 --- a/ext/oci8/oci8_collection.c +++ b/ext/oci8/oci8_collection.c @@ -278,7 +278,7 @@ int php_oci_collection_trim(php_oci_collection *collection, zend_long trim_size) php_oci_connection *connection = collection->connection; sword errstatus; - PHP_OCI_CALL_RETURN(errstatus, OCICollTrim, (connection->env, connection->err, trim_size, collection->collection)); + PHP_OCI_CALL_RETURN(errstatus, OCICollTrim, (connection->env, connection->err, (sb4) trim_size, collection->collection)); if (errstatus != OCI_SUCCESS) { errstatus = php_oci_error(connection->err, errstatus); diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c index 5f414bd4ae..d161342a2d 100644 --- a/ext/oci8/oci8_interface.c +++ b/ext/oci8/oci8_interface.c @@ -91,8 +91,8 @@ PHP_FUNCTION(oci_define_by_name) define->name = (text*) ecalloc(1, name_len+1); memcpy(define->name, name, name_len); define->name[name_len] = '\0'; - define->name_len = name_len; - define->type = type; + define->name_len = (ub4) name_len; + define->type = (ub4) type; define->zval = var; RETURN_TRUE; @@ -157,7 +157,7 @@ PHP_FUNCTION(oci_bind_array_by_name) RETURN_FALSE; } - if (php_oci_bind_array_by_name(statement, name, name_len, bind_var, max_array_len, max_item_len, type)) { + if (php_oci_bind_array_by_name(statement, name, (sb4) name_len, bind_var, max_array_len, max_item_len, type)) { RETURN_FALSE; } RETURN_TRUE; @@ -223,7 +223,7 @@ PHP_FUNCTION(oci_lob_save) RETURN_FALSE; } - if (php_oci_lob_write(descriptor, offset, data, data_len, &bytes_written)) { + if (php_oci_lob_write(descriptor, (ub4) offset, data, (ub4) data_len, &bytes_written)) { RETURN_FALSE; } RETURN_TRUE; @@ -463,7 +463,7 @@ PHP_FUNCTION(oci_lob_seek) return; } } - + if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) { php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); RETURN_FALSE; @@ -477,11 +477,11 @@ PHP_FUNCTION(oci_lob_seek) switch(whence) { case PHP_OCI_SEEK_CUR: - descriptor->lob_current_position += offset; + descriptor->lob_current_position += (ub4) offset; break; case PHP_OCI_SEEK_END: if ((descriptor->lob_size + offset) >= 0) { - descriptor->lob_current_position = descriptor->lob_size + offset; + descriptor->lob_current_position = descriptor->lob_size + (ub4) offset; } else { descriptor->lob_current_position = 0; @@ -489,9 +489,14 @@ PHP_FUNCTION(oci_lob_seek) break; case PHP_OCI_SEEK_SET: default: - descriptor->lob_current_position = (offset > 0) ? offset : 0; + descriptor->lob_current_position = (offset > 0) ? (ub4) offset : 0; break; } + if ((descriptor->lob_current_position < 0) || + (descriptor->lob_current_position > UB4MAXVAL-1)) { + php_error_docref(NULL, E_WARNING, "Invalid offset or LOB position"); + RETURN_FALSE; + } RETURN_TRUE; } /* }}} */ @@ -530,7 +535,7 @@ PHP_FUNCTION(oci_lob_write) { zval *tmp, *z_descriptor = getThis(); php_oci_descriptor *descriptor; - size_t data_len; + zend_long data_len; zend_long write_len = 0; ub4 bytes_written; char *data; @@ -565,7 +570,7 @@ PHP_FUNCTION(oci_lob_write) RETURN_LONG(0); } - if (php_oci_lob_write(descriptor, descriptor->lob_current_position, data, data_len, &bytes_written)) { + if (php_oci_lob_write(descriptor, descriptor->lob_current_position, data, (ub4) data_len, &bytes_written)) { RETURN_FALSE; } RETURN_LONG(bytes_written); @@ -698,7 +703,7 @@ PHP_FUNCTION(oci_lob_erase) PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); - if (php_oci_lob_erase(descriptor, offset, length, &bytes_erased)) { + if (php_oci_lob_erase(descriptor, offset, (ub4) length, &bytes_erased)) { RETURN_FALSE; } RETURN_LONG(bytes_erased); @@ -1047,7 +1052,7 @@ PHP_FUNCTION(oci_lob_write_temporary) PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); - if (php_oci_lob_write_tmp(descriptor, type, data, data_len)) { + if (php_oci_lob_write_tmp(descriptor, type, data, (int) data_len)) { RETURN_FALSE; } RETURN_TRUE; @@ -1343,7 +1348,7 @@ PHP_FUNCTION(oci_execute) PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement); - if (php_oci_statement_execute(statement, mode)) { + if (php_oci_statement_execute(statement, (ub4) mode)) { RETURN_FALSE; } RETURN_TRUE; @@ -1585,7 +1590,10 @@ PHP_FUNCTION(oci_close) } PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - if (GC_REFCOUNT(connection->id) == 1) + if (GC_REFCOUNT(connection->id) == 2) /* CHANGED VERSION::PHP7 + Changed the refCount to 2 since + internally Zend engine increments + RefCount value by 1 */ zend_list_close(connection->id); /* ZVAL_NULL(z_connection); */ @@ -1723,7 +1731,7 @@ PHP_FUNCTION(oci_parse) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - statement = php_oci_statement_create(connection, query, query_len); + statement = php_oci_statement_create(connection, query, (int) query_len); if (statement) { RETURN_RES(statement->id); @@ -2002,7 +2010,7 @@ PHP_FUNCTION(oci_password_change) RETURN_FALSE; } - if (php_oci_password_change(connection, user, user_len, pass_old, pass_old_len, pass_new, pass_new_len)) { + if (php_oci_password_change(connection, user, (int) user_len, pass_old, (int) pass_old_len, pass_new, (int) pass_new_len)) { RETURN_FALSE; } RETURN_TRUE; @@ -2021,7 +2029,7 @@ PHP_FUNCTION(oci_password_change) RETURN_FALSE; } - connection = php_oci_do_connect_ex(user, user_len, pass_old, pass_old_len, pass_new, pass_new_len, dbname, dbname_len, NULL, OCI_DEFAULT, 0, 0); + connection = php_oci_do_connect_ex(user, (int) user_len, pass_old, (int) pass_old_len, pass_new, (int) pass_new_len, dbname, (int) dbname_len, NULL, OCI_DEFAULT, 0, 0); if (!connection) { RETURN_FALSE; } @@ -2233,7 +2241,7 @@ PHP_FUNCTION(oci_collection_append) PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); - if (php_oci_collection_append(collection, value, value_len)) { + if (php_oci_collection_append(collection, value, (int) value_len)) { RETURN_FALSE; } RETURN_TRUE; @@ -2341,7 +2349,7 @@ PHP_FUNCTION(oci_collection_element_assign) PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); - if (php_oci_collection_element_set(collection, element_index, value, value_len)) { + if (php_oci_collection_element_set(collection, element_index, value, (int) value_len)) { RETURN_FALSE; } RETURN_TRUE; @@ -2453,7 +2461,7 @@ PHP_FUNCTION(oci_new_collection) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - if ( (collection = php_oci_collection_create(connection, tdo, tdo_len, schema, schema_len)) ) { + if ( (collection = php_oci_collection_create(connection, tdo, (int) tdo_len, schema, (int) schema_len)) ) { object_init_ex(return_value, oci_coll_class_entry_ptr); add_property_resource(return_value, "collection", collection->id); } diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c index 7661a048db..4db99171ac 100644 --- a/ext/oci8/oci8_lob.c +++ b/ext/oci8/oci8_lob.c @@ -69,7 +69,7 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, zend_lon } descriptor = ecalloc(1, sizeof(php_oci_descriptor)); - descriptor->type = type; + descriptor->type = (ub4) type; descriptor->connection = connection; ++GC_REFCOUNT(descriptor->connection->id); @@ -216,7 +216,7 @@ static inline int php_oci_lob_calculate_buffer(php_oci_descriptor *descriptor, z sword errstatus; if (descriptor->type == OCI_DTYPE_FILE) { - return read_length; + return (int) read_length; } if (!descriptor->chunk_size) { @@ -225,16 +225,16 @@ static inline int php_oci_lob_calculate_buffer(php_oci_descriptor *descriptor, z if (errstatus != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, errstatus); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); - return read_length; /* we have to return original length here */ + return (int) read_length; /* we have to return original length here */ } descriptor->chunk_size = chunk_size; connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ } if ((read_length % descriptor->chunk_size) != 0) { - return descriptor->chunk_size * ((read_length / descriptor->chunk_size) + 1); + return (int) descriptor->chunk_size * (((int) read_length / descriptor->chunk_size) + 1); } - return read_length; + return (int) read_length; } /* }}} */ @@ -278,7 +278,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, zend_long read_length, zen requested_len = length; } - if (requested_len > (length - initial_offset)) { + if ((ub4) requested_len > (length - (ub4) initial_offset)) { requested_len = length - initial_offset; } @@ -324,7 +324,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, zend_long read_length, zen /* BLOBs don't have encoding, so bytes_per_char == 1 */ } - ctx.alloc_len = (requested_len + 1) * bytes_per_char; + ctx.alloc_len = ((ub4) requested_len + 1) * bytes_per_char; *data = ecalloc(bytes_per_char, requested_len + 1); if (is_clob) { @@ -335,7 +335,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, zend_long read_length, zen bytes_read = requested_len; } - buffer_size = (requested_len < buffer_size ) ? requested_len : buffer_size; /* optimize buffer size */ + buffer_size = ((int) requested_len < buffer_size ) ? (int) requested_len : buffer_size; /* optimize buffer size */ buffer_size = php_oci_lob_calculate_buffer(descriptor, buffer_size); /* use chunk size */ bufp = (ub1 *) ecalloc(1, buffer_size); @@ -450,7 +450,7 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i *bytes_written = data_len; descriptor->lob_current_position += data_len; - if (descriptor->lob_current_position > descriptor->lob_size) { + if ((int) descriptor->lob_current_position > (int) descriptor->lob_size) { descriptor->lob_size = descriptor->lob_current_position; } @@ -529,7 +529,7 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d if (length == -1) { copy_len = length_from - descriptor_from->lob_current_position; } else { - copy_len = length; + copy_len = (ub4) length; } if ((int)copy_len <= 0) { @@ -646,7 +646,7 @@ int php_oci_lob_flush(php_oci_descriptor *descriptor, zend_long flush_flag) return 0; } - PHP_OCI_CALL_RETURN(errstatus, OCILobFlushBuffer, (connection->svc, connection->err, lob, flush_flag)); + PHP_OCI_CALL_RETURN(errstatus, OCILobFlushBuffer, (connection->svc, connection->err, lob, (ub4) flush_flag)); if (errstatus != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, errstatus); @@ -830,7 +830,7 @@ int php_oci_lob_truncate (php_oci_descriptor *descriptor, zend_long new_lob_leng return 1; } - PHP_OCI_CALL_RETURN(errstatus, OCILobTrim, (connection->svc, connection->err, lob, new_lob_length)); + PHP_OCI_CALL_RETURN(errstatus, OCILobTrim, (connection->svc, connection->err, lob, (ub4) new_lob_length)); if (errstatus != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, errstatus); @@ -838,7 +838,7 @@ int php_oci_lob_truncate (php_oci_descriptor *descriptor, zend_long new_lob_leng return 1; } - descriptor->lob_size = new_lob_length; + descriptor->lob_size = (ub4) new_lob_length; connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; @@ -868,7 +868,7 @@ int php_oci_lob_erase (php_oci_descriptor *descriptor, zend_long offset, ub4 len length = lob_length; } - PHP_OCI_CALL_RETURN(errstatus, OCILobErase, (connection->svc, connection->err, lob, (ub4 *)&length, offset+1)); + PHP_OCI_CALL_RETURN(errstatus, OCILobErase, (connection->svc, connection->err, lob, (ub4 *)&length, (ub4) offset+1)); if (errstatus != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, errstatus); diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 32ce365ea4..9f251a19cb 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -997,8 +997,8 @@ int php_oci_bind_post_exec(zval *data) case SQLT_NUM: case SQLT_INT: case SQLT_LNG: - for (i = 0; i < bind->array.current_length; i++) { - if ((i < bind->array.old_length) && (entry = zend_hash_get_current_data(hash)) != NULL) { + for (i = 0; i < (int) bind->array.current_length; i++) { + if ((i < (int) bind->array.old_length) && (entry = zend_hash_get_current_data(hash)) != NULL) { zval_dtor(entry); ZVAL_LONG(entry, ((ub4 *)(bind->array.elements))[i]); zend_hash_move_forward(hash); @@ -1008,8 +1008,8 @@ int php_oci_bind_post_exec(zval *data) } break; case SQLT_FLT: - for (i = 0; i < bind->array.current_length; i++) { - if ((i < bind->array.old_length) && (entry = zend_hash_get_current_data(hash)) != NULL) { + for (i = 0; i < (int) bind->array.current_length; i++) { + if ((i < (int) bind->array.old_length) && (entry = zend_hash_get_current_data(hash)) != NULL) { zval_dtor(entry); ZVAL_DOUBLE(entry, ((double *)(bind->array.elements))[i]); zend_hash_move_forward(hash); @@ -1019,13 +1019,13 @@ int php_oci_bind_post_exec(zval *data) } break; case SQLT_ODT: - for (i = 0; i < bind->array.current_length; i++) { + for (i = 0; i < (int) bind->array.current_length; i++) { oratext buff[1024]; ub4 buff_len = 1024; memset((void*)buff,0,sizeof(buff)); - if ((i < bind->array.old_length) && (entry = zend_hash_get_current_data(hash)) != NULL) { + if ((i < (int) bind->array.old_length) && (entry = zend_hash_get_current_data(hash)) != NULL) { PHP_OCI_CALL_RETURN(errstatus, OCIDateToText, (connection->err, &(((OCIDate *)(bind->array.elements))[i]), 0, 0, 0, 0, &buff_len, buff)); zval_dtor(entry); @@ -1058,10 +1058,10 @@ int php_oci_bind_post_exec(zval *data) case SQLT_AVC: case SQLT_STR: case SQLT_LVC: - for (i = 0; i < bind->array.current_length; i++) { + for (i = 0; i < (int) bind->array.current_length; i++) { /* int curr_element_length = strlen(((text *)bind->array.elements)+i*bind->array.max_length); */ int curr_element_length = bind->array.element_lengths[i]; - if ((i < bind->array.old_length) && (entry = zend_hash_get_current_data(hash)) != NULL) { + if ((i < (int) bind->array.old_length) && (entry = zend_hash_get_current_data(hash)) != NULL) { zval_dtor(entry); ZVAL_STRINGL(entry, (char *)(((text *)bind->array.elements)+i*bind->array.max_length), curr_element_length); zend_hash_move_forward(hash); @@ -1084,7 +1084,7 @@ int php_oci_bind_post_exec(zval *data) /* {{{ php_oci_bind_by_name() Bind zval to the given placeholder */ -int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, zval *var, zend_long maxlength, ub2 type) +int php_oci_bind_by_name(php_oci_statement *statement, char *name, size_t name_len, zval *var, zend_long maxlength, ub2 type) { php_oci_collection *bind_collection = NULL; php_oci_descriptor *bind_descriptor = NULL; @@ -1176,7 +1176,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, if (maxlength == 0) { value_sz = PHP_OCI_PIECE_SIZE; } else { - value_sz = maxlength; + value_sz = (sb4) maxlength; } } break; @@ -1257,7 +1257,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, (OCIBind **)&bindp->bind, /* bind hdl (will alloc) */ statement->err, /* error handle */ (text*) name, /* placeholder name */ - name_len, /* placeholder length */ + (sb4) name_len, /* placeholder length */ (dvoid *)bind_data, /* in/out data */ value_sz, /* PHP_OCI_MAX_DATA_SIZE, */ /* max size of input/output data */ type, /* in/out data type */ @@ -1352,7 +1352,7 @@ sb4 php_oci_bind_in_callback( convert_to_string(val); *bufpp = Z_STRVAL_P(val); - *alenp = Z_STRLEN_P(val); + *alenp = (ub4) Z_STRLEN_P(val); *indpp = (dvoid *)&phpbind->indicator; } else if (phpbind->statement != 0) { /* RSET */ @@ -1552,7 +1552,7 @@ int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows) /* {{{ php_oci_bind_array_by_name() Bind arrays to PL/SQL types */ -int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int name_len, zval *var, zend_long max_table_length, zend_long maxlength, zend_long type) +int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, size_t name_len, zval *var, zend_long max_table_length, zend_long maxlength, zend_long type) { php_oci_bind *bind, *bindp; sword errstatus; @@ -1618,7 +1618,7 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam (OCIBind **)&bind->bind, statement->err, (text *)name, - name_len, + (sb4) name_len, (dvoid *) bind->array.elements, (sb4) bind->array.max_length, (ub2)type, @@ -1682,7 +1682,7 @@ php_oci_bind *php_oci_bind_array_helper_string(zval *var, zend_long max_table_le while ((entry = zend_hash_get_current_data(hash)) != NULL) { convert_to_string_ex(entry); - if (maxlength == -1 || Z_STRLEN_P(entry) > maxlength) { + if (maxlength == -1 || Z_STRLEN_P(entry) > (size_t) maxlength) { maxlength = Z_STRLEN_P(entry) + 1; } @@ -1695,7 +1695,7 @@ php_oci_bind *php_oci_bind_array_helper_string(zval *var, zend_long max_table_le memset(bind->array.elements, 0, max_table_length * (maxlength + 1) * sizeof(text)); bind->array.current_length = zend_hash_num_elements(Z_ARRVAL_P(var)); bind->array.old_length = bind->array.current_length; - bind->array.max_length = maxlength; + bind->array.max_length = (ub4) maxlength; bind->array.element_lengths = safe_emalloc(max_table_length, sizeof(ub2), 0); memset(bind->array.element_lengths, 0, max_table_length*sizeof(ub2)); bind->array.indicators = safe_emalloc(max_table_length, sizeof(sb2), 0); @@ -1706,7 +1706,7 @@ php_oci_bind *php_oci_bind_array_helper_string(zval *var, zend_long max_table_le for (i = 0; i < bind->array.current_length; i++) { if ((entry = zend_hash_get_current_data(hash)) != NULL) { convert_to_string_ex(entry); - bind->array.element_lengths[i] = Z_STRLEN_P(entry); + bind->array.element_lengths[i] = (ub2) Z_STRLEN_P(entry); if (Z_STRLEN_P(entry) == 0) { bind->array.indicators[i] = -1; } @@ -1722,7 +1722,7 @@ php_oci_bind *php_oci_bind_array_helper_string(zval *var, zend_long max_table_le int element_length; convert_to_string_ex(entry); - element_length = (maxlength > Z_STRLEN_P(entry)) ? Z_STRLEN_P(entry) : maxlength; + element_length = ((size_t) maxlength > Z_STRLEN_P(entry)) ? (int) Z_STRLEN_P(entry) : (int) maxlength; memcpy((text *)bind->array.elements + i*maxlength, Z_STRVAL_P(entry), element_length); ((text *)bind->array.elements)[i*maxlength + element_length] = '\0'; @@ -1846,7 +1846,7 @@ php_oci_bind *php_oci_bind_array_helper_date(zval *var, zend_long max_table_leng if ((i < bind->array.current_length) && (entry = zend_hash_get_current_data(hash)) != NULL) { convert_to_string_ex(entry); - PHP_OCI_CALL_RETURN(errstatus, OCIDateFromText, (connection->err, (CONST text *)Z_STRVAL_P(entry), Z_STRLEN_P(entry), NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(errstatus, OCIDateFromText, (connection->err, (CONST text *)Z_STRVAL_P(entry), (ub4) Z_STRLEN_P(entry), NULL, 0, NULL, 0, &oci_date)); if (errstatus != OCI_SUCCESS) { /* failed to convert string to date */ diff --git a/ext/oci8/php_oci8_int.h b/ext/oci8/php_oci8_int.h index d113775bdc..5994d0be48 100644 --- a/ext/oci8/php_oci8_int.h +++ b/ext/oci8/php_oci8_int.h @@ -176,7 +176,7 @@ typedef struct { php_oci_connection *connection; /* parent connection handle */ dvoid *descriptor; /* OCI descriptor handle */ ub4 type; /* descriptor type (FILE/LOB) */ - int lob_current_position; /* LOB internal pointer */ + ub4 lob_current_position; /* LOB internal pointer */ int lob_size; /* cached LOB size. -1 = Lob wasn't initialized yet */ int buffering; /* cached buffering flag. 0 - off, 1 - on, 2 - on and buffer was used */ ub4 chunk_size; /* chunk size of the LOB. 0 - unknown */ @@ -492,14 +492,14 @@ int php_oci_statement_cancel(php_oci_statement *statement); void php_oci_statement_free(php_oci_statement *statement); int php_oci_bind_pre_exec(zval *data, void *result); int php_oci_bind_post_exec(zval *data); -int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, zval *var, zend_long maxlength, ub2 type); +int php_oci_bind_by_name(php_oci_statement *statement, char *name, size_t name_len, zval *var, zend_long maxlength, ub2 type); sb4 php_oci_bind_in_callback(dvoid *ictxp, OCIBind *bindp, ub4 iter, ub4 index, dvoid **bufpp, ub4 *alenp, ub1 *piecep, dvoid **indpp); sb4 php_oci_bind_out_callback(dvoid *octxp, OCIBind *bindp, ub4 iter, ub4 index, dvoid **bufpp, ub4 **alenpp, ub1 *piecep, dvoid **indpp, ub2 **rcodepp); php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAMETERS, int need_data); int php_oci_cleanup_pre_fetch(zval *data); int php_oci_statement_get_type(php_oci_statement *statement, ub2 *type); int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows); -int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int name_len, zval *var, zend_long max_table_length, zend_long maxlength, zend_long type); +int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, size_t name_len, zval *var, zend_long max_table_length, zend_long maxlength, zend_long type); php_oci_bind *php_oci_bind_array_helper_number(zval *var, zend_long max_table_length); php_oci_bind *php_oci_bind_array_helper_double(zval *var, zend_long max_table_length); php_oci_bind *php_oci_bind_array_helper_string(zval *var, zend_long max_table_length, zend_long maxlength); @@ -552,4 +552,6 @@ ZEND_EXTERN_MODULE_GLOBALS(oci) * tab-width: 4 * c-basic-offset: 4 * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 */ diff --git a/ext/oci8/tests/coll_002.phpt b/ext/oci8/tests/coll_002.phpt index cd068ff0b2..6633380c27 100644 --- a/ext/oci8/tests/coll_002.phpt +++ b/ext/oci8/tests/coll_002.phpt @@ -28,6 +28,6 @@ object(OCI-Collection)#%d (1) { } bool(true) -Warning: OCI-Collection::size(): %d is not a valid oci8 collection resource in %s on line %d +Warning: OCI-Collection::size(): supplied resource is not a valid oci8 collection resource in %s on line %d bool(false) Done diff --git a/ext/oci8/tests/coll_002_func.phpt b/ext/oci8/tests/coll_002_func.phpt index 9d8e4cf976..d309de249c 100644 --- a/ext/oci8/tests/coll_002_func.phpt +++ b/ext/oci8/tests/coll_002_func.phpt @@ -28,6 +28,6 @@ object(OCI-Collection)#%d (1) { } bool(true) -Warning: oci_collection_size(): %d is not a valid oci8 collection resource in %s on line %d +Warning: oci_collection_size(): supplied resource is not a valid oci8 collection resource in %s on line %d bool(false) Done diff --git a/ext/oci8/tests/coll_006.phpt b/ext/oci8/tests/coll_006.phpt index 4799eb6b79..f9e06d4fab 100644 --- a/ext/oci8/tests/coll_006.phpt +++ b/ext/oci8/tests/coll_006.phpt @@ -28,6 +28,6 @@ object(OCI-Collection)#%d (1) { } bool(true) -Warning: OCI-Collection::size(): %d is not a valid oci8 collection resource in %s on line %d +Warning: OCI-Collection::size(): supplied resource is not a valid oci8 collection resource in %s on line %d bool(false) Done diff --git a/ext/oci8/tests/coll_006_func.phpt b/ext/oci8/tests/coll_006_func.phpt index 3d65606148..87cbd7498c 100644 --- a/ext/oci8/tests/coll_006_func.phpt +++ b/ext/oci8/tests/coll_006_func.phpt @@ -28,6 +28,6 @@ object(OCI-Collection)#%d (1) { } bool(true) -Warning: oci_collection_size(): %d is not a valid oci8 collection resource in %s on line %d +Warning: oci_collection_size(): supplied resource is not a valid oci8 collection resource in %s on line %d bool(false) Done diff --git a/ext/oci8/tests/define4.phpt b/ext/oci8/tests/define4.phpt index 3114a73937..6aae1d99b2 100644 --- a/ext/oci8/tests/define4.phpt +++ b/ext/oci8/tests/define4.phpt @@ -68,7 +68,7 @@ Test 3 bool(true) string(4) "some" -Warning: oci_result(): %d is not a valid oci8 statement resource in %s on line %d +Warning: oci_result(): supplied resource is not a valid oci8 statement resource in %s on line %d bool(false) Done diff --git a/ext/oci8/tests/imp_res_get_close_1.phpt b/ext/oci8/tests/imp_res_get_close_1.phpt index 2edc8bf604..0e3b3b0c13 100644 --- a/ext/oci8/tests/imp_res_get_close_1.phpt +++ b/ext/oci8/tests/imp_res_get_close_1.phpt @@ -58,11 +58,11 @@ oci_free_statement($s); Test 1 1 -Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %s on line %d +Warning: oci_fetch_array(): supplied resource is not a valid oci8 statement resource in %s on line %d 3 -Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %s on line %d +Warning: oci_fetch_array(): supplied resource is not a valid oci8 statement resource in %s on line %d 5 -Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %s on line %d +Warning: oci_fetch_array(): supplied resource is not a valid oci8 statement resource in %s on line %d ===DONE=== diff --git a/ext/oci8/tests/lob_014.phpt b/ext/oci8/tests/lob_014.phpt index 2a1a6bed64..e319178683 100644 --- a/ext/oci8/tests/lob_014.phpt +++ b/ext/oci8/tests/lob_014.phpt @@ -50,7 +50,7 @@ bool(true) int(4) bool(true) -Warning: OCI-Lob::write(): %d is not a valid oci8 descriptor resource in %slob_014.php on line %d +Warning: OCI-Lob::write(): %s is not a valid oci8 descriptor resource in %slob_014.php on line %d bool(false) array(1) { [0]=> diff --git a/ext/oci8/tests/lob_021.phpt b/ext/oci8/tests/lob_021.phpt index b7489271b9..16b389dd05 100644 --- a/ext/oci8/tests/lob_021.phpt +++ b/ext/oci8/tests/lob_021.phpt @@ -55,10 +55,10 @@ bool(true) int(4) bool(true) -Warning: OCI-Lob::write(): %d is not a valid oci8 descriptor resource in %s on line %d +Warning: OCI-Lob::write(): %s is not a valid oci8 descriptor resource in %s on line %d bool(false) -Warning: oci_free_descriptor(): %d is not a valid oci8 descriptor resource in %s on line %d +Warning: oci_free_descriptor(): %s is not a valid oci8 descriptor resource in %s on line %d bool(false) Warning: oci_free_descriptor() expects parameter 1 to be OCI-Lob, object given in %s on line %d diff --git a/ext/oci8/tests/lob_041.phpt b/ext/oci8/tests/lob_041.phpt index aa1ea98a52..c5c0a209f3 100644 --- a/ext/oci8/tests/lob_041.phpt +++ b/ext/oci8/tests/lob_041.phpt @@ -72,7 +72,7 @@ Test 2 - implicit statement close test data object(OCI-Lob)#%d (1) { ["descriptor"]=> - resource(%d) of type (oci8 descriptor) + resource(%d) of type (Unknown) } Test 3 - no preallocated descriptor diff --git a/ext/oci8/tests/old_oci_close1.phpt b/ext/oci8/tests/old_oci_close1.phpt index 9af2eeb398..02b68f45c7 100644 --- a/ext/oci8/tests/old_oci_close1.phpt +++ b/ext/oci8/tests/old_oci_close1.phpt @@ -20,6 +20,6 @@ echo "Done\n"; resource(%d) of type (oci8 connection) bool(true) -Warning: oci_parse() expects parameter 1 to be resource, null given in %s on line %d -NULL +Warning: oci_parse(): supplied resource is not a valid oci8 connection resource in %sold_oci_close1.php on line %d +bool(false) Done -- 2.40.0