php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #62410
Patch property-overloading-php-5.4-support revision 2012-06-25 19:29 UTC by lars at strojny dot net
Patch property-overloading-v1.diff revision 2012-06-25 19:23 UTC by lars at strojny dot net

Patch property-overloading-php-5.4-support for amqp Bug #62410

Patch version 2012-06-25 19:29 UTC

Return to Bug #62410 | Download this patch
Patch Revisions:

Developer: lars@strojny.net

diff --git a/amqp_channel.c b/amqp_channel.c
index 8a2930f..a26e9a1 100644
--- a/amqp_channel.c
+++ b/amqp_channel.c
@@ -95,13 +95,12 @@ void amqp_channel_dtor(void *object TSRMLS_DC)
 zend_object_value amqp_channel_ctor(zend_class_entry *ce TSRMLS_DC)
 {
 	zend_object_value new_value;
-	zval *tmp;
 	amqp_channel_object *channel = (amqp_channel_object*)emalloc(sizeof(amqp_channel_object));
 
 	memset(channel, 0, sizeof(amqp_channel_object));
 
 	zend_object_std_init(&channel->zo, ce TSRMLS_CC);
-	zend_hash_copy(channel->zo.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+	AMQP_OBJECT_PROPERTIES_INIT(channel->zo, ce);
 
 	new_value.handle = zend_objects_store_put(
 		channel,
diff --git a/amqp_connection.c b/amqp_connection.c
index efc0242..0d25129 100644
--- a/amqp_connection.c
+++ b/amqp_connection.c
@@ -341,13 +341,12 @@ void amqp_connection_dtor(void *object TSRMLS_DC)
 zend_object_value amqp_connection_ctor(zend_class_entry *ce TSRMLS_DC)
 {
 	zend_object_value new_value;
-	zval *tmp;
 
 	amqp_connection_object* connection = (amqp_connection_object*)emalloc(sizeof(amqp_connection_object));
 	memset(connection, 0, sizeof(amqp_connection_object));
 
 	zend_object_std_init(&connection->zo, ce TSRMLS_CC);
-	zend_hash_copy(connection->zo.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+	AMQP_OBJECT_PROPERTIES_INIT(connection->zo, ce);
 
 	new_value.handle = zend_objects_store_put(
 		connection,
diff --git a/amqp_envelope.c b/amqp_envelope.c
index 4692a63..6354007 100644
--- a/amqp_envelope.c
+++ b/amqp_envelope.c
@@ -152,7 +152,6 @@ void amqp_envelope_dtor(void *object TSRMLS_DC)
 zend_object_value amqp_envelope_ctor(zend_class_entry *ce TSRMLS_DC)
 {
 	zend_object_value new_value;
-	zval *tmp;
 	amqp_envelope_object *envelope = (amqp_envelope_object*)emalloc(sizeof(amqp_envelope_object));
 
 	memset(envelope, 0, sizeof(amqp_envelope_object));
@@ -161,7 +160,7 @@ zend_object_value amqp_envelope_ctor(zend_class_entry *ce TSRMLS_DC)
 	array_init(envelope->headers);
 
 	zend_object_std_init(&envelope->zo, ce TSRMLS_CC);
-	zend_hash_copy(envelope->zo.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+	AMQP_OBJECT_PROPERTIES_INIT(envelope->zo, ce);
 
 	new_value.handle = zend_objects_store_put(envelope, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)amqp_envelope_dtor, NULL TSRMLS_CC);
 
diff --git a/amqp_exchange.c b/amqp_exchange.c
index 212dede..03a4ce7 100644
--- a/amqp_exchange.c
+++ b/amqp_exchange.c
@@ -101,7 +101,6 @@ void amqp_exchange_dtor(void *object TSRMLS_DC)
 zend_object_value amqp_exchange_ctor(zend_class_entry *ce TSRMLS_DC)
 {
 	zend_object_value new_value;
-	zval *tmp;
 	amqp_exchange_object* exchange = (amqp_exchange_object*)emalloc(sizeof(amqp_exchange_object));
 
 	memset(exchange, 0, sizeof(amqp_exchange_object));
@@ -111,7 +110,7 @@ zend_object_value amqp_exchange_ctor(zend_class_entry *ce TSRMLS_DC)
 	array_init(exchange->arguments);
 
 	zend_object_std_init(&exchange->zo, ce TSRMLS_CC);
-	zend_hash_copy(exchange->zo.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+	AMQP_OBJECT_PROPERTIES_INIT(exchange->zo, ce);
 
 	new_value.handle = zend_objects_store_put(
 		exchange,
diff --git a/amqp_queue.c b/amqp_queue.c
index d2f7844..537644d 100644
--- a/amqp_queue.c
+++ b/amqp_queue.c
@@ -112,13 +112,12 @@ void amqp_queue_dtor(void *object TSRMLS_DC)
 zend_object_value amqp_queue_ctor(zend_class_entry *ce TSRMLS_DC)
 {
 	zend_object_value new_value;
-	zval *tmp;
 	amqp_queue_object* queue = (amqp_queue_object*)emalloc(sizeof(amqp_queue_object));
 
 	memset(queue, 0, sizeof(amqp_queue_object));
 
 	zend_object_std_init(&queue->zo, ce TSRMLS_CC);
-	zend_hash_copy(queue->zo.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+	AMQP_OBJECT_PROPERTIES_INIT(queue->zo, ce);
 
 	// Initialize the arguments array:
 	MAKE_STD_ZVAL(queue->arguments);
diff --git a/php_amqp.h b/php_amqp.h
index cdfd116..a9e5cd4 100644
--- a/php_amqp.h
+++ b/php_amqp.h
@@ -263,6 +263,14 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
 		return; \
 	} \
 
+#if ZEND_MODULE_API_NO >= 20100000
+#define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) object_properties_init(&obj, ce);
+#else
+#define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) \
+zval *tmp; \
+zend_hash_copy(obj.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+#endif
+
 extern int le_amqp_connection_resource;
 // ZEND_DECLARE_MODULE_GLOBALS(amqp)
 
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Dec 07 18:03:35 2021 UTC