From 8155e1bfaf49fd7841bd51526a2dd3e0f6747a0d Mon Sep 17 00:00:00 2001 From: Pierrick Charron Date: Sun, 12 Jun 2022 13:21:37 -0400 Subject: [PATCH 1/5] Declare OCILob descriptor property --- ext/oci8/oci8.stub.php | 3 + ext/oci8/oci8_arginfo.h | 8 ++- ext/oci8/oci8_interface.c | 139 ++++++++------------------------------ ext/oci8/oci8_statement.c | 9 ++- 4 files changed, 42 insertions(+), 117 deletions(-) diff --git a/ext/oci8/oci8.stub.php b/ext/oci8/oci8.stub.php index 8fc39bd378d53..2973905cc10b8 100644 --- a/ext/oci8/oci8.stub.php +++ b/ext/oci8/oci8.stub.php @@ -953,6 +953,9 @@ function oci_unregister_taf_callback($connection): bool {} #[\AllowDynamicProperties] class OCILob { + /** @var resource */ + public readonly $descriptor; + /** * @alias oci_lob_save * @tentative-return-type diff --git a/ext/oci8/oci8_arginfo.h b/ext/oci8/oci8_arginfo.h index a6869afd2e64b..2acd4cd89d23f 100644 --- a/ext/oci8/oci8_arginfo.h +++ b/ext/oci8/oci8_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 850d4e63296c95a27cdfc1244d63b1ed496acd54 */ + * Stub hash: 68f8a530fcec3301925056d167a95ecca365296f */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement) @@ -901,6 +901,12 @@ static zend_class_entry *register_class_OCILob(void) class_entry = zend_register_internal_class_ex(&ce, NULL); class_entry->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES; + zval property_descriptor_default_value; + ZVAL_NULL(&property_descriptor_default_value); + zend_string *property_descriptor_name = zend_string_init("descriptor", sizeof("descriptor") - 1, 1); + zend_declare_property_ex(class_entry, property_descriptor_name, &property_descriptor_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL); + zend_string_release(property_descriptor_name); + zend_string *attribute_name_AllowDynamicProperties_class_OCILob = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1); zend_add_class_attribute(class_entry, attribute_name_AllowDynamicProperties_class_OCILob, 0); zend_string_release(attribute_name_AllowDynamicProperties_class_OCILob); diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c index 2b1117dd6515f..485c72a4caf8a 100644 --- a/ext/oci8/oci8_interface.c +++ b/ext/oci8/oci8_interface.c @@ -40,6 +40,8 @@ #define OCI_STMT_CALL 10 #endif +#define Z_OCILOB_DESCRIPTOR_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 0) + #define ERROR_ARG_POS(arg_num) (getThis() ? (arg_num-1) : (arg_num)) /* {{{ Register a callback function for Oracle Transparent Application Failover (TAF) */ @@ -233,10 +235,7 @@ PHP_FUNCTION(oci_free_descriptor) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -264,10 +263,7 @@ PHP_FUNCTION(oci_lob_save) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -290,10 +286,7 @@ PHP_FUNCTION(oci_lob_import) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -316,10 +309,7 @@ PHP_FUNCTION(oci_lob_load) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -356,10 +346,7 @@ PHP_FUNCTION(oci_lob_read) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -388,10 +375,7 @@ PHP_FUNCTION(oci_lob_eof) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -414,11 +398,7 @@ PHP_FUNCTION(oci_lob_tell) RETURN_THROWS(); } - 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; - } - + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); RETURN_LONG(descriptor->lob_current_position); @@ -435,10 +415,7 @@ PHP_FUNCTION(oci_lob_rewind) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -460,10 +437,7 @@ PHP_FUNCTION(oci_lob_seek) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -507,10 +481,7 @@ PHP_FUNCTION(oci_lob_size) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -540,11 +511,7 @@ PHP_FUNCTION(oci_lob_write) data_len = MIN((zend_long) data_len, write_len); } - 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; - } - + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (data_len <= 0) { @@ -568,15 +535,8 @@ PHP_FUNCTION(oci_lob_append) RETURN_THROWS(); } - if ((tmp_dest = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_dest), "descriptor", sizeof("descriptor")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object"); - RETURN_FALSE; - } - - if ((tmp_from = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_from), "descriptor", sizeof("descriptor")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object"); - RETURN_FALSE; - } + tmp_dest = Z_OCILOB_DESCRIPTOR_P(z_descriptor_dest); + tmp_from = Z_OCILOB_DESCRIPTOR_P(z_descriptor_from); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_dest, descriptor_dest); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_from, descriptor_from); @@ -606,10 +566,7 @@ PHP_FUNCTION(oci_lob_truncate) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); ub_trim_length = (ub4) trim_length; PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -648,11 +605,7 @@ PHP_FUNCTION(oci_lob_erase) RETURN_THROWS(); } - 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; - } - + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (php_oci_lob_erase(descriptor, offset, (ub4) length, &bytes_erased)) { @@ -673,11 +626,7 @@ PHP_FUNCTION(oci_lob_flush) RETURN_THROWS(); } - 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; - } - + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (descriptor->buffering == PHP_OCI_LOB_BUFFER_DISABLED) { @@ -703,11 +652,7 @@ PHP_FUNCTION(ocisetbufferinglob) RETURN_THROWS(); } - 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; - } - + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (php_oci_lob_set_buffering(descriptor, flag)) { @@ -727,11 +672,7 @@ PHP_FUNCTION(ocigetbufferinglob) RETURN_THROWS(); } - 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; - } - + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (descriptor->buffering != PHP_OCI_LOB_BUFFER_DISABLED) { @@ -760,15 +701,8 @@ PHP_FUNCTION(oci_lob_copy) RETURN_THROWS(); } - if ((tmp_dest = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_dest), "descriptor", sizeof("descriptor")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object"); - RETURN_FALSE; - } - - if ((tmp_from = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_from), "descriptor", sizeof("descriptor")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object"); - RETURN_FALSE; - } + tmp_dest = Z_OCILOB_DESCRIPTOR_P(z_descriptor_dest); + tmp_from = Z_OCILOB_DESCRIPTOR_P(z_descriptor_from); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_dest, descriptor_dest); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_from, descriptor_from); @@ -791,15 +725,8 @@ PHP_FUNCTION(oci_lob_is_equal) RETURN_THROWS(); } - if ((tmp_first = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_first), "descriptor", sizeof("descriptor")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object"); - RETURN_FALSE; - } - - if ((tmp_second = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_second), "descriptor", sizeof("descriptor")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object"); - RETURN_FALSE; - } + tmp_first = Z_OCILOB_DESCRIPTOR_P(z_descriptor_first); + tmp_second = Z_OCILOB_DESCRIPTOR_P(z_descriptor_second); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_first, descriptor_first); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_second, descriptor_second); @@ -846,10 +773,7 @@ PHP_FUNCTION(oci_lob_export) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -928,10 +852,7 @@ PHP_METHOD(OCILob, writeTemporary) RETURN_THROWS(); } - 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; - } + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -952,11 +873,7 @@ PHP_METHOD(OCILob, close) RETURN_THROWS(); } - 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; - } - + tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (php_oci_lob_close(descriptor)) { @@ -988,7 +905,7 @@ PHP_FUNCTION(oci_new_descriptor) } object_init_ex(return_value, oci_lob_class_entry_ptr); - add_property_resource(return_value, "descriptor", descriptor->id); + ZVAL_RES(Z_OCILOB_DESCRIPTOR_P(return_value), descriptor->id); } /* }}} */ diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 91bba23127b12..e181c2ec2862d 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -42,6 +42,8 @@ typedef ub8 oci_phpsized_int; typedef ub4 oci_phpsized_int; #endif +#define Z_OCILOB_DESCRIPTOR_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 0) + /* {{{ php_oci_statement_create() Create statemend handle and allocate necessary resources */ php_oci_statement *php_oci_statement_create(php_oci_connection *connection, char *query, int query_len) @@ -1161,7 +1163,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, size_t name_l { zval *tmp; - if (Z_TYPE_P(param) != IS_OBJECT || (tmp = zend_hash_str_find(Z_OBJPROP_P(param), "descriptor", sizeof("descriptor")-1)) == NULL) { + if (Z_TYPE_P(param) != IS_OBJECT || !(tmp = Z_OCILOB_DESCRIPTOR_P(param))) { php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); return 1; } @@ -1480,10 +1482,7 @@ sb4 php_oci_bind_out_callback( * out-bind as the contents would have been changed for in/out * binds (Bug #46994). */ - if ((tmp = zend_hash_str_find(Z_OBJPROP_P(val), "descriptor", sizeof("descriptor")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find object outbind descriptor property"); - return OCI_ERROR; - } + tmp = Z_OCILOB_DESCRIPTOR_P(val); PHP_OCI_ZVAL_TO_DESCRIPTOR_EX(tmp, desc); desc->lob_size = -1; /* force OCI8 to update cached size */ From d509a704a23e126f4776aa1c8fa113915424c50b Mon Sep 17 00:00:00 2001 From: Pierrick Charron Date: Sun, 12 Jun 2022 13:25:24 -0400 Subject: [PATCH 2/5] Declare OCICollection collection property --- ext/oci8/oci8.stub.php | 2 ++ ext/oci8/oci8_arginfo.h | 8 +++++- ext/oci8/oci8_interface.c | 57 ++++++++------------------------------- ext/oci8/oci8_statement.c | 3 ++- 4 files changed, 22 insertions(+), 48 deletions(-) diff --git a/ext/oci8/oci8.stub.php b/ext/oci8/oci8.stub.php index 2973905cc10b8..aa585b51faeca 100644 --- a/ext/oci8/oci8.stub.php +++ b/ext/oci8/oci8.stub.php @@ -1085,6 +1085,8 @@ public function free(): bool {} #[\AllowDynamicProperties] class OCICollection { + /** @var resource */ + public readonly $collection; /** * @alias oci_free_collection * @tentative-return-type diff --git a/ext/oci8/oci8_arginfo.h b/ext/oci8/oci8_arginfo.h index 2acd4cd89d23f..8b03ba302b844 100644 --- a/ext/oci8/oci8_arginfo.h +++ b/ext/oci8/oci8_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 68f8a530fcec3301925056d167a95ecca365296f */ + * Stub hash: d8e9f7e55dce2c77242476e323d7795a97b5c862 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement) @@ -922,6 +922,12 @@ static zend_class_entry *register_class_OCICollection(void) class_entry = zend_register_internal_class_ex(&ce, NULL); class_entry->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES; + zval property_collection_default_value; + ZVAL_NULL(&property_collection_default_value); + zend_string *property_collection_name = zend_string_init("collection", sizeof("collection") - 1, 1); + zend_declare_property_ex(class_entry, property_collection_name, &property_collection_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL); + zend_string_release(property_collection_name); + zend_string *attribute_name_AllowDynamicProperties_class_OCICollection = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1); zend_add_class_attribute(class_entry, attribute_name_AllowDynamicProperties_class_OCICollection, 0); zend_string_release(attribute_name_AllowDynamicProperties_class_OCICollection); diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c index 485c72a4caf8a..90e770161198d 100644 --- a/ext/oci8/oci8_interface.c +++ b/ext/oci8/oci8_interface.c @@ -41,6 +41,7 @@ #endif #define Z_OCILOB_DESCRIPTOR_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 0) +#define Z_OCICOLLECTION_COLLECTION_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 0) #define ERROR_ARG_POS(arg_num) (getThis() ? (arg_num-1) : (arg_num)) @@ -2014,11 +2015,7 @@ PHP_FUNCTION(oci_free_collection) RETURN_THROWS(); } - if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find collection property"); - RETURN_FALSE; - } - + tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); zend_list_close(collection->id); @@ -2038,11 +2035,7 @@ PHP_FUNCTION(oci_collection_append) RETURN_THROWS(); } - if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find collection property"); - RETURN_FALSE; - } - + tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_append(collection, value, (int) value_len)) { @@ -2063,11 +2056,7 @@ PHP_FUNCTION(oci_collection_element_get) RETURN_THROWS(); } - if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find collection property"); - RETURN_FALSE; - } - + tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_element_get(collection, element_index, return_value)) { @@ -2086,16 +2075,8 @@ PHP_FUNCTION(oci_collection_assign) RETURN_THROWS(); } - if ((tmp_dest = zend_hash_str_find(Z_OBJPROP_P(z_collection_dest), "collection", sizeof("collection")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find collection property. The first argument should be valid collection object"); - RETURN_FALSE; - } - - if ((tmp_from = zend_hash_str_find(Z_OBJPROP_P(z_collection_from), "collection", sizeof("collection")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find collection property. The second argument should be valid collection object"); - RETURN_FALSE; - } - + tmp_dest = Z_OCICOLLECTION_COLLECTION_P(z_collection_dest); + tmp_from = Z_OCICOLLECTION_COLLECTION_P(z_collection_from); PHP_OCI_ZVAL_TO_COLLECTION(tmp_dest, collection_dest); PHP_OCI_ZVAL_TO_COLLECTION(tmp_from, collection_from); @@ -2119,11 +2100,7 @@ PHP_FUNCTION(oci_collection_element_assign) RETURN_THROWS(); } - if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find collection property"); - RETURN_FALSE; - } - + tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_element_set(collection, element_index, value, (int) value_len)) { @@ -2144,11 +2121,7 @@ PHP_FUNCTION(oci_collection_size) RETURN_THROWS(); } - if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find collection property"); - RETURN_FALSE; - } - + tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_size(collection, &size)) { @@ -2169,11 +2142,7 @@ PHP_FUNCTION(oci_collection_max) RETURN_THROWS(); } - if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find collection property"); - RETURN_FALSE; - } - + tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_max(collection, &max)) { @@ -2194,11 +2163,7 @@ PHP_FUNCTION(oci_collection_trim) RETURN_THROWS(); } - if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find collection property"); - RETURN_FALSE; - } - + tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_trim(collection, trim_size)) { @@ -2225,7 +2190,7 @@ PHP_FUNCTION(oci_new_collection) 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); + ZVAL_RES(Z_OCICOLLECTION_COLLECTION_P(return_value), collection->id); } else { RETURN_FALSE; diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index e181c2ec2862d..fef019b97fd64 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -43,6 +43,7 @@ typedef ub4 oci_phpsized_int; #endif #define Z_OCILOB_DESCRIPTOR_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 0) +#define Z_OCICOLLECTION_COLLECTION_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 0) /* {{{ php_oci_statement_create() Create statemend handle and allocate necessary resources */ @@ -1141,7 +1142,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, size_t name_l { zval *tmp; - if (Z_TYPE_P(param) != IS_OBJECT || (tmp = zend_hash_str_find(Z_OBJPROP_P(param), "collection", sizeof("collection")-1)) == NULL) { + if (Z_TYPE_P(param) != IS_OBJECT || !(tmp = Z_OCICOLLECTION_COLLECTION_P(param))) { php_error_docref(NULL, E_WARNING, "Unable to find collection property"); return 1; } From cf4c3155b52f57428c9b0db8e0fe414546a9fc4a Mon Sep 17 00:00:00 2001 From: Pierrick Charron Date: Wed, 25 Jan 2023 20:12:40 -0500 Subject: [PATCH 3/5] Add type declaration in stub --- ext/oci8/oci8.stub.php | 4 ++-- ext/oci8/oci8_arginfo.h | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ext/oci8/oci8.stub.php b/ext/oci8/oci8.stub.php index aa585b51faeca..52e96a5b93e7c 100644 --- a/ext/oci8/oci8.stub.php +++ b/ext/oci8/oci8.stub.php @@ -954,7 +954,7 @@ function oci_unregister_taf_callback($connection): bool {} #[\AllowDynamicProperties] class OCILob { /** @var resource */ - public readonly $descriptor; + public readonly mixed $descriptor; /** * @alias oci_lob_save @@ -1086,7 +1086,7 @@ public function free(): bool {} #[\AllowDynamicProperties] class OCICollection { /** @var resource */ - public readonly $collection; + public readonly mixed $collection; /** * @alias oci_free_collection * @tentative-return-type diff --git a/ext/oci8/oci8_arginfo.h b/ext/oci8/oci8_arginfo.h index 8b03ba302b844..8ea2af5ef930c 100644 --- a/ext/oci8/oci8_arginfo.h +++ b/ext/oci8/oci8_arginfo.h @@ -1,5 +1,9 @@ /* This is a generated file, edit the .stub.php file instead. +<<<<<<< HEAD * Stub hash: d8e9f7e55dce2c77242476e323d7795a97b5c862 */ +======= + * Stub hash: e3c87c2100a1d480faad06b0149c67209fda7ed1 */ +>>>>>>> f5856f4d80 (Add type declaration in stub) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement) @@ -902,9 +906,9 @@ static zend_class_entry *register_class_OCILob(void) class_entry->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES; zval property_descriptor_default_value; - ZVAL_NULL(&property_descriptor_default_value); + ZVAL_UNDEF(&property_descriptor_default_value); zend_string *property_descriptor_name = zend_string_init("descriptor", sizeof("descriptor") - 1, 1); - zend_declare_property_ex(class_entry, property_descriptor_name, &property_descriptor_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL); + zend_declare_typed_property(class_entry, property_descriptor_name, &property_descriptor_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); zend_string_release(property_descriptor_name); zend_string *attribute_name_AllowDynamicProperties_class_OCILob = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1); @@ -923,9 +927,9 @@ static zend_class_entry *register_class_OCICollection(void) class_entry->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES; zval property_collection_default_value; - ZVAL_NULL(&property_collection_default_value); + ZVAL_UNDEF(&property_collection_default_value); zend_string *property_collection_name = zend_string_init("collection", sizeof("collection") - 1, 1); - zend_declare_property_ex(class_entry, property_collection_name, &property_collection_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL); + zend_declare_typed_property(class_entry, property_collection_name, &property_collection_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); zend_string_release(property_collection_name); zend_string *attribute_name_AllowDynamicProperties_class_OCICollection = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1); From 2c56ef462754de95d0146465a68c971d0c5c34a4 Mon Sep 17 00:00:00 2001 From: Pierrick Charron Date: Wed, 25 Jan 2023 20:22:10 -0500 Subject: [PATCH 4/5] Remove #[\AllowDynamicProperties] --- ext/oci8/oci8.stub.php | 2 -- ext/oci8/oci8_arginfo.h | 16 +--------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/ext/oci8/oci8.stub.php b/ext/oci8/oci8.stub.php index 52e96a5b93e7c..6dd0d07045cef 100644 --- a/ext/oci8/oci8.stub.php +++ b/ext/oci8/oci8.stub.php @@ -951,7 +951,6 @@ function oci_register_taf_callback($connection, ?callable $callback): bool {} /** @param resource $connection */ function oci_unregister_taf_callback($connection): bool {} -#[\AllowDynamicProperties] class OCILob { /** @var resource */ public readonly mixed $descriptor; @@ -1083,7 +1082,6 @@ public function close(): bool {} public function free(): bool {} } -#[\AllowDynamicProperties] class OCICollection { /** @var resource */ public readonly mixed $collection; diff --git a/ext/oci8/oci8_arginfo.h b/ext/oci8/oci8_arginfo.h index 8ea2af5ef930c..4e8304b8673d6 100644 --- a/ext/oci8/oci8_arginfo.h +++ b/ext/oci8/oci8_arginfo.h @@ -1,9 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. -<<<<<<< HEAD - * Stub hash: d8e9f7e55dce2c77242476e323d7795a97b5c862 */ -======= - * Stub hash: e3c87c2100a1d480faad06b0149c67209fda7ed1 */ ->>>>>>> f5856f4d80 (Add type declaration in stub) + * Stub hash: 66436b4202234c49e23f476f32ce178e756795a3 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement) @@ -903,7 +899,6 @@ static zend_class_entry *register_class_OCILob(void) INIT_CLASS_ENTRY(ce, "OCILob", class_OCILob_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); - class_entry->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES; zval property_descriptor_default_value; ZVAL_UNDEF(&property_descriptor_default_value); @@ -911,10 +906,6 @@ static zend_class_entry *register_class_OCILob(void) zend_declare_typed_property(class_entry, property_descriptor_name, &property_descriptor_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); zend_string_release(property_descriptor_name); - zend_string *attribute_name_AllowDynamicProperties_class_OCILob = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1); - zend_add_class_attribute(class_entry, attribute_name_AllowDynamicProperties_class_OCILob, 0); - zend_string_release(attribute_name_AllowDynamicProperties_class_OCILob); - return class_entry; } @@ -924,7 +915,6 @@ static zend_class_entry *register_class_OCICollection(void) INIT_CLASS_ENTRY(ce, "OCICollection", class_OCICollection_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); - class_entry->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES; zval property_collection_default_value; ZVAL_UNDEF(&property_collection_default_value); @@ -932,9 +922,5 @@ static zend_class_entry *register_class_OCICollection(void) zend_declare_typed_property(class_entry, property_collection_name, &property_collection_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); zend_string_release(property_collection_name); - zend_string *attribute_name_AllowDynamicProperties_class_OCICollection = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1); - zend_add_class_attribute(class_entry, attribute_name_AllowDynamicProperties_class_OCICollection, 0); - zend_string_release(attribute_name_AllowDynamicProperties_class_OCICollection); - return class_entry; } From 1069dd66ae1cc3bf6c3804564896e6f57a3cd1d4 Mon Sep 17 00:00:00 2001 From: Pierrick Charron Date: Sun, 19 Feb 2023 16:23:02 -0500 Subject: [PATCH 5/5] Reuse old errors to ensure that tests are still working Next step will be to refactor the code to change those error messages and also maybe to remove the useless temp variables. --- ext/oci8/oci8.stub.php | 4 +- ext/oci8/oci8_arginfo.h | 10 +-- ext/oci8/oci8_interface.c | 151 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 7 deletions(-) diff --git a/ext/oci8/oci8.stub.php b/ext/oci8/oci8.stub.php index 6dd0d07045cef..4c4ed64559139 100644 --- a/ext/oci8/oci8.stub.php +++ b/ext/oci8/oci8.stub.php @@ -953,7 +953,7 @@ function oci_unregister_taf_callback($connection): bool {} class OCILob { /** @var resource */ - public readonly mixed $descriptor; + public mixed $descriptor = null; /** * @alias oci_lob_save @@ -1084,7 +1084,7 @@ public function free(): bool {} class OCICollection { /** @var resource */ - public readonly mixed $collection; + public mixed $collection = null; /** * @alias oci_free_collection * @tentative-return-type diff --git a/ext/oci8/oci8_arginfo.h b/ext/oci8/oci8_arginfo.h index 4e8304b8673d6..58a1d43ca8f2d 100644 --- a/ext/oci8/oci8_arginfo.h +++ b/ext/oci8/oci8_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 66436b4202234c49e23f476f32ce178e756795a3 */ + * Stub hash: 99e690256bdafbdcda848cbef1c43264f9977151 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement) @@ -901,9 +901,9 @@ static zend_class_entry *register_class_OCILob(void) class_entry = zend_register_internal_class_ex(&ce, NULL); zval property_descriptor_default_value; - ZVAL_UNDEF(&property_descriptor_default_value); + ZVAL_NULL(&property_descriptor_default_value); zend_string *property_descriptor_name = zend_string_init("descriptor", sizeof("descriptor") - 1, 1); - zend_declare_typed_property(class_entry, property_descriptor_name, &property_descriptor_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); + zend_declare_typed_property(class_entry, property_descriptor_name, &property_descriptor_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); zend_string_release(property_descriptor_name); return class_entry; @@ -917,9 +917,9 @@ static zend_class_entry *register_class_OCICollection(void) class_entry = zend_register_internal_class_ex(&ce, NULL); zval property_collection_default_value; - ZVAL_UNDEF(&property_collection_default_value); + ZVAL_NULL(&property_collection_default_value); zend_string *property_collection_name = zend_string_init("collection", sizeof("collection") - 1, 1); - zend_declare_typed_property(class_entry, property_collection_name, &property_collection_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); + zend_declare_typed_property(class_entry, property_collection_name, &property_collection_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); zend_string_release(property_collection_name); return class_entry; diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c index 90e770161198d..64deb8de5fd0d 100644 --- a/ext/oci8/oci8_interface.c +++ b/ext/oci8/oci8_interface.c @@ -237,6 +237,10 @@ PHP_FUNCTION(oci_free_descriptor) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -265,6 +269,10 @@ PHP_FUNCTION(oci_lob_save) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -288,6 +296,10 @@ PHP_FUNCTION(oci_lob_import) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -311,6 +323,10 @@ PHP_FUNCTION(oci_lob_load) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -348,6 +364,10 @@ PHP_FUNCTION(oci_lob_read) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -377,6 +397,10 @@ PHP_FUNCTION(oci_lob_eof) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -400,6 +424,11 @@ PHP_FUNCTION(oci_lob_tell) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); RETURN_LONG(descriptor->lob_current_position); @@ -417,6 +446,10 @@ PHP_FUNCTION(oci_lob_rewind) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -439,6 +472,10 @@ PHP_FUNCTION(oci_lob_seek) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -483,6 +520,10 @@ PHP_FUNCTION(oci_lob_size) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -513,6 +554,11 @@ PHP_FUNCTION(oci_lob_write) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (data_len <= 0) { @@ -537,7 +583,15 @@ PHP_FUNCTION(oci_lob_append) } tmp_dest = Z_OCILOB_DESCRIPTOR_P(z_descriptor_dest); + if (Z_TYPE_P(tmp_dest) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object"); + RETURN_FALSE; + } tmp_from = Z_OCILOB_DESCRIPTOR_P(z_descriptor_from); + if (Z_TYPE_P(tmp_from) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_dest, descriptor_dest); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_from, descriptor_from); @@ -568,6 +622,10 @@ PHP_FUNCTION(oci_lob_truncate) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } ub_trim_length = (ub4) trim_length; PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -607,6 +665,11 @@ PHP_FUNCTION(oci_lob_erase) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (php_oci_lob_erase(descriptor, offset, (ub4) length, &bytes_erased)) { @@ -628,6 +691,11 @@ PHP_FUNCTION(oci_lob_flush) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (descriptor->buffering == PHP_OCI_LOB_BUFFER_DISABLED) { @@ -654,6 +722,11 @@ PHP_FUNCTION(ocisetbufferinglob) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (php_oci_lob_set_buffering(descriptor, flag)) { @@ -674,6 +747,11 @@ PHP_FUNCTION(ocigetbufferinglob) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (descriptor->buffering != PHP_OCI_LOB_BUFFER_DISABLED) { @@ -703,7 +781,15 @@ PHP_FUNCTION(oci_lob_copy) } tmp_dest = Z_OCILOB_DESCRIPTOR_P(z_descriptor_dest); + if (Z_TYPE_P(tmp_dest) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object"); + RETURN_FALSE; + } tmp_from = Z_OCILOB_DESCRIPTOR_P(z_descriptor_from); + if (Z_TYPE_P(tmp_from) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_dest, descriptor_dest); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_from, descriptor_from); @@ -727,7 +813,15 @@ PHP_FUNCTION(oci_lob_is_equal) } tmp_first = Z_OCILOB_DESCRIPTOR_P(z_descriptor_first); + if (Z_TYPE_P(tmp_first) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object"); + RETURN_FALSE; + } tmp_second = Z_OCILOB_DESCRIPTOR_P(z_descriptor_second); + if (Z_TYPE_P(tmp_second) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_first, descriptor_first); PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_second, descriptor_second); @@ -775,6 +869,10 @@ PHP_FUNCTION(oci_lob_export) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -854,6 +952,10 @@ PHP_METHOD(OCILob, writeTemporary) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); @@ -875,6 +977,11 @@ PHP_METHOD(OCILob, close) } tmp = Z_OCILOB_DESCRIPTOR_P(z_descriptor); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find descriptor property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor); if (php_oci_lob_close(descriptor)) { @@ -2016,6 +2123,11 @@ PHP_FUNCTION(oci_free_collection) } tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find collection property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); zend_list_close(collection->id); @@ -2036,6 +2148,11 @@ PHP_FUNCTION(oci_collection_append) } tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find collection property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_append(collection, value, (int) value_len)) { @@ -2057,6 +2174,11 @@ PHP_FUNCTION(oci_collection_element_get) } tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find collection property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_element_get(collection, element_index, return_value)) { @@ -2076,7 +2198,16 @@ PHP_FUNCTION(oci_collection_assign) } tmp_dest = Z_OCICOLLECTION_COLLECTION_P(z_collection_dest); + if (Z_TYPE_P(tmp_dest) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find collection property. The first argument should be valid collection object"); + RETURN_FALSE; + } tmp_from = Z_OCICOLLECTION_COLLECTION_P(z_collection_from); + if (Z_TYPE_P(tmp_from) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find collection property. The second argument should be valid collection object"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_COLLECTION(tmp_dest, collection_dest); PHP_OCI_ZVAL_TO_COLLECTION(tmp_from, collection_from); @@ -2101,6 +2232,11 @@ PHP_FUNCTION(oci_collection_element_assign) } tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find collection property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_element_set(collection, element_index, value, (int) value_len)) { @@ -2122,6 +2258,11 @@ PHP_FUNCTION(oci_collection_size) } tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find collection property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_size(collection, &size)) { @@ -2143,6 +2284,11 @@ PHP_FUNCTION(oci_collection_max) } tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find collection property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_max(collection, &max)) { @@ -2164,6 +2310,11 @@ PHP_FUNCTION(oci_collection_trim) } tmp = Z_OCICOLLECTION_COLLECTION_P(z_collection); + if (Z_TYPE_P(tmp) != IS_RESOURCE) { + php_error_docref(NULL, E_WARNING, "Unable to find collection property"); + RETURN_FALSE; + } + PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection); if (php_oci_collection_trim(collection, trim_size)) {