From 7ebb278e7854e8dd7c4fd6c0363531642d135676 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Sat, 2 Mar 2019 18:37:26 +0100 Subject: [PATCH 1/1] PHP-7.4 compat --- src/php_pq_object.c | 10 +++++++++- src/php_pq_object.h | 8 +++++++- src/php_pqcancel.c | 2 +- src/php_pqconn.c | 2 +- src/php_pqcopy.c | 2 +- src/php_pqcur.c | 2 +- src/php_pqlob.c | 2 +- src/php_pqres.c | 2 +- src/php_pqstm.c | 2 +- src/php_pqtxn.c | 2 +- src/php_pqtypes.c | 16 +++++++++++++--- 11 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/php_pq_object.c b/src/php_pq_object.c index 7c695ff..b9ce32d 100644 --- a/src/php_pq_object.c +++ b/src/php_pq_object.c @@ -203,7 +203,7 @@ zval *php_pq_object_read_prop(zval *object, zval *member, int type, void **cache return return_value; } -void php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot) +php_pq_object_write_prop_t php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot) { php_pq_object_t *obj = PHP_PQ_OBJ(object, NULL); php_pq_object_prophandler_t *handler; @@ -218,6 +218,14 @@ void php_pq_object_write_prop(zval *object, zval *member, zval *value, void **ca } else { zend_get_std_object_handlers()->write_property(object, member, value, cache_slot); } +#if PHP_VERSION_ID >= 70400 + return value; +#endif +} + +zval *php_pq_object_get_prop_ptr_null(zval *object, zval *member, int type, void **cache_slot) +{ + return NULL; } void php_pq_object_prophandler_dtor(zval *zv) { diff --git a/src/php_pq_object.h b/src/php_pq_object.h index 2c7417a..a274dd4 100644 --- a/src/php_pq_object.h +++ b/src/php_pq_object.h @@ -49,7 +49,13 @@ extern HashTable *php_pq_object_properties(zval *object); HashTable *php_pq_object_get_gc(zval *object, zval **table, int *n); extern zend_class_entry *ancestor(zend_class_entry *ce); extern zval *php_pq_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp); -extern void php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot); +#if PHP_VERSION_ID >= 70400 +typedef zval *php_pq_object_write_prop_t; +#else +typedef void php_pq_object_write_prop_t; +#endif +extern php_pq_object_write_prop_t php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot); +extern zval *php_pq_object_get_prop_ptr_null(zval *object, zval *member, int type, void **cache_slot); extern void php_pq_object_prophandler_dtor(zval *zv); #endif diff --git a/src/php_pqcancel.c b/src/php_pqcancel.c index edf8b10..e3b6ed7 100644 --- a/src/php_pqcancel.c +++ b/src/php_pqcancel.c @@ -156,7 +156,7 @@ PHP_MINIT_FUNCTION(pqcancel) php_pqcancel_object_handlers.read_property = php_pq_object_read_prop; php_pqcancel_object_handlers.write_property = php_pq_object_write_prop; php_pqcancel_object_handlers.clone_obj = NULL; - php_pqcancel_object_handlers.get_property_ptr_ptr = NULL; + php_pqcancel_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null; php_pqcancel_object_handlers.get_gc = php_pq_object_get_gc; php_pqcancel_object_handlers.get_properties = php_pq_object_properties; php_pqcancel_object_handlers.get_debug_info = php_pq_object_debug_info; diff --git a/src/php_pqconn.c b/src/php_pqconn.c index 9b507b6..e3ca68f 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -2004,7 +2004,7 @@ PHP_MINIT_FUNCTION(pqconn) php_pqconn_object_handlers.read_property = php_pq_object_read_prop; php_pqconn_object_handlers.write_property = php_pq_object_write_prop; php_pqconn_object_handlers.clone_obj = NULL; - php_pqconn_object_handlers.get_property_ptr_ptr = NULL; + php_pqconn_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null; php_pqconn_object_handlers.get_gc = php_pq_object_get_gc; php_pqconn_object_handlers.get_properties = php_pq_object_properties; php_pqconn_object_handlers.get_debug_info = php_pq_object_debug_info; diff --git a/src/php_pqcopy.c b/src/php_pqcopy.c index e945679..1ab3ad9 100644 --- a/src/php_pqcopy.c +++ b/src/php_pqcopy.c @@ -321,7 +321,7 @@ PHP_MINIT_FUNCTION(pqcopy) php_pqcopy_object_handlers.read_property = php_pq_object_read_prop; php_pqcopy_object_handlers.write_property = php_pq_object_write_prop; php_pqcopy_object_handlers.clone_obj = NULL; - php_pqcopy_object_handlers.get_property_ptr_ptr = NULL; + php_pqcopy_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null; php_pqcopy_object_handlers.get_gc = php_pq_object_get_gc; php_pqcopy_object_handlers.get_properties = php_pq_object_properties; php_pqcopy_object_handlers.get_debug_info = php_pq_object_debug_info; diff --git a/src/php_pqcur.c b/src/php_pqcur.c index 9989533..6dcd83e 100644 --- a/src/php_pqcur.c +++ b/src/php_pqcur.c @@ -433,7 +433,7 @@ PHP_MINIT_FUNCTION(pqcur) php_pqcur_object_handlers.read_property = php_pq_object_read_prop; php_pqcur_object_handlers.write_property = php_pq_object_write_prop; php_pqcur_object_handlers.clone_obj = NULL; - php_pqcur_object_handlers.get_property_ptr_ptr = NULL; + php_pqcur_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null; php_pqcur_object_handlers.get_gc = php_pq_object_get_gc; php_pqcur_object_handlers.get_properties = php_pq_object_properties; php_pqcur_object_handlers.get_debug_info = php_pq_object_debug_info; diff --git a/src/php_pqlob.c b/src/php_pqlob.c index 5d1f6ba..006eb75 100644 --- a/src/php_pqlob.c +++ b/src/php_pqlob.c @@ -453,7 +453,7 @@ PHP_MINIT_FUNCTION(pqlob) php_pqlob_object_handlers.read_property = php_pq_object_read_prop; php_pqlob_object_handlers.write_property = php_pq_object_write_prop; php_pqlob_object_handlers.clone_obj = NULL; - php_pqlob_object_handlers.get_property_ptr_ptr = NULL; + php_pqlob_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null; php_pqlob_object_handlers.get_gc = php_pq_object_get_gc; php_pqlob_object_handlers.get_properties = php_pq_object_properties; php_pqlob_object_handlers.get_debug_info = php_pq_object_debug_info; diff --git a/src/php_pqres.c b/src/php_pqres.c index 7638445..6e8bb07 100644 --- a/src/php_pqres.c +++ b/src/php_pqres.c @@ -1192,7 +1192,7 @@ PHP_MINIT_FUNCTION(pqres) php_pqres_object_handlers.read_property = php_pq_object_read_prop; php_pqres_object_handlers.write_property = php_pq_object_write_prop; php_pqres_object_handlers.clone_obj = NULL; - php_pqres_object_handlers.get_property_ptr_ptr = NULL; + php_pqres_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null; php_pqres_object_handlers.get_gc = php_pq_object_get_gc; php_pqres_object_handlers.get_debug_info = php_pq_object_debug_info; php_pqres_object_handlers.get_properties = php_pq_object_properties; diff --git a/src/php_pqstm.c b/src/php_pqstm.c index a5caa1b..60f4bc8 100644 --- a/src/php_pqstm.c +++ b/src/php_pqstm.c @@ -493,7 +493,7 @@ PHP_MINIT_FUNCTION(pqstm) php_pqstm_object_handlers.read_property = php_pq_object_read_prop; php_pqstm_object_handlers.write_property = php_pq_object_write_prop; php_pqstm_object_handlers.clone_obj = NULL; - php_pqstm_object_handlers.get_property_ptr_ptr = NULL; + php_pqstm_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null; php_pqstm_object_handlers.get_gc = php_pq_object_get_gc; php_pqstm_object_handlers.get_properties = php_pq_object_properties; php_pqstm_object_handlers.get_debug_info = php_pq_object_debug_info; diff --git a/src/php_pqtxn.c b/src/php_pqtxn.c index 70b7ec9..ebcb44d 100644 --- a/src/php_pqtxn.c +++ b/src/php_pqtxn.c @@ -883,7 +883,7 @@ PHP_MINIT_FUNCTION(pqtxn) php_pqtxn_object_handlers.read_property = php_pq_object_read_prop; php_pqtxn_object_handlers.write_property = php_pq_object_write_prop; php_pqtxn_object_handlers.clone_obj = NULL; - php_pqtxn_object_handlers.get_property_ptr_ptr = NULL; + php_pqtxn_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null; php_pqtxn_object_handlers.get_gc = php_pq_object_get_gc; php_pqtxn_object_handlers.get_properties = php_pq_object_properties; php_pqtxn_object_handlers.get_debug_info = php_pq_object_debug_info; diff --git a/src/php_pqtypes.c b/src/php_pqtypes.c index e1d22ad..323883c 100644 --- a/src/php_pqtypes.c +++ b/src/php_pqtypes.c @@ -143,6 +143,16 @@ static zval *php_pqtypes_object_read_dimension(zval *object, zval *member, int t return data; } +static void php_pqtypes_object_write_dimension(zval *object, zval *offset, zval *value) +{ + throw_exce(EX_RUNTIME, "pq\\Types object must not be modified"); +} + +static void php_pqtypes_object_unset_dimension(zval *object, zval *offset) +{ + throw_exce(EX_RUNTIME, "pq\\Types object must not be modified"); +} + ZEND_BEGIN_ARG_INFO_EX(ai_pqtypes_construct, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, connection, pq\\Connection, 0) ZEND_ARG_ARRAY_INFO(0, namespaces, 1) @@ -301,14 +311,14 @@ PHP_MINIT_FUNCTION(pqtypes) php_pqtypes_object_handlers.read_property = php_pq_object_read_prop; php_pqtypes_object_handlers.write_property = php_pq_object_write_prop; php_pqtypes_object_handlers.clone_obj = NULL; - php_pqtypes_object_handlers.get_property_ptr_ptr = NULL; + php_pqtypes_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null; php_pqtypes_object_handlers.get_gc = php_pq_object_get_gc; php_pqtypes_object_handlers.get_properties = php_pq_object_properties; php_pqtypes_object_handlers.get_debug_info = php_pq_object_debug_info; php_pqtypes_object_handlers.has_dimension = php_pqtypes_object_has_dimension; php_pqtypes_object_handlers.read_dimension = php_pqtypes_object_read_dimension; - php_pqtypes_object_handlers.unset_dimension = NULL; - php_pqtypes_object_handlers.write_dimension = NULL; + php_pqtypes_object_handlers.unset_dimension = php_pqtypes_object_unset_dimension; + php_pqtypes_object_handlers.write_dimension = php_pqtypes_object_write_dimension; zend_hash_init(&php_pqtypes_object_prophandlers, 1, NULL, php_pq_object_prophandler_dtor, 1); -- 2.30.2