summaryrefslogtreecommitdiffstats
path: root/rdkafka-php8.patch
diff options
context:
space:
mode:
Diffstat (limited to 'rdkafka-php8.patch')
-rw-r--r--rdkafka-php8.patch6386
1 files changed, 1887 insertions, 4499 deletions
diff --git a/rdkafka-php8.patch b/rdkafka-php8.patch
index dcb7e0e..4199489 100644
--- a/rdkafka-php8.patch
+++ b/rdkafka-php8.patch
@@ -1,46 +1,15 @@
-From a1cf352a1688097dbe2a755a05c05ee9e29ea7c4 Mon Sep 17 00:00:00 2001
-From: Arnaud Le Blanc <arnaud.lb@gmail.com>
-Date: Mon, 7 Dec 2020 10:59:39 +0100
-Subject: [PATCH] Drop TSRMLS (#401)
-
-Co-authored-by: nick <nickjobszh@gmail.com>
----
- conf.c | 148 +++++++++++-----------
- conf.h | 8 +-
- fun.c | 8 +-
- kafka_consumer.c | 166 ++++++++++++-------------
- kafka_consumer.h | 2 +-
- kafka_error_exception.c | 56 ++++-----
- kafka_error_exception.h | 4 +-
- message.c | 54 ++++----
- message.h | 6 +-
- metadata.c | 56 ++++-----
- metadata.h | 4 +-
- metadata_broker.c | 30 ++---
- metadata_broker.h | 4 +-
- metadata_collection.c | 46 +++----
- metadata_collection.h | 6 +-
- metadata_partition.c | 40 +++---
- metadata_partition.h | 4 +-
- metadata_topic.c | 38 +++---
- metadata_topic.h | 4 +-
- php_rdkafka_priv.h | 30 ++---
- queue.c | 26 ++--
- queue.h | 4 +-
- rdkafka.c | 176 +++++++++++++--------------
- tests/conf_setDefaultTopicConf8.phpt | 38 ++++++
- topic.c | 124 +++++++++----------
- topic.h | 4 +-
- topic_partition.c | 70 +++++------
- topic_partition.h | 10 +-
- 28 files changed, 602 insertions(+), 564 deletions(-)
- create mode 100644 tests/conf_setDefaultTopicConf8.phpt
-
diff --git a/conf.c b/conf.c
-index 2e4fe99..69d1863 100644
+index 2e4fe99..1ec2e59 100644
--- a/conf.c
+++ b/conf.c
-@@ -38,7 +38,7 @@ zend_class_entry * ce_kafka_topic_conf;
+@@ -31,14 +31,13 @@
+ #include "conf.h"
+ #include "topic_partition.h"
+ #include "message.h"
+-#include "zeval.h"
+
+ zend_class_entry * ce_kafka_conf;
+ zend_class_entry * ce_kafka_topic_conf;
static zend_object_handlers handlers;
@@ -49,7 +18,7 @@ index 2e4fe99..69d1863 100644
{
if (cb) {
zval_ptr_dtor(&cb->fci.function_name);
-@@ -46,25 +46,25 @@ static void kafka_conf_callback_dtor(kafka_conf_callback *cb TSRMLS_DC) /* {{{ *
+@@ -46,58 +45,54 @@ static void kafka_conf_callback_dtor(kafka_conf_callback *cb TSRMLS_DC) /* {{{ *
}
} /* }}} */
@@ -84,7 +53,12 @@ index 2e4fe99..69d1863 100644
{
if (from) {
*to = emalloc(sizeof(**to));
-@@ -77,18 +77,18 @@ static void kafka_conf_callback_copy(kafka_conf_callback **to, kafka_conf_callba
+ **to = *from;
+-#if PHP_MAJOR_VERSION >= 7
+ zval_copy_ctor(&(*to)->fci.function_name);
+-#else
+- Z_ADDREF_P((*to)->fci.function_name);
+-#endif
}
} /* }}} */
@@ -110,9 +84,11 @@ index 2e4fe99..69d1863 100644
-static void kafka_conf_free(zend_object *object TSRMLS_DC) /* {{{ */
+static void kafka_conf_free(zend_object *object) /* {{{ */
{
- kafka_conf_object *intern = get_custom_object(kafka_conf_object, object);
+- kafka_conf_object *intern = get_custom_object(kafka_conf_object, object);
++ kafka_conf_object *intern = php_kafka_from_obj(kafka_conf_object, object);
-@@ -97,7 +97,7 @@ static void kafka_conf_free(zend_object *object TSRMLS_DC) /* {{{ */
+ switch (intern->type) {
+ case KAFKA_CONF:
if (intern->u.conf) {
rd_kafka_conf_destroy(intern->u.conf);
}
@@ -121,37 +97,44 @@ index 2e4fe99..69d1863 100644
break;
case KAFKA_TOPIC_CONF:
if (intern->u.topic_conf) {
-@@ -106,19 +106,19 @@ static void kafka_conf_free(zend_object *object TSRMLS_DC) /* {{{ */
+@@ -106,34 +101,32 @@ static void kafka_conf_free(zend_object *object TSRMLS_DC) /* {{{ */
break;
}
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+-
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
/* }}} */
-static zend_object_value kafka_conf_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value kafka_conf_new(zend_class_entry *class_type) /* {{{ */
++static zend_object *kafka_conf_new(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
kafka_conf_object *intern;
- intern = alloc_object(intern, class_type);
+- intern = alloc_object(intern, class_type);
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
++ intern = zend_object_alloc(sizeof(*intern), class_type);
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_conf_free, NULL);
-@@ -128,12 +128,12 @@ static zend_object_value kafka_conf_new(zend_class_entry *class_type TSRMLS_DC)
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_conf_free, NULL);
+- SET_OBJECT_HANDLERS(retval, &handlers);
++ retval = &intern->std;
++ retval->handlers = &handlers;
+
+ return retval;
}
/* }}} */
-kafka_conf_object * get_kafka_conf_object(zval *zconf TSRMLS_DC)
+kafka_conf_object * get_kafka_conf_object(zval *zconf)
{
- kafka_conf_object *oconf = get_custom_object_zval(kafka_conf_object, zconf);
+- kafka_conf_object *oconf = get_custom_object_zval(kafka_conf_object, zconf);
++ kafka_conf_object *oconf = Z_RDKAFKA_P(kafka_conf_object, zconf);
if (!oconf->type) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Conf::__construct() has not been called" TSRMLS_CC);
@@ -159,37 +142,112 @@ index 2e4fe99..69d1863 100644
return NULL;
}
-@@ -162,7 +162,7 @@ static void kafka_conf_error_cb(rd_kafka_t *rk, int err, const char *reason, voi
- ZVAL_LONG(P_ZEVAL(args[1]), err);
- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[2]), reason);
+@@ -143,8 +136,7 @@ kafka_conf_object * get_kafka_conf_object(zval *zconf TSRMLS_DC)
+ static void kafka_conf_error_cb(rd_kafka_t *rk, int err, const char *reason, void *opaque)
+ {
+ kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
+- zeval args[3];
+- TSRMLS_FETCH();
++ zval args[3];
+
+ if (!opaque) {
+ return;
+@@ -154,15 +146,15 @@ static void kafka_conf_error_cb(rd_kafka_t *rk, int err, const char *reason, voi
+ return;
+ }
+
+- MAKE_STD_ZEVAL(args[0]);
+- MAKE_STD_ZEVAL(args[1]);
+- MAKE_STD_ZEVAL(args[2]);
++ ZVAL_NULL(&args[0]);
++ ZVAL_NULL(&args[1]);
++ ZVAL_NULL(&args[2]);
+
+- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
+- ZVAL_LONG(P_ZEVAL(args[1]), err);
+- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[2]), reason);
++ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
++ ZVAL_LONG(&args[1], err);
++ ZVAL_STRING(&args[2], reason);
- rdkafka_call_function(&cbs->error->fci, &cbs->error->fcc, NULL, 3, args TSRMLS_CC);
+ rdkafka_call_function(&cbs->error->fci, &cbs->error->fcc, NULL, 3, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
-@@ -187,9 +187,9 @@ static void kafka_conf_dr_msg_cb(rd_kafka_t *rk, const rd_kafka_message_t *msg,
- MAKE_STD_ZEVAL(args[1]);
+@@ -172,8 +164,7 @@ static void kafka_conf_error_cb(rd_kafka_t *rk, int err, const char *reason, voi
+ static void kafka_conf_dr_msg_cb(rd_kafka_t *rk, const rd_kafka_message_t *msg, void *opaque)
+ {
+ kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
+- zeval args[2];
+- TSRMLS_FETCH();
++ zval args[2];
+
+ if (!opaque) {
+ return;
+@@ -183,13 +174,13 @@ static void kafka_conf_dr_msg_cb(rd_kafka_t *rk, const rd_kafka_message_t *msg,
+ return;
+ }
+
+- MAKE_STD_ZEVAL(args[0]);
+- MAKE_STD_ZEVAL(args[1]);
++ ZVAL_NULL(&args[0]);
++ ZVAL_NULL(&args[1]);
- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
+- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
- kafka_message_new(P_ZEVAL(args[1]), msg TSRMLS_CC);
-+ kafka_message_new(P_ZEVAL(args[1]), msg);
++ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
++ kafka_message_new(&args[1], msg);
- rdkafka_call_function(&cbs->dr_msg->fci, &cbs->dr_msg->fcc, NULL, 2, args TSRMLS_CC);
+ rdkafka_call_function(&cbs->dr_msg->fci, &cbs->dr_msg->fcc, NULL, 2, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
-@@ -217,7 +217,7 @@ static int kafka_conf_stats_cb(rd_kafka_t *rk, char *json, size_t json_len, void
- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[1]), json);
- ZVAL_LONG(P_ZEVAL(args[2]), json_len);
+@@ -198,8 +189,7 @@ static void kafka_conf_dr_msg_cb(rd_kafka_t *rk, const rd_kafka_message_t *msg,
+ static int kafka_conf_stats_cb(rd_kafka_t *rk, char *json, size_t json_len, void *opaque)
+ {
+ kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
+- zeval args[3];
+- TSRMLS_FETCH();
++ zval args[3];
+
+ if (!opaque) {
+ return 0;
+@@ -209,15 +199,15 @@ static int kafka_conf_stats_cb(rd_kafka_t *rk, char *json, size_t json_len, void
+ return 0;
+ }
+
+- MAKE_STD_ZEVAL(args[0]);
+- MAKE_STD_ZEVAL(args[1]);
+- MAKE_STD_ZEVAL(args[2]);
++ ZVAL_NULL(&args[0]);
++ ZVAL_NULL(&args[1]);
++ ZVAL_NULL(&args[2]);
+
+- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
+- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[1]), json);
+- ZVAL_LONG(P_ZEVAL(args[2]), json_len);
++ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
++ ZVAL_STRING(&args[1], json);
++ ZVAL_LONG(&args[2], json_len);
- rdkafka_call_function(&cbs->stats->fci, &cbs->stats->fcc, NULL, 3, args TSRMLS_CC);
+ rdkafka_call_function(&cbs->stats->fci, &cbs->stats->fcc, NULL, 3, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
-@@ -240,7 +240,7 @@ static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_
+@@ -229,8 +219,7 @@ static int kafka_conf_stats_cb(rd_kafka_t *rk, char *json, size_t json_len, void
+ static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_kafka_topic_partition_list_t *partitions, void *opaque)
+ {
+ kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
+- zeval args[3];
+- TSRMLS_FETCH();
++ zval args[3];
+
+ if (!opaque) {
+ return;
+@@ -240,22 +229,22 @@ static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_
err = rd_kafka_assign(rk, NULL);
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -198,25 +256,51 @@ index 2e4fe99..69d1863 100644
return;
}
-@@ -253,9 +253,9 @@ static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_
+ return;
+ }
+
+- MAKE_STD_ZEVAL(args[0]);
+- MAKE_STD_ZEVAL(args[1]);
+- MAKE_STD_ZEVAL(args[2]);
++ ZVAL_NULL(&args[0]);
++ ZVAL_NULL(&args[1]);
++ ZVAL_NULL(&args[2]);
- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
- ZVAL_LONG(P_ZEVAL(args[1]), err);
+- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
+- ZVAL_LONG(P_ZEVAL(args[1]), err);
- kafka_topic_partition_list_to_array(P_ZEVAL(args[2]), partitions TSRMLS_CC);
-+ kafka_topic_partition_list_to_array(P_ZEVAL(args[2]), partitions);
++ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
++ ZVAL_LONG(&args[1], err);
++ kafka_topic_partition_list_to_array(&args[2], partitions);
- rdkafka_call_function(&cbs->rebalance->fci, &cbs->rebalance->fcc, NULL, 3, args TSRMLS_CC);
+ rdkafka_call_function(&cbs->rebalance->fci, &cbs->rebalance->fcc, NULL, 3, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
-@@ -279,11 +279,11 @@ static void kafka_conf_consume_cb(rd_kafka_message_t *msg, void *opaque)
- MAKE_STD_ZEVAL(args[0]);
- MAKE_STD_ZEVAL(args[1]);
+@@ -265,8 +254,7 @@ static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_
+ static void kafka_conf_consume_cb(rd_kafka_message_t *msg, void *opaque)
+ {
+ kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
+- zeval args[2];
+- TSRMLS_FETCH();
++ zval args[2];
+
+ if (!opaque) {
+ return;
+@@ -276,14 +264,14 @@ static void kafka_conf_consume_cb(rd_kafka_message_t *msg, void *opaque)
+ return;
+ }
+
+- MAKE_STD_ZEVAL(args[0]);
+- MAKE_STD_ZEVAL(args[1]);
++ ZVAL_NULL(&args[0]);
++ ZVAL_NULL(&args[1]);
- kafka_message_new(P_ZEVAL(args[0]), msg TSRMLS_CC);
-+ kafka_message_new(P_ZEVAL(args[0]), msg);
- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[1]), &cbs->zrk, 1, 0);
+- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[1]), &cbs->zrk, 1, 0);
++ kafka_message_new(&args[0], msg);
++ ZVAL_ZVAL(&args[1], &cbs->zrk, 1, 0);
- rdkafka_call_function(&cbs->consume->fci, &cbs->consume->fcc, NULL, 2, args TSRMLS_CC);
@@ -224,28 +308,77 @@ index 2e4fe99..69d1863 100644
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
-@@ -309,9 +309,9 @@ static void kafka_conf_offset_commit_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err,
+@@ -292,8 +280,7 @@ static void kafka_conf_consume_cb(rd_kafka_message_t *msg, void *opaque)
+ static void kafka_conf_offset_commit_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_kafka_topic_partition_list_t *partitions, void *opaque)
+ {
+ kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
+- zeval args[3];
+- TSRMLS_FETCH();
++ zval args[3];
+
+ if (!opaque) {
+ return;
+@@ -303,15 +290,15 @@ static void kafka_conf_offset_commit_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err,
+ return;
+ }
+
+- MAKE_STD_ZEVAL(args[0]);
+- MAKE_STD_ZEVAL(args[1]);
+- MAKE_STD_ZEVAL(args[2]);
++ ZVAL_NULL(&args[0]);
++ ZVAL_NULL(&args[1]);
++ ZVAL_NULL(&args[2]);
- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
- ZVAL_LONG(P_ZEVAL(args[1]), err);
+- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
+- ZVAL_LONG(P_ZEVAL(args[1]), err);
- kafka_topic_partition_list_to_array(P_ZEVAL(args[2]), partitions TSRMLS_CC);
-+ kafka_topic_partition_list_to_array(P_ZEVAL(args[2]), partitions);
++ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
++ ZVAL_LONG(&args[1], err);
++ kafka_topic_partition_list_to_array(&args[2], partitions);
- rdkafka_call_function(&cbs->offset_commit->fci, &cbs->offset_commit->fcc, NULL, 3, args TSRMLS_CC);
+ rdkafka_call_function(&cbs->offset_commit->fci, &cbs->offset_commit->fcc, NULL, 3, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
-@@ -339,7 +339,7 @@ static void kafka_conf_log_cb(const rd_kafka_t *rk, int level, const char *facil
- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[2]), facility);
- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[3]), message);
+@@ -320,8 +307,7 @@ static void kafka_conf_offset_commit_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err,
+
+ static void kafka_conf_log_cb(const rd_kafka_t *rk, int level, const char *facility, const char *message)
+ {
+- zeval args[4];
+- TSRMLS_FETCH();
++ zval args[4];
+
+ kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) rd_kafka_opaque(rk);
+
+@@ -329,17 +315,17 @@ static void kafka_conf_log_cb(const rd_kafka_t *rk, int level, const char *facil
+ return;
+ }
+
+- MAKE_STD_ZEVAL(args[0]);
+- MAKE_STD_ZEVAL(args[1]);
+- MAKE_STD_ZEVAL(args[2]);
+- MAKE_STD_ZEVAL(args[3]);
++ ZVAL_NULL(&args[0]);
++ ZVAL_NULL(&args[1]);
++ ZVAL_NULL(&args[2]);
++ ZVAL_NULL(&args[3]);
+
+- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
+- ZVAL_LONG(P_ZEVAL(args[1]), level);
+- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[2]), facility);
+- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[3]), message);
++ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
++ ZVAL_LONG(&args[1], level);
++ ZVAL_STRING(&args[2], facility);
++ ZVAL_STRING(&args[3], message);
- rdkafka_call_function(&cbs->log->fci, &cbs->log->fcc, NULL, 4, args TSRMLS_CC);
+ rdkafka_call_function(&cbs->log->fci, &cbs->log->fcc, NULL, 4, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
-@@ -357,10 +357,10 @@ PHP_METHOD(RdKafka__Conf, __construct)
+@@ -357,18 +343,18 @@ PHP_METHOD(RdKafka__Conf, __construct)
kafka_conf_object *intern;
zend_error_handling error_handling;
@@ -259,7 +392,8 @@ index 2e4fe99..69d1863 100644
return;
}
-@@ -368,7 +368,7 @@ PHP_METHOD(RdKafka__Conf, __construct)
+- intern = get_custom_object_zval(kafka_conf_object, getThis());
++ intern = Z_RDKAFKA_P(kafka_conf_object, getThis());
intern->type = KAFKA_CONF;
intern->u.conf = rd_kafka_conf_new();
@@ -268,7 +402,7 @@ index 2e4fe99..69d1863 100644
}
/* }}} */
-@@ -385,11 +385,11 @@ PHP_METHOD(RdKafka__Conf, dump)
+@@ -385,11 +371,11 @@ PHP_METHOD(RdKafka__Conf, dump)
kafka_conf_object *intern;
size_t i;
@@ -282,7 +416,25 @@ index 2e4fe99..69d1863 100644
if (!intern) {
return;
}
-@@ -435,11 +435,11 @@ PHP_METHOD(RdKafka__Conf, set)
+@@ -410,7 +396,7 @@ PHP_METHOD(RdKafka__Conf, dump)
+ for (i = 0; i < cntp; i+=2) {
+ const char *key = dump[i];
+ const char *value = dump[i+1];
+- rdkafka_add_assoc_string(return_value, (char*)key, (char*)value);
++ add_assoc_string(return_value, (char*)key, (char*)value);
+ }
+
+ rd_kafka_conf_dump_free(dump, cntp);
+@@ -428,18 +414,18 @@ ZEND_END_ARG_INFO()
+ PHP_METHOD(RdKafka__Conf, set)
+ {
+ char *name;
+- arglen_t name_len;
++ size_t name_len;
+ char *value;
+- arglen_t value_len;
++ size_t value_len;
+ kafka_conf_object *intern;
rd_kafka_conf_res_t ret = 0;
char errstr[512];
@@ -296,7 +448,7 @@ index 2e4fe99..69d1863 100644
if (!intern) {
return;
}
-@@ -457,10 +457,10 @@ PHP_METHOD(RdKafka__Conf, set)
+@@ -457,10 +443,10 @@ PHP_METHOD(RdKafka__Conf, set)
switch (ret) {
case RD_KAFKA_CONF_UNKNOWN:
@@ -309,7 +461,7 @@ index 2e4fe99..69d1863 100644
return;
case RD_KAFKA_CONF_OK:
break;
-@@ -481,16 +481,16 @@ PHP_METHOD(RdKafka__Conf, setDefaultTopicConf)
+@@ -481,16 +467,16 @@ PHP_METHOD(RdKafka__Conf, setDefaultTopicConf)
kafka_conf_object *topic_conf_intern;
rd_kafka_topic_conf_t *topic_conf;
@@ -329,7 +481,7 @@ index 2e4fe99..69d1863 100644
if (!topic_conf_intern) {
return;
}
-@@ -514,11 +514,11 @@ PHP_METHOD(RdKafka__Conf, setErrorCb)
+@@ -514,16 +500,16 @@ PHP_METHOD(RdKafka__Conf, setErrorCb)
zend_fcall_info_cache fcc;
kafka_conf_object *intern;
@@ -343,7 +495,13 @@ index 2e4fe99..69d1863 100644
if (!intern) {
return;
}
-@@ -551,11 +551,11 @@ PHP_METHOD(RdKafka__Conf, setDrMsgCb)
+
+- Z_ADDREF_P(P_ZEVAL(fci.function_name));
++ Z_ADDREF_P(&fci.function_name);
+
+ if (intern->cbs.error) {
+ zval_ptr_dtor(&intern->cbs.error->fci.function_name);
+@@ -551,16 +537,16 @@ PHP_METHOD(RdKafka__Conf, setDrMsgCb)
zend_fcall_info_cache fcc;
kafka_conf_object *intern;
@@ -357,7 +515,13 @@ index 2e4fe99..69d1863 100644
if (!intern) {
return;
}
-@@ -588,11 +588,11 @@ PHP_METHOD(RdKafka__Conf, setStatsCb)
+
+- Z_ADDREF_P(P_ZEVAL(fci.function_name));
++ Z_ADDREF_P(&fci.function_name);
+
+ if (intern->cbs.dr_msg) {
+ zval_ptr_dtor(&intern->cbs.dr_msg->fci.function_name);
+@@ -588,16 +574,16 @@ PHP_METHOD(RdKafka__Conf, setStatsCb)
zend_fcall_info_cache fcc;
kafka_conf_object *intern;
@@ -371,7 +535,13 @@ index 2e4fe99..69d1863 100644
if (!intern) {
return;
}
-@@ -625,11 +625,11 @@ PHP_METHOD(RdKafka__Conf, setRebalanceCb)
+
+- Z_ADDREF_P(P_ZEVAL(fci.function_name));
++ Z_ADDREF_P(&fci.function_name);
+
+ if (intern->cbs.stats) {
+ zval_ptr_dtor(&intern->cbs.stats->fci.function_name);
+@@ -625,16 +611,16 @@ PHP_METHOD(RdKafka__Conf, setRebalanceCb)
zend_fcall_info_cache fcc;
kafka_conf_object *intern;
@@ -385,7 +555,13 @@ index 2e4fe99..69d1863 100644
if (!intern) {
return;
}
-@@ -662,11 +662,11 @@ PHP_METHOD(RdKafka__Conf, setConsumeCb)
+
+- Z_ADDREF_P(P_ZEVAL(fci.function_name));
++ Z_ADDREF_P(&fci.function_name);
+
+ if (intern->cbs.rebalance) {
+ zval_ptr_dtor(&intern->cbs.rebalance->fci.function_name);
+@@ -662,16 +648,16 @@ PHP_METHOD(RdKafka__Conf, setConsumeCb)
zend_fcall_info_cache fcc;
kafka_conf_object *intern;
@@ -399,7 +575,13 @@ index 2e4fe99..69d1863 100644
if (!intern) {
return;
}
-@@ -699,11 +699,11 @@ PHP_METHOD(RdKafka__Conf, setOffsetCommitCb)
+
+- Z_ADDREF_P(P_ZEVAL(fci.function_name));
++ Z_ADDREF_P(&fci.function_name);
+
+ if (intern->cbs.consume) {
+ zval_ptr_dtor(&intern->cbs.consume->fci.function_name);
+@@ -699,16 +685,16 @@ PHP_METHOD(RdKafka__Conf, setOffsetCommitCb)
zend_fcall_info_cache fcc;
kafka_conf_object *intern;
@@ -413,7 +595,13 @@ index 2e4fe99..69d1863 100644
if (!intern) {
return;
}
-@@ -737,11 +737,11 @@ PHP_METHOD(RdKafka__Conf, setLogCb)
+
+- Z_ADDREF_P(P_ZEVAL(fci.function_name));
++ Z_ADDREF_P(&fci.function_name);
+
+ if (intern->cbs.offset_commit) {
+ zval_ptr_dtor(&intern->cbs.offset_commit->fci.function_name);
+@@ -737,16 +723,16 @@ PHP_METHOD(RdKafka__Conf, setLogCb)
kafka_conf_object *conf;
char errstr[512];
@@ -427,7 +615,13 @@ index 2e4fe99..69d1863 100644
if (!conf) {
return;
}
-@@ -768,10 +768,10 @@ PHP_METHOD(RdKafka__TopicConf, __construct)
+
+- Z_ADDREF_P(P_ZEVAL(fci.function_name));
++ Z_ADDREF_P(&fci.function_name);
+
+ if (conf->cbs.log) {
+ zval_ptr_dtor(&conf->cbs.log->fci.function_name);
+@@ -768,18 +754,18 @@ PHP_METHOD(RdKafka__TopicConf, __construct)
kafka_conf_object *intern;
zend_error_handling error_handling;
@@ -441,7 +635,8 @@ index 2e4fe99..69d1863 100644
return;
}
-@@ -779,7 +779,7 @@ PHP_METHOD(RdKafka__TopicConf, __construct)
+- intern = get_custom_object_zval(kafka_conf_object, getThis());
++ intern = Z_RDKAFKA_P(kafka_conf_object, getThis());
intern->type = KAFKA_TOPIC_CONF;
intern->u.topic_conf = rd_kafka_topic_conf_new();
@@ -450,7 +645,7 @@ index 2e4fe99..69d1863 100644
}
/* }}} */
-@@ -795,11 +795,11 @@ PHP_METHOD(RdKafka__TopicConf, setPartitioner)
+@@ -795,11 +781,11 @@ PHP_METHOD(RdKafka__TopicConf, setPartitioner)
zend_long id;
int32_t (*partitioner) (const rd_kafka_topic_t * rkt, const void * keydata, size_t keylen, int32_t partition_cnt, void * rkt_opaque, void * msg_opaque);
@@ -464,7 +659,7 @@ index 2e4fe99..69d1863 100644
if (!intern) {
return;
}
-@@ -823,7 +823,7 @@ PHP_METHOD(RdKafka__TopicConf, setPartitioner)
+@@ -823,7 +809,7 @@ PHP_METHOD(RdKafka__TopicConf, setPartitioner)
break;
#endif
default:
@@ -473,17 +668,20 @@ index 2e4fe99..69d1863 100644
return;
}
-@@ -854,7 +854,7 @@ static const zend_function_entry kafka_conf_fe[] = {
+@@ -854,19 +840,19 @@ static const zend_function_entry kafka_conf_fe[] = {
PHP_FE_END
};
-void kafka_conf_minit(TSRMLS_D)
-+void kafka_conf_minit()
++void kafka_conf_minit(INIT_FUNC_ARGS)
{
zend_class_entry tmpce;
-@@ -863,10 +863,10 @@ void kafka_conf_minit(TSRMLS_D)
- set_object_handler_offset(&handlers, XtOffsetOf(kafka_conf_object, std));
+ handlers = kafka_default_object_handlers;
+- set_object_handler_free_obj(&handlers, kafka_conf_free);
+- set_object_handler_offset(&handlers, XtOffsetOf(kafka_conf_object, std));
++ handlers.free_obj = kafka_conf_free;
++ handlers.offset = XtOffsetOf(kafka_conf_object, std);
INIT_NS_CLASS_ENTRY(tmpce, "RdKafka", "Conf", kafka_conf_fe);
- ce_kafka_conf = zend_register_internal_class(&tmpce TSRMLS_CC);
@@ -496,17 +694,31 @@ index 2e4fe99..69d1863 100644
ce_kafka_topic_conf->create_object = kafka_conf_new;
}
diff --git a/conf.h b/conf.h
-index 3ec6bcf..4bf13b2 100644
+index 3ec6bcf..9778eb5 100644
--- a/conf.h
+++ b/conf.h
-@@ -63,11 +63,11 @@ typedef struct _kafka_conf_object {
- #endif
+@@ -49,25 +49,20 @@ typedef struct _kafka_conf_callbacks {
+ } kafka_conf_callbacks;
+
+ typedef struct _kafka_conf_object {
+-#if PHP_MAJOR_VERSION < 7
+- zend_object std;
+-#endif
+ kafka_conf_type type;
+ union {
+ rd_kafka_conf_t *conf;
+ rd_kafka_topic_conf_t *topic_conf;
+ } u;
+ kafka_conf_callbacks cbs;
+-#if PHP_MAJOR_VERSION >= 7
+ zend_object std;
+-#endif
} kafka_conf_object;
-kafka_conf_object * get_kafka_conf_object(zval *zconf TSRMLS_DC);
-void kafka_conf_minit(TSRMLS_D);
+kafka_conf_object * get_kafka_conf_object(zval *zconf);
-+void kafka_conf_minit();
++void kafka_conf_minit(INIT_FUNC_ARGS);
-void kafka_conf_callbacks_dtor(kafka_conf_callbacks *cbs TSRMLS_DC);
-void kafka_conf_callbacks_copy(kafka_conf_callbacks *to, kafka_conf_callbacks *from TSRMLS_DC);
@@ -516,10 +728,56 @@ index 3ec6bcf..4bf13b2 100644
extern zend_class_entry * ce_kafka_conf;
extern zend_class_entry * ce_kafka_topic_conf;
diff --git a/fun.c b/fun.c
-index b5231ce..ee21814 100644
+index b5231ce..d73e202 100644
--- a/fun.c
+++ b/fun.c
-@@ -106,7 +106,7 @@ PHP_FUNCTION(rd_kafka_err2str)
+@@ -26,7 +26,6 @@
+ #include "librdkafka/rdkafka.h"
+ #include "Zend/zend_exceptions.h"
+ #include "ext/spl/spl_exceptions.h"
+-#include "zeval.h"
+
+ /* {{{ arginfo */
+ ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_get_err_descs, 0, 0, 0)
+@@ -71,7 +70,7 @@ PHP_FUNCTION(rd_kafka_get_err_descs)
+
+ for (i = 0; i < cnt; i++) {
+ const struct rd_kafka_err_desc *desc = &errdescs[i];
+- zeval el;
++ zval el;
+
+ if (desc->code == 0) {
+ if (seen_zero) {
+@@ -80,20 +79,20 @@ PHP_FUNCTION(rd_kafka_get_err_descs)
+ seen_zero = 1;
+ }
+
+- MAKE_STD_ZEVAL(el);
+- array_init(P_ZEVAL(el));
+- add_assoc_long(P_ZEVAL(el), "code", desc->code);
++ ZVAL_NULL(&el);
++ array_init(&el);
++ add_assoc_long(&el, "code", desc->code);
+ if (desc->name) {
+- rdkafka_add_assoc_string(P_ZEVAL(el), "name", (char*) desc->name);
++ add_assoc_string(&el, "name", (char*) desc->name);
+ } else {
+- add_assoc_null(P_ZEVAL(el), "name");
++ add_assoc_null(&el, "name");
+ }
+ if (desc->desc) {
+- rdkafka_add_assoc_string(P_ZEVAL(el), "desc", (char*) desc->desc);
++ add_assoc_string(&el, "desc", (char*) desc->desc);
+ }else {
+- add_assoc_null(P_ZEVAL(el), "desc");
++ add_assoc_null(&el, "desc");
+ }
+- add_next_index_zval(return_value, P_ZEVAL(el));
++ add_next_index_zval(return_value, &el);
+ }
+ }
+ /* }}} */
+@@ -106,14 +105,14 @@ PHP_FUNCTION(rd_kafka_err2str)
zend_long err;
const char *errstr;
@@ -528,7 +786,15 @@ index b5231ce..ee21814 100644
return;
}
-@@ -122,7 +122,7 @@ PHP_FUNCTION(rd_kafka_err2str)
+ errstr = rd_kafka_err2str(err);
+
+ if (errstr) {
+- RDKAFKA_RETURN_STRING(errstr);
++ RETURN_STRING(errstr);
+ }
+ }
+ /* }}} */
+@@ -122,7 +121,7 @@ PHP_FUNCTION(rd_kafka_err2str)
* Returns `errno` */
PHP_FUNCTION(rd_kafka_errno)
{
@@ -537,7 +803,7 @@ index b5231ce..ee21814 100644
return;
}
-@@ -136,7 +136,7 @@ PHP_FUNCTION(rd_kafka_errno2err)
+@@ -136,7 +135,7 @@ PHP_FUNCTION(rd_kafka_errno2err)
{
zend_long errnox;
@@ -546,7 +812,7 @@ index b5231ce..ee21814 100644
return;
}
-@@ -164,7 +164,7 @@ PHP_FUNCTION(rd_kafka_offset_tail)
+@@ -164,7 +163,7 @@ PHP_FUNCTION(rd_kafka_offset_tail)
{
zend_long cnt;
@@ -556,57 +822,78 @@ index b5231ce..ee21814 100644
}
diff --git a/kafka_consumer.c b/kafka_consumer.c
-index 5ee209a..8b6c4c2 100644
+index 5ee209a..f1b596a 100644
--- a/kafka_consumer.c
+++ b/kafka_consumer.c
-@@ -46,11 +46,11 @@ typedef struct _object_intern {
+@@ -33,24 +33,19 @@
+ #include "metadata.h"
+
+ typedef struct _object_intern {
+-#if PHP_MAJOR_VERSION < 7
+- zend_object std;
+-#endif
+ rd_kafka_t *rk;
+ kafka_conf_callbacks cbs;
+-#if PHP_MAJOR_VERSION >= 7
+ zend_object std;
+-#endif
+ } object_intern;
+
static zend_class_entry * ce;
static zend_object_handlers handlers;
-static void kafka_consumer_free(zend_object *object TSRMLS_DC) /* {{{ */
+static void kafka_consumer_free(zend_object *object) /* {{{ */
{
- object_intern *intern = get_custom_object(object_intern, object);
+- object_intern *intern = get_custom_object(object_intern, object);
++ object_intern *intern = php_kafka_from_obj(object_intern, object);
rd_kafka_resp_err_t err;
- kafka_conf_callbacks_dtor(&intern->cbs TSRMLS_CC);
+ kafka_conf_callbacks_dtor(&intern->cbs);
if (intern->rk) {
err = rd_kafka_consumer_close(intern->rk);
-@@ -63,21 +63,21 @@ static void kafka_consumer_free(zend_object *object TSRMLS_DC) /* {{{ */
+@@ -63,36 +58,34 @@ static void kafka_consumer_free(zend_object *object TSRMLS_DC) /* {{{ */
intern->rk = NULL;
}
- kafka_conf_callbacks_dtor(&intern->cbs TSRMLS_CC);
+-
+- zend_object_std_dtor(&intern->std TSRMLS_CC);
+ kafka_conf_callbacks_dtor(&intern->cbs);
-- zend_object_std_dtor(&intern->std TSRMLS_CC);
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
/* }}} */
-static zend_object_value kafka_consumer_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value kafka_consumer_new(zend_class_entry *class_type) /* {{{ */
++static zend_object *kafka_consumer_new(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
object_intern *intern;
- intern = alloc_object(intern, class_type);
+- intern = alloc_object(intern, class_type);
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
++ intern = zend_object_alloc(sizeof(*intern), class_type);
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_consumer_free, NULL);
-@@ -87,12 +87,12 @@ static zend_object_value kafka_consumer_new(zend_class_entry *class_type TSRMLS_
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_consumer_free, NULL);
+- SET_OBJECT_HANDLERS(retval, &handlers);
++ retval = &intern->std;
++ retval->handlers = &handlers;
+
+ return retval;
}
/* }}} */
-static object_intern * get_object(zval *zconsumer TSRMLS_DC) /* {{{ */
+static object_intern * get_object(zval *zconsumer) /* {{{ */
{
- object_intern *oconsumer = get_custom_object_zval(object_intern, zconsumer);
+- object_intern *oconsumer = get_custom_object_zval(object_intern, zconsumer);
++ object_intern *oconsumer = Z_RDKAFKA_P(object_intern, zconsumer);
if (!oconsumer->rk) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\KafkaConsumer::__construct() has not been called");
@@ -614,7 +901,7 @@ index 5ee209a..8b6c4c2 100644
return NULL;
}
-@@ -134,19 +134,19 @@ PHP_METHOD(RdKafka__KafkaConsumer, __construct)
+@@ -134,19 +127,19 @@ PHP_METHOD(RdKafka__KafkaConsumer, __construct)
kafka_conf_object *conf_intern;
rd_kafka_conf_t *conf = NULL;
@@ -628,7 +915,8 @@ index 5ee209a..8b6c4c2 100644
return;
}
- intern = get_custom_object_zval(object_intern, getThis());
+- intern = get_custom_object_zval(object_intern, getThis());
++ intern = Z_RDKAFKA_P(object_intern, getThis());
- conf_intern = get_kafka_conf_object(zconf TSRMLS_CC);
+ conf_intern = get_kafka_conf_object(zconf);
@@ -639,7 +927,7 @@ index 5ee209a..8b6c4c2 100644
intern->cbs.zrk = *getThis();
rd_kafka_conf_set_opaque(conf, &intern->cbs);
}
-@@ -155,15 +155,15 @@ PHP_METHOD(RdKafka__KafkaConsumer, __construct)
+@@ -155,15 +148,15 @@ PHP_METHOD(RdKafka__KafkaConsumer, __construct)
if (conf) {
rd_kafka_conf_destroy(conf);
}
@@ -658,7 +946,7 @@ index 5ee209a..8b6c4c2 100644
return;
}
-@@ -175,7 +175,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, __construct)
+@@ -175,7 +168,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, __construct)
rd_kafka_poll_set_consumer(rk);
@@ -667,7 +955,7 @@ index 5ee209a..8b6c4c2 100644
}
/* }}} */
-@@ -193,17 +193,17 @@ PHP_METHOD(RdKafka__KafkaConsumer, assign)
+@@ -193,17 +186,17 @@ PHP_METHOD(RdKafka__KafkaConsumer, assign)
rd_kafka_resp_err_t err;
object_intern *intern;
@@ -688,7 +976,7 @@ index 5ee209a..8b6c4c2 100644
if (!topics) {
return;
}
-@@ -218,7 +218,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, assign)
+@@ -218,7 +211,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, assign)
}
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -697,7 +985,7 @@ index 5ee209a..8b6c4c2 100644
return;
}
}
-@@ -236,11 +236,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getAssignment)
+@@ -236,11 +229,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getAssignment)
rd_kafka_topic_partition_list_t *topics;
object_intern *intern;
@@ -711,7 +999,7 @@ index 5ee209a..8b6c4c2 100644
if (!intern) {
return;
}
-@@ -248,11 +248,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getAssignment)
+@@ -248,11 +241,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getAssignment)
err = rd_kafka_assignment(intern->rk, &topics);
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -725,9 +1013,12 @@ index 5ee209a..8b6c4c2 100644
rd_kafka_topic_partition_list_destroy(topics);
}
/* }}} */
-@@ -273,11 +273,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, subscribe)
+@@ -271,13 +264,13 @@ PHP_METHOD(RdKafka__KafkaConsumer, subscribe)
+ object_intern *intern;
+ rd_kafka_topic_partition_list_t *topics;
rd_kafka_resp_err_t err;
- zeval *zv;
+- zeval *zv;
++ zval *zv;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "h", &htopics) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "h", &htopics) == FAILURE) {
@@ -739,7 +1030,20 @@ index 5ee209a..8b6c4c2 100644
if (!intern) {
return;
}
-@@ -296,7 +296,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, subscribe)
+@@ -285,10 +278,10 @@ PHP_METHOD(RdKafka__KafkaConsumer, subscribe)
+ topics = rd_kafka_topic_partition_list_new(zend_hash_num_elements(htopics));
+
+ for (zend_hash_internal_pointer_reset_ex(htopics, &pos);
+- (zv = rdkafka_hash_get_current_data_ex(htopics, &pos)) != NULL;
++ (zv = zend_hash_get_current_data_ex(htopics, &pos)) != NULL;
+ zend_hash_move_forward_ex(htopics, &pos)) {
+ convert_to_string_ex(zv);
+- rd_kafka_topic_partition_list_add(topics, Z_STRVAL_P(ZEVAL(zv)), RD_KAFKA_PARTITION_UA);
++ rd_kafka_topic_partition_list_add(topics, Z_STRVAL_P(zv), RD_KAFKA_PARTITION_UA);
+ }
+
+ err = rd_kafka_subscribe(intern->rk, topics);
+@@ -296,7 +289,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, subscribe)
rd_kafka_topic_partition_list_destroy(topics);
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -748,7 +1052,7 @@ index 5ee209a..8b6c4c2 100644
return;
}
}
-@@ -315,11 +315,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getSubscription)
+@@ -315,11 +308,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getSubscription)
object_intern *intern;
int i;
@@ -762,7 +1066,7 @@ index 5ee209a..8b6c4c2 100644
if (!intern) {
return;
}
-@@ -327,7 +327,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, getSubscription)
+@@ -327,14 +320,14 @@ PHP_METHOD(RdKafka__KafkaConsumer, getSubscription)
err = rd_kafka_subscription(intern->rk, &topics);
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -771,7 +1075,15 @@ index 5ee209a..8b6c4c2 100644
return;
}
-@@ -352,11 +352,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, unsubscribe)
+ array_init_size(return_value, topics->cnt);
+
+ for (i = 0; i < topics->cnt; i++) {
+- add_next_index_string(return_value, topics->elems[i].topic ZEVAL_DUP_CC);
++ add_next_index_string(return_value, topics->elems[i].topic);
+ }
+
+ rd_kafka_topic_partition_list_destroy(topics);
+@@ -352,11 +345,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, unsubscribe)
object_intern *intern;
rd_kafka_resp_err_t err;
@@ -785,7 +1097,7 @@ index 5ee209a..8b6c4c2 100644
if (!intern) {
return;
}
-@@ -364,7 +364,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, unsubscribe)
+@@ -364,7 +357,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, unsubscribe)
err = rd_kafka_unsubscribe(intern->rk);
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -794,7 +1106,7 @@ index 5ee209a..8b6c4c2 100644
return;
}
}
-@@ -383,11 +383,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, consume)
+@@ -383,11 +376,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, consume)
zend_long timeout_ms;
rd_kafka_message_t *rkmessage, rkmessage_tmp = {0};
@@ -808,7 +1120,7 @@ index 5ee209a..8b6c4c2 100644
if (!intern) {
return;
}
-@@ -399,7 +399,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, consume)
+@@ -399,7 +392,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, consume)
rkmessage = &rkmessage_tmp;
}
@@ -817,7 +1129,7 @@ index 5ee209a..8b6c4c2 100644
if (rkmessage != &rkmessage_tmp) {
rd_kafka_message_destroy(rkmessage);
-@@ -414,44 +414,44 @@ static void consumer_commit(int async, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
+@@ -414,44 +407,44 @@ static void consumer_commit(int async, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
rd_kafka_topic_partition_list_t *offsets = NULL;
rd_kafka_resp_err_t err;
@@ -842,7 +1154,7 @@ index 5ee209a..8b6c4c2 100644
rd_kafka_topic_partition_t *rktpar;
- zerr = rdkafka_read_property(NULL, zarg, ZEND_STRL("err"), 0 TSRMLS_CC);
-+ zerr = rdkafka_read_property(NULL, zarg, ZEND_STRL("err"), 0);
++ zerr = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("err"), 0);
if (zerr && Z_TYPE_P(zerr) != IS_NULL && (Z_TYPE_P(zerr) != IS_LONG || Z_LVAL_P(zerr) != RD_KAFKA_RESP_ERR_NO_ERROR)) {
- zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message has an error", RD_KAFKA_RESP_ERR__INVALID_ARG TSRMLS_CC);
+ zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message has an error", RD_KAFKA_RESP_ERR__INVALID_ARG);
@@ -850,7 +1162,7 @@ index 5ee209a..8b6c4c2 100644
}
- ztopic = rdkafka_read_property(NULL, zarg, ZEND_STRL("topic_name"), 0 TSRMLS_CC);
-+ ztopic = rdkafka_read_property(NULL, zarg, ZEND_STRL("topic_name"), 0);
++ ztopic = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("topic_name"), 0);
if (!ztopic || Z_TYPE_P(ztopic) != IS_STRING) {
- zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's topic_name is not a string", RD_KAFKA_RESP_ERR__INVALID_ARG TSRMLS_CC);
+ zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's topic_name is not a string", RD_KAFKA_RESP_ERR__INVALID_ARG);
@@ -858,7 +1170,7 @@ index 5ee209a..8b6c4c2 100644
}
- zpartition = rdkafka_read_property(NULL, zarg, ZEND_STRL("partition"), 0 TSRMLS_CC);
-+ zpartition = rdkafka_read_property(NULL, zarg, ZEND_STRL("partition"), 0);
++ zpartition = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("partition"), 0);
if (!zpartition || Z_TYPE_P(zpartition) != IS_LONG) {
- zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's partition is not an int", RD_KAFKA_RESP_ERR__INVALID_ARG TSRMLS_CC);
+ zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's partition is not an int", RD_KAFKA_RESP_ERR__INVALID_ARG);
@@ -866,14 +1178,14 @@ index 5ee209a..8b6c4c2 100644
}
- zoffset = rdkafka_read_property(NULL, zarg, ZEND_STRL("offset"), 0 TSRMLS_CC);
-+ zoffset = rdkafka_read_property(NULL, zarg, ZEND_STRL("offset"), 0);
++ zoffset = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("offset"), 0);
if (!zoffset || Z_TYPE_P(zoffset) != IS_LONG) {
- zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's offset is not an int", RD_KAFKA_RESP_ERR__INVALID_ARG TSRMLS_CC);
+ zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's offset is not an int", RD_KAFKA_RESP_ERR__INVALID_ARG);
return;
}
-@@ -463,14 +463,14 @@ static void consumer_commit(int async, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
+@@ -463,14 +456,14 @@ static void consumer_commit(int async, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
} else if (Z_TYPE_P(zarg) == IS_ARRAY) {
HashTable *ary = Z_ARRVAL_P(zarg);
@@ -890,7 +1202,7 @@ index 5ee209a..8b6c4c2 100644
1,
"an instance of RdKafka\\Message or an array of RdKafka\\TopicPartition",
zend_zval_type_name(zarg));
-@@ -485,7 +485,7 @@ static void consumer_commit(int async, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
+@@ -485,7 +478,7 @@ static void consumer_commit(int async, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
}
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -899,7 +1211,7 @@ index 5ee209a..8b6c4c2 100644
return;
}
}
-@@ -527,7 +527,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, close)
+@@ -527,7 +520,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, close)
{
object_intern *intern;
@@ -908,7 +1220,7 @@ index 5ee209a..8b6c4c2 100644
if (!intern) {
return;
}
-@@ -555,17 +555,17 @@ PHP_METHOD(RdKafka__KafkaConsumer, getMetadata)
+@@ -555,17 +548,17 @@ PHP_METHOD(RdKafka__KafkaConsumer, getMetadata)
const rd_kafka_metadata_t *metadata;
kafka_topic_object *only_orkt = NULL;
@@ -929,7 +1241,7 @@ index 5ee209a..8b6c4c2 100644
if (!only_orkt) {
return;
}
-@@ -574,11 +574,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getMetadata)
+@@ -574,11 +567,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getMetadata)
err = rd_kafka_metadata(intern->rk, all_topics, only_orkt ? only_orkt->rkt : NULL, &metadata, timeout_ms);
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -943,7 +1255,16 @@ index 5ee209a..8b6c4c2 100644
}
/* }}} */
-@@ -601,17 +601,17 @@ PHP_METHOD(RdKafka__KafkaConsumer, newTopic)
+@@ -593,7 +586,7 @@ ZEND_END_ARG_INFO()
+ PHP_METHOD(RdKafka__KafkaConsumer, newTopic)
+ {
+ char *topic;
+- arglen_t topic_len;
++ size_t topic_len;
+ rd_kafka_topic_t *rkt;
+ object_intern *intern;
+ kafka_topic_object *topic_intern;
+@@ -601,17 +594,17 @@ PHP_METHOD(RdKafka__KafkaConsumer, newTopic)
rd_kafka_topic_conf_t *conf = NULL;
kafka_conf_object *conf_intern;
@@ -964,7 +1285,16 @@ index 5ee209a..8b6c4c2 100644
if (conf_intern) {
conf = rd_kafka_topic_conf_dup(conf_intern->u.topic_conf);
}
-@@ -652,16 +652,16 @@ PHP_METHOD(RdKafka__KafkaConsumer, getCommittedOffsets)
+@@ -627,7 +620,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, newTopic)
+ return;
+ }
+
+- topic_intern = get_custom_object_zval(kafka_topic_object, return_value);
++ topic_intern = Z_RDKAFKA_P(kafka_topic_object, return_value);
+ if (!topic_intern) {
+ return;
+ }
+@@ -652,16 +645,16 @@ PHP_METHOD(RdKafka__KafkaConsumer, getCommittedOffsets)
rd_kafka_resp_err_t err;
rd_kafka_topic_partition_list_t *topics;
@@ -984,7 +1314,7 @@ index 5ee209a..8b6c4c2 100644
if (!topics) {
return;
}
-@@ -670,10 +670,10 @@ PHP_METHOD(RdKafka__KafkaConsumer, getCommittedOffsets)
+@@ -670,10 +663,10 @@ PHP_METHOD(RdKafka__KafkaConsumer, getCommittedOffsets)
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
rd_kafka_topic_partition_list_destroy(topics);
@@ -997,7 +1327,7 @@ index 5ee209a..8b6c4c2 100644
rd_kafka_topic_partition_list_destroy(topics);
}
/* }}} */
-@@ -694,16 +694,16 @@ PHP_METHOD(RdKafka__KafkaConsumer, getOffsetPositions)
+@@ -694,16 +687,16 @@ PHP_METHOD(RdKafka__KafkaConsumer, getOffsetPositions)
rd_kafka_resp_err_t err;
rd_kafka_topic_partition_list_t *topics;
@@ -1017,7 +1347,7 @@ index 5ee209a..8b6c4c2 100644
if (!topics) {
return;
}
-@@ -712,10 +712,10 @@ PHP_METHOD(RdKafka__KafkaConsumer, getOffsetPositions)
+@@ -712,10 +705,10 @@ PHP_METHOD(RdKafka__KafkaConsumer, getOffsetPositions)
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
rd_kafka_topic_partition_list_destroy(topics);
@@ -1030,7 +1360,7 @@ index 5ee209a..8b6c4c2 100644
rd_kafka_topic_partition_list_destroy(topics);
}
/* }}} */
-@@ -734,16 +734,16 @@ PHP_METHOD(RdKafka__KafkaConsumer, offsetsForTimes)
+@@ -734,16 +727,16 @@ PHP_METHOD(RdKafka__KafkaConsumer, offsetsForTimes)
zend_long timeout_ms;
rd_kafka_resp_err_t err;
@@ -1050,7 +1380,7 @@ index 5ee209a..8b6c4c2 100644
if (!topicPartitions) {
return;
}
-@@ -752,10 +752,10 @@ PHP_METHOD(RdKafka__KafkaConsumer, offsetsForTimes)
+@@ -752,10 +745,10 @@ PHP_METHOD(RdKafka__KafkaConsumer, offsetsForTimes)
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
rd_kafka_topic_partition_list_destroy(topicPartitions);
@@ -1063,7 +1393,14 @@ index 5ee209a..8b6c4c2 100644
rd_kafka_topic_partition_list_destroy(topicPartitions);
}
/* }}} */
-@@ -781,14 +781,14 @@ PHP_METHOD(RdKafka__KafkaConsumer, queryWatermarkOffsets)
+@@ -775,20 +768,20 @@ PHP_METHOD(RdKafka__KafkaConsumer, queryWatermarkOffsets)
+ {
+ object_intern *intern;
+ char *topic;
+- arglen_t topic_length;
++ size_t topic_length;
+ long low, high;
+ zend_long partition, timeout;
zval *lowResult, *highResult;
rd_kafka_resp_err_t err;
@@ -1072,15 +1409,17 @@ index 5ee209a..8b6c4c2 100644
return;
}
- ZEVAL_DEREF(lowResult);
- ZEVAL_DEREF(highResult);
+- ZEVAL_DEREF(lowResult);
+- ZEVAL_DEREF(highResult);
++ ZVAL_DEREF(lowResult);
++ ZVAL_DEREF(highResult);
- intern = get_object(getThis() TSRMLS_CC);
+ intern = get_object(getThis());
if (!intern) {
return;
}
-@@ -796,7 +796,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, queryWatermarkOffsets)
+@@ -796,7 +789,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, queryWatermarkOffsets)
err = rd_kafka_query_watermark_offsets(intern->rk, topic, partition, &low, &high, timeout);
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -1089,12 +1428,12 @@ index 5ee209a..8b6c4c2 100644
return;
}
-@@ -825,19 +825,19 @@ static const zend_function_entry fe[] = { /* {{{ */
+@@ -825,19 +818,19 @@ static const zend_function_entry fe[] = { /* {{{ */
PHP_FE_END
}; /* }}} */
-void kafka_kafka_consumer_minit(TSRMLS_D) /* {{{ */
-+void kafka_kafka_consumer_minit() /* {{{ */
++void kafka_kafka_consumer_minit(INIT_FUNC_ARGS) /* {{{ */
{
zend_class_entry tmpce;
@@ -1104,8 +1443,10 @@ index 5ee209a..8b6c4c2 100644
ce->create_object = kafka_consumer_new;
handlers = kafka_default_object_handlers;
- set_object_handler_free_obj(&handlers, kafka_consumer_free);
- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
+- set_object_handler_free_obj(&handlers, kafka_consumer_free);
+- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
++ handlers.free_obj = kafka_consumer_free;
++ handlers.offset = XtOffsetOf(object_intern, std);
- zend_declare_property_null(ce, ZEND_STRL("error_cb"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(ce, ZEND_STRL("rebalance_cb"), ZEND_ACC_PRIVATE TSRMLS_CC);
@@ -1115,7 +1456,7 @@ index 5ee209a..8b6c4c2 100644
+ zend_declare_property_null(ce, ZEND_STRL("dr_msg_cb"), ZEND_ACC_PRIVATE);
} /* }}} */
diff --git a/kafka_consumer.h b/kafka_consumer.h
-index 6e86784..0ac97f3 100644
+index 6e86784..cc4be66 100644
--- a/kafka_consumer.h
+++ b/kafka_consumer.h
@@ -16,4 +16,4 @@
@@ -1123,12 +1464,16 @@ index 6e86784..0ac97f3 100644
*/
-void kafka_kafka_consumer_minit(TSRMLS_D);
-+void kafka_kafka_consumer_minit();
++void kafka_kafka_consumer_minit(INIT_FUNC_ARGS);
diff --git a/kafka_error_exception.c b/kafka_error_exception.c
-index ee1f8b5..ea3bdba 100644
+index a19527a..19b881c 100644
--- a/kafka_error_exception.c
+++ b/kafka_error_exception.c
-@@ -30,16 +30,16 @@
+@@ -27,20 +27,19 @@
+ #include "Zend/zend_interfaces.h"
+ #include "Zend/zend_exceptions.h"
+ #include "kafka_error_exception.h"
+-#include "zeval.h"
zend_class_entry * ce_kafka_error;
@@ -1143,16 +1488,21 @@ index ee1f8b5..ea3bdba 100644
- zend_update_property_bool(ce_kafka_error, return_value, ZEND_STRL("isFatal"), rd_kafka_error_is_fatal(error) TSRMLS_CC);
- zend_update_property_bool(ce_kafka_error, return_value, ZEND_STRL("isRetriable"), rd_kafka_error_is_retriable(error) TSRMLS_CC);
- zend_update_property_bool(ce_kafka_error, return_value, ZEND_STRL("transactionRequiresAbort"), rd_kafka_error_txn_requires_abort(error) TSRMLS_CC);
-+ zend_update_property_string(ce_kafka_error, return_value, ZEND_STRL("message"), rd_kafka_error_name(error));
-+ zend_update_property_long(ce_kafka_error, return_value, ZEND_STRL("code"), rd_kafka_error_code(error));
-+ zend_update_property_string(ce_kafka_error, return_value, ZEND_STRL("error_string"), rd_kafka_error_string(error));
-+ zend_update_property_bool(ce_kafka_error, return_value, ZEND_STRL("isFatal"), rd_kafka_error_is_fatal(error));
-+ zend_update_property_bool(ce_kafka_error, return_value, ZEND_STRL("isRetriable"), rd_kafka_error_is_retriable(error));
-+ zend_update_property_bool(ce_kafka_error, return_value, ZEND_STRL("transactionRequiresAbort"), rd_kafka_error_txn_requires_abort(error));
++ zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("message"), rd_kafka_error_name(error));
++ zend_update_property_long(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("code"), rd_kafka_error_code(error));
++ zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("error_string"), rd_kafka_error_string(error));
++ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("isFatal"), rd_kafka_error_is_fatal(error));
++ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("isRetriable"), rd_kafka_error_is_retriable(error));
++ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("transactionRequiresAbort"), rd_kafka_error_txn_requires_abort(error));
Z_ADDREF_P(return_value);
}
-@@ -62,16 +62,16 @@ PHP_METHOD(RdKafka__KafkaErrorException, __construct)
+@@ -59,20 +58,20 @@ ZEND_END_ARG_INFO()
+ PHP_METHOD(RdKafka__KafkaErrorException, __construct)
+ {
+ char *message, *error_string = "";
+- arglen_t message_length = 0, error_string_length = 0;
++ size_t message_length = 0, error_string_length = 0;
zend_bool isFatal = 0, isRetriable = 0, transactionRequiresAbort = 0;
zend_long code = 0;
@@ -1167,16 +1517,16 @@ index ee1f8b5..ea3bdba 100644
- zend_update_property_bool(ce_kafka_error, getThis(), ZEND_STRL("isFatal"), isFatal TSRMLS_CC);
- zend_update_property_bool(ce_kafka_error, getThis(), ZEND_STRL("isRetriable"), isRetriable TSRMLS_CC);
- zend_update_property_bool(ce_kafka_error, getThis(), ZEND_STRL("transactionRequiresAbort"), transactionRequiresAbort TSRMLS_CC);
-+ zend_update_property_string(ce_kafka_error, getThis(), ZEND_STRL("message"), message);
-+ zend_update_property_long(ce_kafka_error, getThis(), ZEND_STRL("code"), code);
-+ zend_update_property_string(ce_kafka_error, getThis(), ZEND_STRL("error_string"), error_string);
-+ zend_update_property_bool(ce_kafka_error, getThis(), ZEND_STRL("isFatal"), isFatal);
-+ zend_update_property_bool(ce_kafka_error, getThis(), ZEND_STRL("isRetriable"), isRetriable);
-+ zend_update_property_bool(ce_kafka_error, getThis(), ZEND_STRL("transactionRequiresAbort"), transactionRequiresAbort);
++ zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("message"), message);
++ zend_update_property_long(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("code"), code);
++ zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("error_string"), error_string);
++ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isFatal"), isFatal);
++ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isRetriable"), isRetriable);
++ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("transactionRequiresAbort"), transactionRequiresAbort);
}
/* }}} */
-@@ -85,11 +85,11 @@ PHP_METHOD(RdKafka__KafkaErrorException, getErrorString)
+@@ -86,22 +85,18 @@ PHP_METHOD(RdKafka__KafkaErrorException, getErrorString)
{
zval *res;
@@ -1186,11 +1536,22 @@ index ee1f8b5..ea3bdba 100644
}
- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("error_string"), 0 TSRMLS_CC);
-+ res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("error_string"), 0);
++ res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("error_string"), 0);
if (!res || Z_TYPE_P(res) != IS_STRING) {
return;
-@@ -115,11 +115,11 @@ PHP_METHOD(RdKafka__KafkaErrorException, isFatal)
+ }
+
+-#if PHP_MAJOR_VERSION >= 7
+ ZVAL_DEREF(res);
+ ZVAL_COPY(return_value, res);
+-#else
+- RETURN_ZVAL(res, 1, 0)
+-#endif
+ }
+ /* }}} */
+
+@@ -116,22 +111,18 @@ PHP_METHOD(RdKafka__KafkaErrorException, isFatal)
{
zval *res;
@@ -1200,11 +1561,22 @@ index ee1f8b5..ea3bdba 100644
}
- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("isFatal"), 0 TSRMLS_CC);
-+ res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("isFatal"), 0);
++ res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isFatal"), 0);
- #if PHP_MAJOR_VERSION >= 7
+-#if PHP_MAJOR_VERSION >= 7
if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) {
-@@ -144,11 +144,11 @@ PHP_METHOD(RdKafka__KafkaErrorException, isRetriable)
+ return;
+ }
+
+ ZVAL_DEREF(res);
+ ZVAL_COPY(return_value, res);
+-#else
+- RETURN_ZVAL(res, 1, 0)
+-#endif
+ }
+ /* }}} */
+
+@@ -145,22 +136,18 @@ PHP_METHOD(RdKafka__KafkaErrorException, isRetriable)
{
zval *res;
@@ -1214,11 +1586,22 @@ index ee1f8b5..ea3bdba 100644
}
- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("isRetriable"), 0 TSRMLS_CC);
-+ res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("isRetriable"), 0);
++ res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isRetriable"), 0);
- #if PHP_MAJOR_VERSION >= 7
+-#if PHP_MAJOR_VERSION >= 7
if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) {
-@@ -173,11 +173,11 @@ PHP_METHOD(RdKafka__KafkaErrorException, transactionRequiresAbort)
+ return;
+ }
+
+ ZVAL_DEREF(res);
+ ZVAL_COPY(return_value, res);
+-#else
+- RETURN_ZVAL(res, 1, 0)
+-#endif
+ }
+ /* }}} */
+
+@@ -174,22 +161,18 @@ PHP_METHOD(RdKafka__KafkaErrorException, transactionRequiresAbort)
{
zval *res;
@@ -1228,11 +1611,22 @@ index ee1f8b5..ea3bdba 100644
}
- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("transactionRequiresAbort"), 0 TSRMLS_CC);
-+ res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("transactionRequiresAbort"), 0);
++ res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("transactionRequiresAbort"), 0);
- #if PHP_MAJOR_VERSION >= 7
+-#if PHP_MAJOR_VERSION >= 7
if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) {
-@@ -201,15 +201,15 @@ static const zend_function_entry kafka_error_fe[] = { /* {{{ */
+ return;
+ }
+
+ ZVAL_DEREF(res);
+ ZVAL_COPY(return_value, res);
+-#else
+- RETURN_ZVAL(res, 1, 0)
+-#endif
+ }
+ /* }}} */
+
+@@ -202,17 +185,17 @@ static const zend_function_entry kafka_error_fe[] = { /* {{{ */
PHP_FE_END
}; /* }}} */
@@ -1243,7 +1637,7 @@ index ee1f8b5..ea3bdba 100644
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "KafkaErrorException", kafka_error_fe);
- ce_kafka_error = rdkafka_register_internal_class_ex(&ce, ce_kafka_exception TSRMLS_CC);
-+ ce_kafka_error = rdkafka_register_internal_class_ex(&ce, ce_kafka_exception);
++ ce_kafka_error = zend_register_internal_class_ex(&ce, ce_kafka_exception);
- zend_declare_property_null(ce_kafka_error, ZEND_STRL("error_string"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_bool(ce_kafka_error, ZEND_STRL("isFatal"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
@@ -1254,13 +1648,23 @@ index ee1f8b5..ea3bdba 100644
+ zend_declare_property_bool(ce_kafka_error, ZEND_STRL("isRetriable"), 0, ZEND_ACC_PRIVATE);
+ zend_declare_property_bool(ce_kafka_error, ZEND_STRL("transactionRequiresAbort"), 0, ZEND_ACC_PRIVATE);
} /* }}} */
+ #endif
+
diff --git a/kafka_error_exception.h b/kafka_error_exception.h
-index 71ad2f3..12068a6 100644
+index 71ad2f3..d44b895 100644
--- a/kafka_error_exception.h
+++ b/kafka_error_exception.h
-@@ -20,6 +20,6 @@
- #include "zeval.h"
+@@ -15,11 +15,13 @@
+ | Author: Arnaud Le Blanc <arnaud.lb@gmail.com> |
+ +----------------------------------------------------------------------+
+ */
++
+ #ifdef HAS_RD_KAFKA_TRANSACTIONS
+
+-#include "zeval.h"
#include "librdkafka/rdkafka.h"
++#include "Zend/zend_interfaces.h"
++
extern zend_class_entry * ce_kafka_error;
-void kafka_error_minit(TSRMLS_D);
-void create_kafka_error(zval *return_value, const rd_kafka_error_t *error TSRMLS_DC);
@@ -1268,7 +1672,7 @@ index 71ad2f3..12068a6 100644
+void create_kafka_error(zval *return_value, const rd_kafka_error_t *error);
#endif
diff --git a/message.c b/message.c
-index f3911f9..c09bc26 100644
+index f3911f9..f4c4c7f 100644
--- a/message.c
+++ b/message.c
@@ -32,7 +32,7 @@
@@ -1285,37 +1689,40 @@ index f3911f9..c09bc26 100644
#endif /* HAVE_RD_KAFKA_MESSAGE_HEADERS */
- zend_update_property_long(NULL, return_value, ZEND_STRL("err"), message->err TSRMLS_CC);
-+ zend_update_property_long(NULL, return_value, ZEND_STRL("err"), message->err);
++ zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("err"), message->err);
if (message->rkt) {
- zend_update_property_string(NULL, return_value, ZEND_STRL("topic_name"), rd_kafka_topic_name(message->rkt) TSRMLS_CC);
-+ zend_update_property_string(NULL, return_value, ZEND_STRL("topic_name"), rd_kafka_topic_name(message->rkt));
++ zend_update_property_string(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("topic_name"), rd_kafka_topic_name(message->rkt));
}
- zend_update_property_long(NULL, return_value, ZEND_STRL("partition"), message->partition TSRMLS_CC);
-+ zend_update_property_long(NULL, return_value, ZEND_STRL("partition"), message->partition);
++ zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("partition"), message->partition);
if (message->payload) {
- zend_update_property_long(NULL, return_value, ZEND_STRL("timestamp"), timestamp TSRMLS_CC);
- zend_update_property_stringl(NULL, return_value, ZEND_STRL("payload"), message->payload, message->len TSRMLS_CC);
- zend_update_property_long(NULL, return_value, ZEND_STRL("len"), message->len TSRMLS_CC);
-+ zend_update_property_long(NULL, return_value, ZEND_STRL("timestamp"), timestamp);
-+ zend_update_property_stringl(NULL, return_value, ZEND_STRL("payload"), message->payload, message->len);
-+ zend_update_property_long(NULL, return_value, ZEND_STRL("len"), message->len);
++ zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("timestamp"), timestamp);
++ zend_update_property_stringl(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("payload"), message->payload, message->len);
++ zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("len"), message->len);
}
if (message->key) {
- zend_update_property_stringl(NULL, return_value, ZEND_STRL("key"), message->key, message->key_len TSRMLS_CC);
-+ zend_update_property_stringl(NULL, return_value, ZEND_STRL("key"), message->key, message->key_len);
++ zend_update_property_stringl(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("key"), message->key, message->key_len);
}
- zend_update_property_long(NULL, return_value, ZEND_STRL("offset"), message->offset TSRMLS_CC);
-+ zend_update_property_long(NULL, return_value, ZEND_STRL("offset"), message->offset);
++ zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("offset"), message->offset);
#ifdef HAVE_RD_KAFKA_MESSAGE_HEADERS
if (message->err == RD_KAFKA_RESP_ERR_NO_ERROR) {
-@@ -79,14 +79,14 @@ void kafka_message_new(zval *return_value, const rd_kafka_message_t *message TSR
+@@ -77,28 +77,28 @@ void kafka_message_new(zval *return_value, const rd_kafka_message_t *message TSR
+ if (header_response != RD_KAFKA_RESP_ERR_NO_ERROR) {
+ break;
}
- rdkafka_add_assoc_stringl(&headers_array, header_name, (const char*)header_value, header_size);
+- rdkafka_add_assoc_stringl(&headers_array, header_name, (const char*)header_value, header_size);
++ add_assoc_stringl(&headers_array, header_name, (const char*)header_value, header_size);
}
- zend_update_property(NULL, return_value, ZEND_STRL("headers"), &headers_array TSRMLS_CC);
-+ zend_update_property(NULL, return_value, ZEND_STRL("headers"), &headers_array);
++ zend_update_property(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("headers"), &headers_array);
zval_ptr_dtor(&headers_array);
}
}
@@ -1326,16 +1733,23 @@ index f3911f9..c09bc26 100644
+void kafka_message_list_to_array(zval *return_value, rd_kafka_message_t **messages, long size) /* {{{ */
{
rd_kafka_message_t *msg;
- zeval zmsg;
-@@ -97,7 +97,7 @@ void kafka_message_list_to_array(zval *return_value, rd_kafka_message_t **messag
+- zeval zmsg;
++ zval zmsg;
+ int i;
+
+ array_init_size(return_value, size);
+
for (i = 0; i < size; i++) {
msg = messages[i];
- MAKE_STD_ZEVAL(zmsg);
+- MAKE_STD_ZEVAL(zmsg);
- kafka_message_new(P_ZEVAL(zmsg), msg TSRMLS_CC);
-+ kafka_message_new(P_ZEVAL(zmsg), msg);
- add_next_index_zval(return_value, P_ZEVAL(zmsg));
+- add_next_index_zval(return_value, P_ZEVAL(zmsg));
++ ZVAL_NULL(&zmsg);
++ kafka_message_new(&zmsg, msg);
++ add_next_index_zval(return_value, &zmsg);
}
} /* }}} */
+
@@ -115,11 +115,11 @@ PHP_METHOD(RdKafka__Message, errstr)
zval *zpayload;
const char *errstr;
@@ -1346,16 +1760,20 @@ index f3911f9..c09bc26 100644
}
- zerr = rdkafka_read_property(NULL, getThis(), ZEND_STRL("err"), 0 TSRMLS_CC);
-+ zerr = rdkafka_read_property(NULL, getThis(), ZEND_STRL("err"), 0);
++ zerr = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("err"), 0);
if (!zerr || Z_TYPE_P(zerr) != IS_LONG) {
return;
-@@ -131,7 +131,7 @@ PHP_METHOD(RdKafka__Message, errstr)
- RDKAFKA_RETURN_STRING(errstr);
+@@ -128,10 +128,10 @@ PHP_METHOD(RdKafka__Message, errstr)
+ errstr = rd_kafka_err2str(Z_LVAL_P(zerr));
+
+ if (errstr) {
+- RDKAFKA_RETURN_STRING(errstr);
++ RETURN_STRING(errstr);
}
- zpayload = rdkafka_read_property(NULL, getThis(), ZEND_STRL("payload"), 0 TSRMLS_CC);
-+ zpayload = rdkafka_read_property(NULL, getThis(), ZEND_STRL("payload"), 0);
++ zpayload = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("payload"), 0);
if (zpayload && Z_TYPE_P(zpayload) == IS_STRING) {
RETURN_ZVAL(zpayload, 1, 0);
@@ -1364,7 +1782,7 @@ index f3911f9..c09bc26 100644
};
-void kafka_message_minit(TSRMLS_D) { /* {{{ */
-+void kafka_message_minit() { /* {{{ */
++void kafka_message_minit(INIT_FUNC_ARGS) { /* {{{ */
zend_class_entry ce;
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Message", kafka_message_fe);
@@ -1394,7 +1812,7 @@ index f3911f9..c09bc26 100644
#endif
} /* }}} */
diff --git a/message.h b/message.h
-index 28d75fb..5db24ce 100644
+index 28d75fb..3a0f701 100644
--- a/message.h
+++ b/message.h
@@ -16,8 +16,8 @@
@@ -1404,35 +1822,47 @@ index 28d75fb..5db24ce 100644
-void kafka_message_minit(TSRMLS_D);
-void kafka_message_new(zval *return_value, const rd_kafka_message_t *message TSRMLS_DC);
-void kafka_message_list_to_array(zval *return_value, rd_kafka_message_t **messages, long size TSRMLS_DC);
-+void kafka_message_minit();
++void kafka_message_minit(INIT_FUNC_ARGS);
+void kafka_message_new(zval *return_value, const rd_kafka_message_t *message);
+void kafka_message_list_to_array(zval *return_value, rd_kafka_message_t **messages, long size);
extern zend_class_entry * ce_kafka_message;
diff --git a/metadata.c b/metadata.c
-index e8baca7..86cdbf5 100644
+index e8baca7..4d3f12d 100644
--- a/metadata.c
+++ b/metadata.c
-@@ -41,22 +41,22 @@ typedef struct _object_intern {
- #endif
+@@ -29,101 +29,93 @@
+ #include "metadata_broker.h"
+ #include "metadata_partition.h"
+ #include "Zend/zend_exceptions.h"
+-#include "zeval.h"
+
+ typedef struct _object_intern {
+-#if PHP_MAJOR_VERSION < 7
+- zend_object std;
+-#endif
+ const rd_kafka_metadata_t *metadata;
+-#if PHP_MAJOR_VERSION >= 7
+ zend_object std;
+-#endif
} object_intern;
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC);
-+static HashTable *get_debug_info(zval *object, int *is_temp);
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
static zend_class_entry * ce;
static zend_object_handlers handlers;
-static void brokers_collection(zval *return_value, zval *parent, object_intern *intern TSRMLS_DC) { /* {{{ */
- kafka_metadata_collection_init(return_value, parent, intern->metadata->brokers, intern->metadata->broker_cnt, sizeof(*intern->metadata->brokers), kafka_metadata_broker_ctor TSRMLS_CC);
-+static void brokers_collection(zval *return_value, zval *parent, object_intern *intern) { /* {{{ */
++static void brokers_collection(zval *return_value, Z_RDKAFKA_OBJ *parent, object_intern *intern) { /* {{{ */
+ kafka_metadata_collection_init(return_value, parent, intern->metadata->brokers, intern->metadata->broker_cnt, sizeof(*intern->metadata->brokers), kafka_metadata_broker_ctor);
}
/* }}} */
-static void topics_collection(zval *return_value, zval *parent, object_intern *intern TSRMLS_DC) { /* {{{ */
- kafka_metadata_collection_init(return_value, parent, intern->metadata->topics, intern->metadata->topic_cnt, sizeof(*intern->metadata->topics), kafka_metadata_topic_ctor TSRMLS_CC);
-+static void topics_collection(zval *return_value, zval *parent, object_intern *intern) { /* {{{ */
++static void topics_collection(zval *return_value, Z_RDKAFKA_OBJ *parent, object_intern *intern) { /* {{{ */
+ kafka_metadata_collection_init(return_value, parent, intern->metadata->topics, intern->metadata->topic_cnt, sizeof(*intern->metadata->topics), kafka_metadata_topic_ctor);
}
/* }}} */
@@ -1440,39 +1870,47 @@ index e8baca7..86cdbf5 100644
-static void kafka_metadata_free(zend_object *object TSRMLS_DC) /* {{{ */
+static void kafka_metadata_free(zend_object *object) /* {{{ */
{
- object_intern *intern = get_custom_object(object_intern, object);
+- object_intern *intern = get_custom_object(object_intern, object);
++ object_intern *intern = php_kafka_from_obj(object_intern, object);
-@@ -64,19 +64,19 @@ static void kafka_metadata_free(zend_object *object TSRMLS_DC) /* {{{ */
+ if (intern->metadata) {
rd_kafka_metadata_destroy(intern->metadata);
}
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+-
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
/* }}} */
-static zend_object_value kafka_metadata_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value kafka_metadata_new(zend_class_entry *class_type) /* {{{ */
++static zend_object *kafka_metadata_new(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
object_intern *intern;
- intern = alloc_object(intern, class_type);
+- intern = alloc_object(intern, class_type);
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
++ intern = zend_object_alloc(sizeof(*intern), class_type);
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_metadata_free, NULL);
-@@ -86,19 +86,19 @@ static zend_object_value kafka_metadata_new(zend_class_entry *class_type TSRMLS_
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_metadata_free, NULL);
+- SET_OBJECT_HANDLERS(retval, &handlers);
++ retval = &intern->std;
++ retval->handlers = &handlers;
+
+ return retval;
}
/* }}} */
-static object_intern * get_object(zval *zmetadata TSRMLS_DC)
+static object_intern * get_object(zval *zmetadata)
{
- object_intern *ometadata = get_custom_object_zval(object_intern, zmetadata);
+- object_intern *ometadata = get_custom_object_zval(object_intern, zmetadata);
++ object_intern *ometadata = Z_RDKAFKA_P(object_intern, zmetadata);
if (!ometadata->metadata) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Metadata::__construct() has not been called");
@@ -1484,32 +1922,46 @@ index e8baca7..86cdbf5 100644
}
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
-+static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
{
zval ary;
object_intern *intern;
-@@ -109,17 +109,17 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
+- zeval brokers;
+- zeval topics;
++ zval brokers;
++ zval topics;
+
+ *is_temp = 1;
array_init(&ary);
- intern = get_object(object TSRMLS_CC);
-+ intern = get_object(object);
++ intern = rdkafka_get_debug_object(object_intern, object);
if (!intern) {
return Z_ARRVAL(ary);
}
- MAKE_STD_ZEVAL(brokers);
+- MAKE_STD_ZEVAL(brokers);
- brokers_collection(P_ZEVAL(brokers), object, intern TSRMLS_CC);
-+ brokers_collection(P_ZEVAL(brokers), object, intern);
- add_assoc_zval(&ary, "brokers", P_ZEVAL(brokers));
+- add_assoc_zval(&ary, "brokers", P_ZEVAL(brokers));
++ ZVAL_NULL(&brokers);
++ brokers_collection(&brokers, object, intern);
++ add_assoc_zval(&ary, "brokers", &brokers);
- MAKE_STD_ZEVAL(topics);
+- MAKE_STD_ZEVAL(topics);
- topics_collection(P_ZEVAL(topics), object, intern TSRMLS_CC);
-+ topics_collection(P_ZEVAL(topics), object, intern);
- add_assoc_zval(&ary, "topics", P_ZEVAL(topics));
+- add_assoc_zval(&ary, "topics", P_ZEVAL(topics));
++ ZVAL_NULL(&topics);
++ topics_collection(&topics, object, intern);
++ add_assoc_zval(&ary, "topics", &topics);
add_assoc_long(&ary, "orig_broker_id", intern->metadata->orig_broker_id);
-@@ -143,7 +143,7 @@ PHP_METHOD(RdKafka__Metadata, getOrigBrokerId)
+- rdkafka_add_assoc_string(&ary, "orig_broker_name", intern->metadata->orig_broker_name);
++ add_assoc_string(&ary, "orig_broker_name", intern->metadata->orig_broker_name);
+
+ return Z_ARRVAL(ary);
+ }
+@@ -143,7 +135,7 @@ PHP_METHOD(RdKafka__Metadata, getOrigBrokerId)
return;
}
@@ -1518,7 +1970,7 @@ index e8baca7..86cdbf5 100644
if (!intern) {
return;
}
-@@ -166,7 +166,7 @@ PHP_METHOD(RdKafka__Metadata, getOrigBrokerName)
+@@ -166,12 +158,12 @@ PHP_METHOD(RdKafka__Metadata, getOrigBrokerName)
return;
}
@@ -1527,7 +1979,13 @@ index e8baca7..86cdbf5 100644
if (!intern) {
return;
}
-@@ -189,12 +189,12 @@ PHP_METHOD(RdKafka__Metadata, getBrokers)
+
+- RDKAFKA_RETURN_STRING(intern->metadata->orig_broker_name);
++ RETURN_STRING(intern->metadata->orig_broker_name);
+ }
+ /* }}} */
+
+@@ -189,12 +181,12 @@ PHP_METHOD(RdKafka__Metadata, getBrokers)
return;
}
@@ -1538,11 +1996,11 @@ index e8baca7..86cdbf5 100644
}
- brokers_collection(return_value, getThis(), intern TSRMLS_CC);
-+ brokers_collection(return_value, getThis(), intern);
++ brokers_collection(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern);
}
/* }}} */
-@@ -212,12 +212,12 @@ PHP_METHOD(RdKafka__Metadata, getTopics)
+@@ -212,12 +204,12 @@ PHP_METHOD(RdKafka__Metadata, getTopics)
return;
}
@@ -1553,16 +2011,16 @@ index e8baca7..86cdbf5 100644
}
- topics_collection(return_value, getThis(), intern TSRMLS_CC);
-+ topics_collection(return_value, getThis(), intern);
++ topics_collection(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern);
}
/* }}} */
-@@ -229,12 +229,12 @@ static const zend_function_entry kafka_metadata_fe[] = {
+@@ -229,26 +221,26 @@ static const zend_function_entry kafka_metadata_fe[] = {
PHP_FE_END
};
-void kafka_metadata_minit(TSRMLS_D)
-+void kafka_metadata_minit()
++void kafka_metadata_minit(INIT_FUNC_ARGS)
{
zend_class_entry tmpce;
@@ -1572,18 +2030,20 @@ index e8baca7..86cdbf5 100644
ce->create_object = kafka_metadata_new;
handlers = kafka_default_object_handlers;
-@@ -242,13 +242,13 @@ void kafka_metadata_minit(TSRMLS_D)
- set_object_handler_free_obj(&handlers, kafka_metadata_free);
- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
+ handlers.get_debug_info = get_debug_info;
+- set_object_handler_free_obj(&handlers, kafka_metadata_free);
+- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
++ handlers.free_obj = kafka_metadata_free;
++ handlers.offset = XtOffsetOf(object_intern, std);
- kafka_metadata_topic_minit(TSRMLS_C);
- kafka_metadata_broker_minit(TSRMLS_C);
- kafka_metadata_partition_minit(TSRMLS_C);
- kafka_metadata_collection_minit(TSRMLS_C);
-+ kafka_metadata_topic_minit();
-+ kafka_metadata_broker_minit();
-+ kafka_metadata_partition_minit();
-+ kafka_metadata_collection_minit();
++ kafka_metadata_topic_minit(INIT_FUNC_ARGS_PASSTHRU);
++ kafka_metadata_broker_minit(INIT_FUNC_ARGS_PASSTHRU);
++ kafka_metadata_partition_minit(INIT_FUNC_ARGS_PASSTHRU);
++ kafka_metadata_collection_minit(INIT_FUNC_ARGS_PASSTHRU);
}
-void kafka_metadata_init(zval *return_value, const rd_kafka_metadata_t *metadata TSRMLS_DC)
@@ -1591,8 +2051,17 @@ index e8baca7..86cdbf5 100644
{
object_intern *intern;
+@@ -256,7 +248,7 @@ void kafka_metadata_init(zval *return_value, const rd_kafka_metadata_t *metadata
+ return;
+ }
+
+- intern = get_custom_object_zval(object_intern, return_value);
++ intern = Z_RDKAFKA_P(object_intern, return_value);
+ if (!intern) {
+ return;
+ }
diff --git a/metadata.h b/metadata.h
-index 074816f..b68592b 100644
+index 074816f..d09d2db 100644
--- a/metadata.h
+++ b/metadata.h
@@ -16,5 +16,5 @@
@@ -1601,18 +2070,31 @@ index 074816f..b68592b 100644
-void kafka_metadata_minit(TSRMLS_D);
-void kafka_metadata_init(zval *return_value, const rd_kafka_metadata_t *metadata TSRMLS_DC);
-+void kafka_metadata_minit();
++void kafka_metadata_minit(INIT_FUNC_ARGS);
+void kafka_metadata_init(zval *return_value, const rd_kafka_metadata_t *metadata);
diff --git a/metadata_broker.c b/metadata_broker.c
-index 89655a5..540b278 100644
+index 89655a5..b964231 100644
--- a/metadata_broker.c
+++ b/metadata_broker.c
-@@ -40,12 +40,12 @@ typedef struct _object_intern {
- #endif
+@@ -27,68 +27,59 @@
+ #include "ext/spl/spl_iterators.h"
+ #include "Zend/zend_interfaces.h"
+ #include "Zend/zend_exceptions.h"
+-#include "zeval.h"
+
+ typedef struct _object_intern {
+-#if PHP_MAJOR_VERSION < 7
+- zend_object std;
+-#endif
+ zval zmetadata;
+ const rd_kafka_metadata_broker_t *metadata_broker;
+-#if PHP_MAJOR_VERSION >= 7
+ zend_object std;
+-#endif
} object_intern;
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC);
-+static HashTable *get_debug_info(zval *object, int *is_temp);
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
static zend_class_entry * ce;
static zend_object_handlers handlers;
@@ -1620,39 +2102,48 @@ index 89655a5..540b278 100644
-static void free_object(zend_object *object TSRMLS_DC) /* {{{ */
+static void free_object(zend_object *object) /* {{{ */
{
- object_intern *intern = get_custom_object(object_intern, object);
+- object_intern *intern = get_custom_object(object_intern, object);
++ object_intern *intern = php_kafka_from_obj(object_intern, object);
-@@ -53,19 +53,19 @@ static void free_object(zend_object *object TSRMLS_DC) /* {{{ */
+ if (intern->metadata_broker) {
zval_dtor(&intern->zmetadata);
}
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+-
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
/* }}} */
-static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value create_object(zend_class_entry *class_type) /* {{{ */
++static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
object_intern *intern;
- intern = alloc_object(intern, class_type);
+- intern = alloc_object(intern, class_type);
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
++ intern = zend_object_alloc(sizeof(*intern), class_type);
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
+-
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
+- SET_OBJECT_HANDLERS(retval, &handlers);
++ retval = &intern->std;
++ retval->handlers = &handlers;
-@@ -76,19 +76,19 @@ static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) /
+ return retval;
}
/* }}} */
-static object_intern * get_object(zval *zmt TSRMLS_DC)
+static object_intern * get_object(zval *zmt)
{
- object_intern *omt = get_custom_object_zval(object_intern, zmt);
+- object_intern *omt = get_custom_object_zval(object_intern, zmt);
++ object_intern *omt = Z_RDKAFKA_P(object_intern, zmt);
if (!omt->metadata_broker) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Metadata\\Broker::__construct() has not been called");
@@ -1664,20 +2155,27 @@ index 89655a5..540b278 100644
}
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
-+static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
{
zval ary;
object_intern *intern;
-@@ -97,7 +97,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
+@@ -97,13 +88,13 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
array_init(&ary);
- intern = get_object(object TSRMLS_CC);
-+ intern = get_object(object);
++ intern = rdkafka_get_debug_object(object_intern, object);
if (!intern) {
return Z_ARRVAL(ary);
}
-@@ -124,7 +124,7 @@ PHP_METHOD(RdKafka__Metadata__Broker, getId)
+
+ add_assoc_long(&ary, "id", intern->metadata_broker->id);
+- rdkafka_add_assoc_string(&ary, "host", intern->metadata_broker->host);
++ add_assoc_string(&ary, "host", intern->metadata_broker->host);
+ add_assoc_long(&ary, "port", intern->metadata_broker->port);
+
+ return Z_ARRVAL(ary);
+@@ -124,7 +115,7 @@ PHP_METHOD(RdKafka__Metadata__Broker, getId)
return;
}
@@ -1686,7 +2184,7 @@ index 89655a5..540b278 100644
if (!intern) {
return;
}
-@@ -147,7 +147,7 @@ PHP_METHOD(RdKafka__Metadata__Broker, getHost)
+@@ -147,12 +138,12 @@ PHP_METHOD(RdKafka__Metadata__Broker, getHost)
return;
}
@@ -1695,7 +2193,13 @@ index 89655a5..540b278 100644
if (!intern) {
return;
}
-@@ -170,7 +170,7 @@ PHP_METHOD(RdKafka__Metadata__Broker, getPort)
+
+- RDKAFKA_RETURN_STRING(intern->metadata_broker->host);
++ RETURN_STRING(intern->metadata_broker->host);
+ }
+ /* }}} */
+
+@@ -170,7 +161,7 @@ PHP_METHOD(RdKafka__Metadata__Broker, getPort)
return;
}
@@ -1704,12 +2208,12 @@ index 89655a5..540b278 100644
if (!intern) {
return;
}
-@@ -186,12 +186,12 @@ static const zend_function_entry fe[] = {
+@@ -186,21 +177,21 @@ static const zend_function_entry fe[] = {
PHP_FE_END
};
-void kafka_metadata_broker_minit(TSRMLS_D)
-+void kafka_metadata_broker_minit()
++void kafka_metadata_broker_minit(INIT_FUNC_ARGS)
{
zend_class_entry tmpce;
@@ -1719,8 +2223,11 @@ index 89655a5..540b278 100644
ce->create_object = create_object;
handlers = kafka_default_object_handlers;
-@@ -200,7 +200,7 @@ void kafka_metadata_broker_minit(TSRMLS_D)
- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
+ handlers.get_debug_info = get_debug_info;
+- set_object_handler_free_obj(&handlers, free_object);
+- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
++ handlers.free_obj = free_object;
++ handlers.offset = XtOffsetOf(object_intern, std);
}
-void kafka_metadata_broker_ctor(zval *return_value, zval *zmetadata, const void *data TSRMLS_DC)
@@ -1728,8 +2235,17 @@ index 89655a5..540b278 100644
{
rd_kafka_metadata_broker_t *metadata_broker = (rd_kafka_metadata_broker_t*)data;
object_intern *intern;
+@@ -209,7 +200,7 @@ void kafka_metadata_broker_ctor(zval *return_value, zval *zmetadata, const void
+ return;
+ }
+
+- intern = get_custom_object_zval(object_intern, return_value);
++ intern = Z_RDKAFKA_P(object_intern, return_value);
+ if (!intern) {
+ return;
+ }
diff --git a/metadata_broker.h b/metadata_broker.h
-index 0cf4e4b..c860495 100644
+index 0cf4e4b..6f64928 100644
--- a/metadata_broker.h
+++ b/metadata_broker.h
@@ -16,5 +16,5 @@
@@ -1738,18 +2254,35 @@ index 0cf4e4b..c860495 100644
-void kafka_metadata_broker_minit(TSRMLS_D);
-void kafka_metadata_broker_ctor(zval *return_value, zval *zmetadata, const void *metadata_broker TSRMLS_DC);
-+void kafka_metadata_broker_minit();
++void kafka_metadata_broker_minit(INIT_FUNC_ARGS);
+void kafka_metadata_broker_ctor(zval *return_value, zval *zmetadata, const void *metadata_broker);
diff --git a/metadata_collection.c b/metadata_collection.c
-index 62867bc..8b19083 100644
+index 62867bc..af986ff 100644
--- a/metadata_collection.c
+++ b/metadata_collection.c
-@@ -45,12 +45,12 @@ typedef struct _object_intern {
- #endif
+@@ -28,90 +28,82 @@
+ #include "Zend/zend_interfaces.h"
+ #include "metadata_collection.h"
+ #include "Zend/zend_exceptions.h"
+-#include "zeval.h"
+
+ typedef struct _object_intern {
+-#if PHP_MAJOR_VERSION < 7
+- zend_object std;
+-#endif
+ zval zmetadata;
+ const void *items;
+ size_t item_cnt;
+ size_t item_size;
+ size_t position;
+ kafka_metadata_collection_ctor_t ctor;
+-#if PHP_MAJOR_VERSION >= 7
+ zend_object std;
+-#endif
} object_intern;
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC);
-+static HashTable *get_debug_info(zval *object, int *is_temp);
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
static zend_class_entry *ce;
static zend_object_handlers handlers;
@@ -1757,39 +2290,47 @@ index 62867bc..8b19083 100644
-static void free_object(zend_object *object TSRMLS_DC) /* {{{ */
+static void free_object(zend_object *object) /* {{{ */
{
- object_intern *intern = get_custom_object(object_intern, object);
+- object_intern *intern = get_custom_object(object_intern, object);
++ object_intern *intern = php_kafka_from_obj(object_intern, object);
-@@ -58,19 +58,19 @@ static void free_object(zend_object *object TSRMLS_DC) /* {{{ */
+ if (intern->items) {
zval_dtor(&intern->zmetadata);
}
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+-
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
/* }}} */
-static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value create_object(zend_class_entry *class_type) /* {{{ */
++static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
object_intern *intern;
- intern = alloc_object(intern, class_type);
+- intern = alloc_object(intern, class_type);
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
++ intern = zend_object_alloc(sizeof(*intern), class_type);
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
-@@ -80,19 +80,19 @@ static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) /
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
+- SET_OBJECT_HANDLERS(retval, &handlers);
++ retval = &intern->std;
++ retval->handlers = &handlers;
+
+ return retval;
}
/* }}} */
-static object_intern * get_object(zval *zmti TSRMLS_DC)
+static object_intern * get_object(zval *zmti)
{
- object_intern *omti = get_custom_object_zval(object_intern, zmti);
+- object_intern *omti = get_custom_object_zval(object_intern, zmti);
++ object_intern *omti = Z_RDKAFKA_P(object_intern, zmti);
if (!omti->items) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Metadata\\Collection::__construct() has not been called" TSRMLS_CC);
@@ -1801,28 +2342,35 @@ index 62867bc..8b19083 100644
}
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
-+static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
{
zval ary;
object_intern *intern;
-@@ -103,14 +103,14 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
+ size_t i;
+- zeval item;
++ zval item;
+
+ *is_temp = 1;
array_init(&ary);
- intern = get_object(object TSRMLS_CC);
-+ intern = get_object(object);
++ intern = rdkafka_get_debug_object(object_intern, object);
if (!intern) {
return Z_ARRVAL(ary);
}
for (i = 0; i < intern->item_cnt; i++) {
- MAKE_STD_ZEVAL(item);
+- MAKE_STD_ZEVAL(item);
- intern->ctor(P_ZEVAL(item), &intern->zmetadata, (char *)intern->items + i * intern->item_size TSRMLS_CC);
-+ intern->ctor(P_ZEVAL(item), &intern->zmetadata, (char *)intern->items + i * intern->item_size);
- add_next_index_zval(&ary, P_ZEVAL(item));
+- add_next_index_zval(&ary, P_ZEVAL(item));
++ ZVAL_NULL(&item);
++ intern->ctor(&item, &intern->zmetadata, (char *)intern->items + i * intern->item_size);
++ add_next_index_zval(&ary, &item);
}
-@@ -132,7 +132,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, count)
+ return Z_ARRVAL(ary);
+@@ -132,7 +124,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, count)
return;
}
@@ -1831,7 +2379,7 @@ index 62867bc..8b19083 100644
if (!intern) {
return;
}
-@@ -155,7 +155,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, rewind)
+@@ -155,7 +147,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, rewind)
return;
}
@@ -1840,7 +2388,7 @@ index 62867bc..8b19083 100644
if (!intern) {
return;
}
-@@ -178,17 +178,17 @@ PHP_METHOD(RdKafka__Metadata__Collection, current)
+@@ -178,17 +170,17 @@ PHP_METHOD(RdKafka__Metadata__Collection, current)
return;
}
@@ -1861,7 +2409,7 @@ index 62867bc..8b19083 100644
}
/* }}} */
-@@ -206,13 +206,13 @@ PHP_METHOD(RdKafka__Metadata__Collection, key)
+@@ -206,13 +198,13 @@ PHP_METHOD(RdKafka__Metadata__Collection, key)
return;
}
@@ -1877,7 +2425,7 @@ index 62867bc..8b19083 100644
return;
}
-@@ -234,7 +234,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, next)
+@@ -234,7 +226,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, next)
return;
}
@@ -1886,7 +2434,7 @@ index 62867bc..8b19083 100644
if (!intern) {
return;
}
-@@ -257,7 +257,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, valid)
+@@ -257,7 +249,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, valid)
return;
}
@@ -1895,12 +2443,12 @@ index 62867bc..8b19083 100644
if (!intern) {
return;
}
-@@ -276,14 +276,14 @@ static const zend_function_entry fe[] = {
+@@ -276,22 +268,22 @@ static const zend_function_entry fe[] = {
PHP_FE_END
};
-void kafka_metadata_collection_minit(TSRMLS_D)
-+void kafka_metadata_collection_minit()
++void kafka_metadata_collection_minit(INIT_FUNC_ARGS)
{
zend_class_entry tmpce;
@@ -1913,17 +2461,35 @@ index 62867bc..8b19083 100644
handlers = kafka_default_object_handlers;
handlers.get_debug_info = get_debug_info;
-@@ -291,7 +291,7 @@ void kafka_metadata_collection_minit(TSRMLS_D)
- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
+- set_object_handler_free_obj(&handlers, free_object);
+- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
++ handlers.free_obj = free_object;
++ handlers.offset = XtOffsetOf(object_intern, std);
}
-void kafka_metadata_collection_init(zval *return_value, zval *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor TSRMLS_DC)
-+void kafka_metadata_collection_init(zval *return_value, zval *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor)
++void kafka_metadata_collection_init(zval *return_value, Z_RDKAFKA_OBJ *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor)
{
object_intern *intern;
+@@ -299,12 +291,14 @@ void kafka_metadata_collection_init(zval *return_value, zval *zmetadata, const v
+ return;
+ }
+
+- intern = get_custom_object_zval(object_intern, return_value);
++ intern = Z_RDKAFKA_P(object_intern, return_value);
+ if (!intern) {
+ return;
+ }
+
++#if PHP_MAJOR_VERSION < 8
+ ZVAL_ZVAL(&intern->zmetadata, zmetadata, 1, 0);
++#endif
+ intern->items = items;
+ intern->item_cnt = item_cnt;
+ intern->item_size = item_size;
diff --git a/metadata_collection.h b/metadata_collection.h
-index 55539bb..13c6123 100644
+index 55539bb..fff2fd6 100644
--- a/metadata_collection.h
+++ b/metadata_collection.h
@@ -16,7 +16,7 @@
@@ -1935,18 +2501,28 @@ index 55539bb..13c6123 100644
-void kafka_metadata_collection_minit(TSRMLS_D);
-void kafka_metadata_collection_init(zval *return_value, zval *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor TSRMLS_DC);
-+void kafka_metadata_collection_minit();
-+void kafka_metadata_collection_init(zval *return_value, zval *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor);
++void kafka_metadata_collection_minit(INIT_FUNC_ARGS);
++void kafka_metadata_collection_init(zval *return_value, Z_RDKAFKA_OBJ *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor);
diff --git a/metadata_partition.c b/metadata_partition.c
-index 17f5f3a..70b7430 100644
+index 17f5f3a..7fcabc2 100644
--- a/metadata_partition.c
+++ b/metadata_partition.c
-@@ -40,12 +40,12 @@ typedef struct _object_intern {
- #endif
+@@ -30,64 +30,57 @@
+ #include "metadata_collection.h"
+
+ typedef struct _object_intern {
+-#if PHP_MAJOR_VERSION < 7
+- zend_object std;
+-#endif
+ zval zmetadata;
+ const rd_kafka_metadata_partition_t *metadata_partition;
+-#if PHP_MAJOR_VERSION >= 7
+ zend_object std;
+-#endif
} object_intern;
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC);
-+static HashTable *get_debug_info(zval *object, int *is_temp);
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
static zend_class_entry * ce;
static zend_object_handlers handlers;
@@ -1954,39 +2530,47 @@ index 17f5f3a..70b7430 100644
-static void free_object(zend_object *object TSRMLS_DC) /* {{{ */
+static void free_object(zend_object *object) /* {{{ */
{
- object_intern *intern = get_custom_object(object_intern, object);
+- object_intern *intern = get_custom_object(object_intern, object);
++ object_intern *intern = php_kafka_from_obj(object_intern, object);
-@@ -53,19 +53,19 @@ static void free_object(zend_object *object TSRMLS_DC) /* {{{ */
+ if (intern->metadata_partition) {
zval_dtor(&intern->zmetadata);
}
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+-
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
/* }}} */
-static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value create_object(zend_class_entry *class_type) /* {{{ */
++static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
object_intern *intern;
- intern = alloc_object(intern, class_type);
+- intern = alloc_object(intern, class_type);
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
++ intern = zend_object_alloc(sizeof(*intern), class_type);
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
-@@ -75,19 +75,19 @@ static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) /
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
+- SET_OBJECT_HANDLERS(retval, &handlers);
++ retval = &intern->std;
++ retval->handlers = &handlers;
+
+ return retval;
}
/* }}} */
-static object_intern * get_object(zval *zmt TSRMLS_DC)
+static object_intern * get_object(zval *zmt)
{
- object_intern *omt = get_custom_object_zval(object_intern, zmt);
+- object_intern *omt = get_custom_object_zval(object_intern, zmt);
++ object_intern *omt = Z_RDKAFKA_P(object_intern, zmt);
if (!omt->metadata_partition) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Metadata\\Partition::__construct() has not been called");
@@ -1998,20 +2582,20 @@ index 17f5f3a..70b7430 100644
}
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
-+static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
{
zval ary;
object_intern *intern;
-@@ -96,7 +96,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
+@@ -96,7 +89,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
array_init(&ary);
- intern = get_object(object TSRMLS_CC);
-+ intern = get_object(object);
++ intern = rdkafka_get_debug_object(object_intern, object);
if (!intern) {
return Z_ARRVAL(ary);
}
-@@ -125,7 +125,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getId)
+@@ -125,7 +118,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getId)
return;
}
@@ -2020,7 +2604,7 @@ index 17f5f3a..70b7430 100644
if (!intern) {
return;
}
-@@ -148,7 +148,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getErr)
+@@ -148,7 +141,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getErr)
return;
}
@@ -2029,7 +2613,7 @@ index 17f5f3a..70b7430 100644
if (!intern) {
return;
}
-@@ -171,7 +171,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getLeader)
+@@ -171,7 +164,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getLeader)
return;
}
@@ -2038,7 +2622,7 @@ index 17f5f3a..70b7430 100644
if (!intern) {
return;
}
-@@ -180,7 +180,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getLeader)
+@@ -180,7 +173,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getLeader)
}
/* }}} */
@@ -2047,7 +2631,7 @@ index 17f5f3a..70b7430 100644
ZVAL_LONG(return_value, *(int32_t*)data);
}
-@@ -198,12 +198,12 @@ PHP_METHOD(RdKafka__Metadata__Partition, getReplicas)
+@@ -198,12 +191,12 @@ PHP_METHOD(RdKafka__Metadata__Partition, getReplicas)
return;
}
@@ -2058,11 +2642,11 @@ index 17f5f3a..70b7430 100644
}
- kafka_metadata_collection_init(return_value, getThis(), intern->metadata_partition->replicas, intern->metadata_partition->replica_cnt, sizeof(*intern->metadata_partition->replicas), int32_ctor TSRMLS_CC);
-+ kafka_metadata_collection_init(return_value, getThis(), intern->metadata_partition->replicas, intern->metadata_partition->replica_cnt, sizeof(*intern->metadata_partition->replicas), int32_ctor);
++ kafka_metadata_collection_init(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern->metadata_partition->replicas, intern->metadata_partition->replica_cnt, sizeof(*intern->metadata_partition->replicas), int32_ctor);
}
/* }}} */
-@@ -221,12 +221,12 @@ PHP_METHOD(RdKafka__Metadata__Partition, getIsrs)
+@@ -221,12 +214,12 @@ PHP_METHOD(RdKafka__Metadata__Partition, getIsrs)
return;
}
@@ -2073,16 +2657,16 @@ index 17f5f3a..70b7430 100644
}
- kafka_metadata_collection_init(return_value, getThis(), intern->metadata_partition->isrs, intern->metadata_partition->isr_cnt, sizeof(*intern->metadata_partition->isrs), int32_ctor TSRMLS_CC);
-+ kafka_metadata_collection_init(return_value, getThis(), intern->metadata_partition->isrs, intern->metadata_partition->isr_cnt, sizeof(*intern->metadata_partition->isrs), int32_ctor);
++ kafka_metadata_collection_init(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern->metadata_partition->isrs, intern->metadata_partition->isr_cnt, sizeof(*intern->metadata_partition->isrs), int32_ctor);
}
/* }}} */
-@@ -239,12 +239,12 @@ static const zend_function_entry fe[] = {
+@@ -239,21 +232,21 @@ static const zend_function_entry fe[] = {
PHP_FE_END
};
-void kafka_metadata_partition_minit(TSRMLS_D)
-+void kafka_metadata_partition_minit()
++void kafka_metadata_partition_minit(INIT_FUNC_ARGS)
{
zend_class_entry tmpce;
@@ -2092,8 +2676,11 @@ index 17f5f3a..70b7430 100644
ce->create_object = create_object;
handlers = kafka_default_object_handlers;
-@@ -253,7 +253,7 @@ void kafka_metadata_partition_minit(TSRMLS_D)
- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
+ handlers.get_debug_info = get_debug_info;
+- set_object_handler_free_obj(&handlers, free_object);
+- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
++ handlers.free_obj = free_object;
++ handlers.offset = XtOffsetOf(object_intern, std);
}
-void kafka_metadata_partition_ctor(zval *return_value, zval *zmetadata, const void *data TSRMLS_DC)
@@ -2101,8 +2688,17 @@ index 17f5f3a..70b7430 100644
{
rd_kafka_metadata_partition_t *metadata_partition = (rd_kafka_metadata_partition_t*)data;
object_intern *intern;
+@@ -262,7 +255,7 @@ void kafka_metadata_partition_ctor(zval *return_value, zval *zmetadata, const vo
+ return;
+ }
+
+- intern = get_custom_object_zval(object_intern, return_value);
++ intern = Z_RDKAFKA_P(object_intern, return_value);
+ if (!intern) {
+ return;
+ }
diff --git a/metadata_partition.h b/metadata_partition.h
-index a3da72c..9d9b4dc 100644
+index a3da72c..8ce35b8 100644
--- a/metadata_partition.h
+++ b/metadata_partition.h
@@ -16,5 +16,5 @@
@@ -2111,25 +2707,38 @@ index a3da72c..9d9b4dc 100644
-void kafka_metadata_partition_minit(TSRMLS_D);
-void kafka_metadata_partition_ctor(zval *return_value, zval *zmetadata, const void *metadata_partition TSRMLS_DC);
-+void kafka_metadata_partition_minit();
++void kafka_metadata_partition_minit(INIT_FUNC_ARGS);
+void kafka_metadata_partition_ctor(zval *return_value, zval *zmetadata, const void *metadata_partition);
diff --git a/metadata_topic.c b/metadata_topic.c
-index 6784316..8a54757 100644
+index 6784316..5aeeed7 100644
--- a/metadata_topic.c
+++ b/metadata_topic.c
-@@ -42,17 +42,17 @@ typedef struct _object_intern {
- #endif
+@@ -29,91 +29,83 @@
+ #include "metadata_partition.h"
+ #include "metadata_collection.h"
+ #include "Zend/zend_exceptions.h"
+-#include "zeval.h"
+
+ typedef struct _object_intern {
+-#if PHP_MAJOR_VERSION < 7
+- zend_object std;
+-#endif
+ zval zmetadata;
+ const rd_kafka_metadata_topic_t *metadata_topic;
+-#if PHP_MAJOR_VERSION >= 7
+ zend_object std;
+-#endif
} object_intern;
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC);
-+static HashTable *get_debug_info(zval *object, int *is_temp);
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
static zend_class_entry * ce;
static zend_object_handlers handlers;
-static void partitions_collection(zval *return_value, zval *parent, object_intern *intern TSRMLS_DC) { /* {{{ */
- kafka_metadata_collection_init(return_value, parent, intern->metadata_topic->partitions, intern->metadata_topic->partition_cnt, sizeof(*intern->metadata_topic->partitions), kafka_metadata_partition_ctor TSRMLS_CC);
-+static void partitions_collection(zval *return_value, zval *parent, object_intern *intern) { /* {{{ */
++static void partitions_collection(zval *return_value, Z_RDKAFKA_OBJ *parent, object_intern *intern) { /* {{{ */
+ kafka_metadata_collection_init(return_value, parent, intern->metadata_topic->partitions, intern->metadata_topic->partition_cnt, sizeof(*intern->metadata_topic->partitions), kafka_metadata_partition_ctor);
}
/* }}} */
@@ -2137,39 +2746,47 @@ index 6784316..8a54757 100644
-static void free_object(zend_object *object TSRMLS_DC) /* {{{ */
+static void free_object(zend_object *object) /* {{{ */
{
- object_intern *intern = get_custom_object(object_intern, object);
+- object_intern *intern = get_custom_object(object_intern, object);
++ object_intern *intern = php_kafka_from_obj(object_intern, object);
-@@ -60,19 +60,19 @@ static void free_object(zend_object *object TSRMLS_DC) /* {{{ */
+ if (intern->metadata_topic) {
zval_dtor(&intern->zmetadata);
}
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+-
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
/* }}} */
-static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value create_object(zend_class_entry *class_type) /* {{{ */
++static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
object_intern *intern;
- intern = alloc_object(intern, class_type);
+- intern = alloc_object(intern, class_type);
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
++ intern = zend_object_alloc(sizeof(*intern), class_type);
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
-@@ -82,19 +82,19 @@ static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) /
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
+- SET_OBJECT_HANDLERS(retval, &handlers);
++ retval = &intern->std;
++ retval->handlers = &handlers;
+
+ return retval;
}
/* }}} */
-static object_intern * get_object(zval *zmt TSRMLS_DC)
+static object_intern * get_object(zval *zmt)
{
- object_intern *omt = get_custom_object_zval(object_intern, zmt);
+- object_intern *omt = get_custom_object_zval(object_intern, zmt);
++ object_intern *omt = Z_RDKAFKA_P(object_intern, zmt);
if (!omt->metadata_topic) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Metadata\\Topic::__construct() has not been called");
@@ -2181,29 +2798,36 @@ index 6784316..8a54757 100644
}
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
-+static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
{
zval ary;
object_intern *intern;
-@@ -104,7 +104,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
+- zeval partitions;
++ zval partitions;
+
+ *is_temp = 1;
array_init(&ary);
- intern = get_object(object TSRMLS_CC);
-+ intern = get_object(object);
++ intern = rdkafka_get_debug_object(object_intern, object);
if (!intern) {
return Z_ARRVAL(ary);
}
-@@ -112,7 +112,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
- rdkafka_add_assoc_string(&ary, "topic", intern->metadata_topic->topic);
- MAKE_STD_ZEVAL(partitions);
+- rdkafka_add_assoc_string(&ary, "topic", intern->metadata_topic->topic);
++ add_assoc_string(&ary, "topic", intern->metadata_topic->topic);
+
+- MAKE_STD_ZEVAL(partitions);
- partitions_collection(P_ZEVAL(partitions), object, intern TSRMLS_CC);
-+ partitions_collection(P_ZEVAL(partitions), object, intern);
- add_assoc_zval(&ary, "partitions", P_ZEVAL(partitions));
+- add_assoc_zval(&ary, "partitions", P_ZEVAL(partitions));
++ ZVAL_NULL(&partitions);
++ partitions_collection(&partitions, object, intern);
++ add_assoc_zval(&ary, "partitions", &partitions);
add_assoc_long(&ary, "err", intern->metadata_topic->err);
-@@ -135,7 +135,7 @@ PHP_METHOD(RdKafka__Metadata__Topic, getTopic)
+
+@@ -135,12 +127,12 @@ PHP_METHOD(RdKafka__Metadata__Topic, getTopic)
return;
}
@@ -2212,7 +2836,13 @@ index 6784316..8a54757 100644
if (!intern) {
return;
}
-@@ -158,7 +158,7 @@ PHP_METHOD(RdKafka__Metadata__Topic, getErr)
+
+- RDKAFKA_RETURN_STRING(intern->metadata_topic->topic);
++ RETURN_STRING(intern->metadata_topic->topic);
+ }
+ /* }}} */
+
+@@ -158,7 +150,7 @@ PHP_METHOD(RdKafka__Metadata__Topic, getErr)
return;
}
@@ -2221,7 +2851,7 @@ index 6784316..8a54757 100644
if (!intern) {
return;
}
-@@ -182,12 +182,12 @@ PHP_METHOD(RdKafka__Metadata__Topic, getPartitions)
+@@ -182,12 +174,12 @@ PHP_METHOD(RdKafka__Metadata__Topic, getPartitions)
return;
}
@@ -2232,16 +2862,16 @@ index 6784316..8a54757 100644
}
- partitions_collection(return_value, getThis(), intern TSRMLS_CC);
-+ partitions_collection(return_value, getThis(), intern);
++ partitions_collection(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern);
}
/* }}} */
-@@ -198,12 +198,12 @@ static const zend_function_entry fe[] = {
+@@ -198,21 +190,21 @@ static const zend_function_entry fe[] = {
PHP_FE_END
};
-void kafka_metadata_topic_minit(TSRMLS_D)
-+void kafka_metadata_topic_minit()
++void kafka_metadata_topic_minit(INIT_FUNC_ARGS)
{
zend_class_entry tmpce;
@@ -2251,8 +2881,11 @@ index 6784316..8a54757 100644
ce->create_object = create_object;
handlers = kafka_default_object_handlers;
-@@ -212,7 +212,7 @@ void kafka_metadata_topic_minit(TSRMLS_D)
- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
+ handlers.get_debug_info = get_debug_info;
+- set_object_handler_free_obj(&handlers, free_object);
+- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
++ handlers.free_obj = free_object;
++ handlers.offset = XtOffsetOf(object_intern, std);
}
-void kafka_metadata_topic_ctor(zval *return_value, zval *zmetadata, const void *data TSRMLS_DC)
@@ -2260,8 +2893,17 @@ index 6784316..8a54757 100644
{
rd_kafka_metadata_topic_t *metadata_topic = (rd_kafka_metadata_topic_t*)data;
object_intern *intern;
+@@ -221,7 +213,7 @@ void kafka_metadata_topic_ctor(zval *return_value, zval *zmetadata, const void *
+ return;
+ }
+
+- intern = get_custom_object_zval(object_intern, return_value);
++ intern = Z_RDKAFKA_P(object_intern, return_value);
+ if (!intern) {
+ return;
+ }
diff --git a/metadata_topic.h b/metadata_topic.h
-index 128fec0..6c5522a 100644
+index 128fec0..677203d 100644
--- a/metadata_topic.h
+++ b/metadata_topic.h
@@ -16,5 +16,5 @@
@@ -2270,31 +2912,120 @@ index 128fec0..6c5522a 100644
-void kafka_metadata_topic_minit(TSRMLS_D);
-void kafka_metadata_topic_ctor(zval *return_value, zval *zmetadata, const void *metadata_topic TSRMLS_DC);
-+void kafka_metadata_topic_minit();
++void kafka_metadata_topic_minit(INIT_FUNC_ARGS);
+void kafka_metadata_topic_ctor(zval *return_value, zval *zmetadata, const void *metadata_topic);
+diff --git a/php_rdkafka.h b/php_rdkafka.h
+index 4188749..19bef56 100644
+--- a/php_rdkafka.h
++++ b/php_rdkafka.h
+@@ -22,7 +22,6 @@
+ #define PHP_RDKAFKA_H
+
+ #include "librdkafka/rdkafka.h"
+-#include "compat.h"
+ #include "conf.h"
+
+ #ifndef PHP_FE_END
+@@ -30,18 +29,13 @@
+ #endif
+
+ typedef struct _kafka_object {
+-#if PHP_MAJOR_VERSION < 7
+- zend_object std;
+-#endif
+ rd_kafka_type_t type;
+ rd_kafka_t *rk;
+ kafka_conf_callbacks cbs;
+ HashTable consuming;
+ HashTable topics;
+ HashTable queues;
+-#if PHP_MAJOR_VERSION >= 7
+ zend_object std;
+-#endif
+ } kafka_object;
+
+ PHP_METHOD(RdKafka, __construct);
+@@ -62,8 +56,4 @@ extern zend_class_entry * ce_kafka_exception;
+ # define PHP_RDKAFKA_API
+ #endif
+
+-#ifdef ZTS
+-#include "TSRM.h"
+-#endif
+-
+ #endif /* PHP_RDKAFKA_H */
diff --git a/php_rdkafka_priv.h b/php_rdkafka_priv.h
-index 434e0e9..d00a8eb 100644
+index 434e0e9..922a88d 100644
--- a/php_rdkafka_priv.h
+++ b/php_rdkafka_priv.h
-@@ -51,7 +51,7 @@ static inline zend_object * is_zend_object(zend_object * object) {
+@@ -19,53 +19,30 @@
+ #ifndef PHP_RDKAFKA_PRIV_H
+ #define PHP_RDKAFKA_PRIV_H
+
+-#if PHP_MAJOR_VERSION >= 7
++#if PHP_MAJOR_VERSION >= 8
+
+-typedef zend_object* zend_object_value;
++#define Z_RDKAFKA_OBJ zend_object
+
+-typedef size_t arglen_t;
++#define Z_RDKAFKA_PROP_OBJ(object) Z_OBJ_P(object)
+
+-#define STORE_OBJECT(retval, intern, dtor, free, clone) do { \
+- retval = &intern->std; \
+-} while (0)
++#define rdkafka_get_debug_object(type, object) php_kafka_from_obj(type, object)
+
+-#define SET_OBJECT_HANDLERS(retval, _handlers) do { \
+- retval->handlers = _handlers; \
+-} while (0)
++#else // PHP 7
+
+-#define alloc_object(intern, ce) ecalloc(1, sizeof(*intern) + zend_object_properties_size(ce))
++#define Z_RDKAFKA_OBJ zval
+
+-static inline zval * is_zval(zval * zv) {
+- return zv;
+-}
+-
+-#define get_custom_object_zval(type, zobject) \
+- ((type*)((char *)Z_OBJ_P(is_zval(zobject)) - XtOffsetOf(type, std)))
++#define Z_RDKAFKA_PROP_OBJ(object) object
+
+-static inline zend_object * is_zend_object(zend_object * object) {
+- return object;
+-}
++#define rdkafka_get_debug_object(type, object) get_object(object)
+
+-#define get_custom_object(type, object) \
+- ((type*)((char *)is_zend_object(object) - XtOffsetOf(type, std)))
++#endif
- #define free_custom_object(object) /* no-op */
+-#define free_custom_object(object) /* no-op */
++#define Z_RDKAFKA_P(php_kafka_type, zobject) php_kafka_from_obj(php_kafka_type, Z_OBJ_P(zobject))
-static inline zend_class_entry *rdkafka_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce TSRMLS_DC)
-+static inline zend_class_entry *rdkafka_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce)
- {
- return zend_register_internal_class_ex(class_entry, parent_ce);
- }
-@@ -65,7 +65,7 @@ static inline void set_object_handler_offset(zend_object_handlers * handlers, si
- handlers->offset = offset;
- }
+-{
+- return zend_register_internal_class_ex(class_entry, parent_ce);
+-}
+-
+-static inline void set_object_handler_free_obj(zend_object_handlers * handlers, zend_object_free_obj_t free_obj)
+-{
+- handlers->free_obj = free_obj;
+-}
+-static inline void set_object_handler_offset(zend_object_handlers * handlers, size_t offset)
+-{
+- handlers->offset = offset;
+-}
++#define php_kafka_from_obj(php_kafka_type, object) \
++ ((php_kafka_type*)((char *)(object) - XtOffsetOf(php_kafka_type, std)))
-static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zval *retval, uint32_t param_count, zval params[] TSRMLS_DC)
+static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zval *retval, uint32_t param_count, zval params[])
{
int local_retval;
zval local_retval_zv;
-@@ -81,17 +81,17 @@ static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_c
+@@ -81,23 +58,19 @@ static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_c
fci->params = params;
fci->param_count = param_count;
@@ -2307,133 +3038,226 @@ index 434e0e9..d00a8eb 100644
}
-static inline zval *rdkafka_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent TSRMLS_DC)
-+static inline zval *rdkafka_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent)
++static inline zval *rdkafka_read_property(zend_class_entry *scope, Z_RDKAFKA_OBJ *object, const char *name, size_t name_length, zend_bool silent)
{
zval rv;
- return zend_read_property(scope, object, name, name_length, silent, &rv TSRMLS_CC);
+ return zend_read_property(scope, object, name, name_length, silent, &rv);
}
- static inline zval *rdkafka_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
-@@ -125,8 +125,8 @@ typedef long zend_long;
- typedef int arglen_t;
+-static inline zval *rdkafka_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
+-{
+- return zend_hash_get_current_data_ex(ht, pos);
+-}
- #define STORE_OBJECT(retval, intern, dtor, free, clone) do { \
+ static inline char *rdkafka_hash_get_current_key_ex(HashTable *ht, HashPosition *pos)
+ {
+@@ -111,148 +84,7 @@ static inline char *rdkafka_hash_get_current_key_ex(HashTable *ht, HashPosition
+ return NULL;
+ }
+
+-#define rdkafka_add_assoc_string(arg, key, str) add_assoc_string(arg, key, str)
+-
+-#define rdkafka_add_assoc_stringl(arg, key, str, str_length) add_assoc_stringl(arg, key, str, str_length)
+-
+-#define RDKAFKA_RETURN_STRING(str) RETURN_STRING(str)
+-#define RDKAFKA_ZVAL_STRING(zv, str) ZVAL_STRING(zv, str)
+-#else /* PHP < 7 */
+-
+-typedef long zend_long;
+-#define ZEND_LONG_FMT "%ld"
+-
+-typedef int arglen_t;
+-
+-#define STORE_OBJECT(retval, intern, dtor, free, clone) do { \
- void (*___free_object_storage)(zend_object *object TSRMLS_DC) = free; \
- retval.handle = zend_objects_store_put(&intern->std, dtor, (zend_objects_free_object_storage_t)___free_object_storage, clone TSRMLS_CC); \
-+ void (*___free_object_storage)(zend_object *object) = free; \
-+ retval.handle = zend_objects_store_put(&intern->std, dtor, (zend_objects_free_object_storage_t)___free_object_storage, clone); \
- } while (0)
-
- #define SET_OBJECT_HANDLERS(retval, _handlers) do { \
-@@ -136,7 +136,7 @@ typedef int arglen_t;
- #define alloc_object(intern, ce) ecalloc(1, sizeof(*intern))
-
- #define get_custom_object_zval(type, zobject) \
+-} while (0)
+-
+-#define SET_OBJECT_HANDLERS(retval, _handlers) do { \
+- retval.handlers = _handlers; \
+-} while (0)
+-
+-#define alloc_object(intern, ce) ecalloc(1, sizeof(*intern))
+-
+-#define get_custom_object_zval(type, zobject) \
- ((type*)zend_object_store_get_object(zobject TSRMLS_CC))
-+ ((type*)zend_object_store_get_object(zobject))
-
- #define get_custom_object(type, object) \
- ((type*)object)
-@@ -167,9 +167,9 @@ static inline void *zend_hash_index_add_ptr(HashTable *ht, zend_ulong h, void *p
- return pDest;
- }
-
+-
+-#define get_custom_object(type, object) \
+- ((type*)object)
+-
+-#define free_custom_object(object) efree(object)
+-
+-static inline void *zend_hash_str_add_ptr(HashTable *ht, const char *str, size_t len, void *pData)
+-{
+- void *pDest;
+- zend_hash_add(ht, str, len, &pData, sizeof(pData), &pDest);
+- return pDest;
+-}
+-
+-static inline int zend_hash_str_del(HashTable *ht, const char *str, size_t len)
+-{
+- return zend_hash_del(ht, str, len);
+-}
+-
+-static inline zend_bool zend_hash_str_exists(const HashTable *ht, const char *str, size_t len)
+-{
+- return zend_hash_exists(ht, str, len);
+-}
+-
+-static inline void *zend_hash_index_add_ptr(HashTable *ht, zend_ulong h, void *pData)
+-{
+- void *pDest;
+- zend_hash_index_update(ht, h, &pData, sizeof(pData), &pDest);
+- return pDest;
+-}
+-
-static inline zend_class_entry *rdkafka_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce TSRMLS_DC)
-+static inline zend_class_entry *rdkafka_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce)
- {
+-{
- return zend_register_internal_class_ex(class_entry, parent_ce, NULL TSRMLS_CC);
-+ return zend_register_internal_class_ex(class_entry, parent_ce, NULL);
- }
-
- typedef void (*zend_object_free_obj_t)(zend_object *object);
-@@ -183,7 +183,7 @@ static inline void set_object_handler_offset(zend_object_handlers * handlers, si
- /* no-op */
- }
-
+-}
+-
+-typedef void (*zend_object_free_obj_t)(zend_object *object);
+-static inline void set_object_handler_free_obj(zend_object_handlers * handlers, zend_object_free_obj_t free_obj)
+-{
+- /* no-op */
+-}
+-
+-static inline void set_object_handler_offset(zend_object_handlers * handlers, size_t offset)
+-{
+- /* no-op */
+-}
+-
-static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zval **retval, uint32_t param_count, zval *params[] TSRMLS_DC)
-+static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zval **retval, uint32_t param_count, zval *params[])
- {
- uint32_t i;
- int local_retval;
-@@ -206,7 +206,7 @@ static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_c
- fci->params = params_array;
- fci->param_count = param_count;
-
+-{
+- uint32_t i;
+- int local_retval;
+- zval *local_retval_zv;
+- zval ***params_array;
+-
+- if (retval) {
+- local_retval = 0;
+- } else {
+- local_retval = 1;
+- retval = &local_retval_zv;
+- }
+-
+- params_array = (zval ***) emalloc(sizeof(zval **)*param_count);
+- for (i = 0; i < param_count; i++) {
+- params_array[i] = &params[i];
+- }
+-
+- fci->retval_ptr_ptr = retval;
+- fci->params = params_array;
+- fci->param_count = param_count;
+-
- zend_call_function(fci, fci_cache TSRMLS_CC);
-+ zend_call_function(fci, fci_cache);
-
- if (local_retval && *retval) {
- zval_ptr_dtor(retval);
-@@ -215,9 +215,9 @@ static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_c
- efree(params_array);
- }
-
+-
+- if (local_retval && *retval) {
+- zval_ptr_dtor(retval);
+- }
+-
+- efree(params_array);
+-}
+-
-static inline zval *rdkafka_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent TSRMLS_DC)
-+static inline zval *rdkafka_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent)
- {
+-{
- return zend_read_property(scope, object, name, name_length, silent TSRMLS_CC);
-+ return zend_read_property(scope, object, name, name_length, silent);
- }
-
- static inline zval **rdkafka_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
-@@ -252,7 +252,7 @@ static inline char **rdkafka_hash_get_current_key_ex(HashTable *ht, HashPosition
- #define RDKAFKA_ZVAL_STRING(zv, str) ZVAL_STRING(zv, str, 1)
- #endif
-
+-}
+-
+-static inline zval **rdkafka_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
+-{
+- zval **zv;
+-
+- if (zend_hash_get_current_data_ex(ht, (void**)&zv, pos) == SUCCESS) {
+- return zv;
+- }
+-
+- return NULL;
+-}
+-
+-static inline char **rdkafka_hash_get_current_key_ex(HashTable *ht, HashPosition *pos)
+-{
+- char *key = NULL;
+- uint klen;
+- ulong index;
+-
+- if (zend_hash_get_current_key_ex(ht, &key, &klen, &index, 0, pos) == HASH_KEY_IS_STRING) {
+- return key;
+- }
+-
+- return NULL;
+-}
+-
+-#define rdkafka_add_assoc_string(arg, key, str) add_assoc_string(arg, key, str, 1)
+-
+-#define rdkafka_add_assoc_stringl(arg, key, str, str_length) add_assoc_stringl(arg, key, str, str_length, 1)
+-
+-#define RDKAFKA_RETURN_STRING(str) RETURN_STRING(str, 1)
+-#define RDKAFKA_ZVAL_STRING(zv, str) ZVAL_STRING(zv, str, 1)
+-#endif
+-
-kafka_object * get_kafka_object(zval *zrk TSRMLS_DC);
+kafka_object * get_kafka_object(zval *zrk);
void add_consuming_toppar(kafka_object * intern, rd_kafka_topic_t * rkt, int32_t partition);
void del_consuming_toppar(kafka_object * intern, rd_kafka_topic_t * rkt, int32_t partition);
int is_consuming_toppar(kafka_object * intern, rd_kafka_topic_t * rkt, int32_t partition);
diff --git a/queue.c b/queue.c
-index 7d661d0..3b0c517 100644
+index 7d661d0..182563a 100644
--- a/queue.c
+++ b/queue.c
-@@ -35,30 +35,30 @@ zend_class_entry * ce_kafka_queue;
+@@ -35,45 +35,43 @@ zend_class_entry * ce_kafka_queue;
static zend_object_handlers handlers;
-static void kafka_queue_free(zend_object *object TSRMLS_DC) /* {{{ */
+static void kafka_queue_free(zend_object *object) /* {{{ */
{
- kafka_queue_object *intern = get_custom_object(kafka_queue_object, object);
+- kafka_queue_object *intern = get_custom_object(kafka_queue_object, object);
++ kafka_queue_object *intern = php_kafka_from_obj(kafka_queue_object, object);
if (intern->rkqu) {
- kafka_object *kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk) TSRMLS_CC);
-+ kafka_object *kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
++ kafka_object *kafka_intern = get_kafka_object(&intern->zrk);
if (kafka_intern) {
zend_hash_index_del(&kafka_intern->queues, (zend_ulong)intern);
}
}
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+-
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
/* }}} */
-static zend_object_value kafka_queue_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value kafka_queue_new(zend_class_entry *class_type) /* {{{ */
++static zend_object *kafka_queue_new(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
kafka_queue_object *intern;
- intern = alloc_object(intern, class_type);
+- intern = alloc_object(intern, class_type);
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
++ intern = zend_object_alloc(sizeof(*intern), class_type);
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_queue_free, NULL);
-@@ -68,12 +68,12 @@ static zend_object_value kafka_queue_new(zend_class_entry *class_type TSRMLS_DC)
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_queue_free, NULL);
+- SET_OBJECT_HANDLERS(retval, &handlers);
++ retval = &intern->std;
++ retval->handlers = &handlers;
+
+ return retval;
}
/* }}} */
-kafka_queue_object * get_kafka_queue_object(zval *zrkqu TSRMLS_DC)
+kafka_queue_object * get_kafka_queue_object(zval *zrkqu)
{
- kafka_queue_object *orkqu = get_custom_object_zval(kafka_queue_object, zrkqu);
+- kafka_queue_object *orkqu = get_custom_object_zval(kafka_queue_object, zrkqu);
++ kafka_queue_object *orkqu = Z_RDKAFKA_P(kafka_queue_object, zrkqu);
if (!orkqu->rkqu) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Queue::__construct() has not been called" TSRMLS_CC);
@@ -2441,7 +3265,7 @@ index 7d661d0..3b0c517 100644
return NULL;
}
-@@ -94,11 +94,11 @@ PHP_METHOD(RdKafka__Queue, consume)
+@@ -94,11 +92,11 @@ PHP_METHOD(RdKafka__Queue, consume)
rd_kafka_message_t *message;
rd_kafka_resp_err_t err;
@@ -2455,7 +3279,7 @@ index 7d661d0..3b0c517 100644
if (!intern) {
return;
}
-@@ -110,11 +110,11 @@ PHP_METHOD(RdKafka__Queue, consume)
+@@ -110,11 +108,11 @@ PHP_METHOD(RdKafka__Queue, consume)
if (err == RD_KAFKA_RESP_ERR__TIMED_OUT) {
return;
}
@@ -2469,17 +3293,20 @@ index 7d661d0..3b0c517 100644
rd_kafka_message_destroy(message);
}
-@@ -129,7 +129,7 @@ static const zend_function_entry kafka_queue_fe[] = {
+@@ -129,15 +127,15 @@ static const zend_function_entry kafka_queue_fe[] = {
PHP_FE_END
};
-void kafka_queue_minit(TSRMLS_D) { /* {{{ */
-+void kafka_queue_minit() { /* {{{ */
++void kafka_queue_minit(INIT_FUNC_ARGS) { /* {{{ */
zend_class_entry ce;
-@@ -138,6 +138,6 @@ void kafka_queue_minit(TSRMLS_D) { /* {{{ */
- set_object_handler_offset(&handlers, XtOffsetOf(kafka_queue_object, std));
+ handlers = kafka_default_object_handlers;
+- set_object_handler_free_obj(&handlers, kafka_queue_free);
+- set_object_handler_offset(&handlers, XtOffsetOf(kafka_queue_object, std));
++ handlers.free_obj = kafka_queue_free;
++ handlers.offset = XtOffsetOf(kafka_queue_object, std);
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Queue", kafka_queue_fe);
- ce_kafka_queue = zend_register_internal_class(&ce TSRMLS_CC);
@@ -2487,21 +3314,32 @@ index 7d661d0..3b0c517 100644
ce_kafka_queue->create_object = kafka_queue_new;
} /* }}} */
diff --git a/queue.h b/queue.h
-index 8d8ab66..532621c 100644
+index 8d8ab66..c3ecb78 100644
--- a/queue.h
+++ b/queue.h
-@@ -27,7 +27,7 @@ typedef struct _kafka_queue_object {
- #endif
+@@ -17,17 +17,12 @@
+ */
+
+ typedef struct _kafka_queue_object {
+-#if PHP_MAJOR_VERSION < 7
+- zend_object std;
+-#endif
+ rd_kafka_queue_t *rkqu;
+- zeval zrk;
+-#if PHP_MAJOR_VERSION >= 7
++ zval zrk;
+ zend_object std;
+-#endif
} kafka_queue_object;
-void kafka_queue_minit(TSRMLS_D);
-kafka_queue_object * get_kafka_queue_object(zval *zrkqu TSRMLS_DC);
-+void kafka_queue_minit();
++void kafka_queue_minit(INIT_FUNC_ARGS);
+kafka_queue_object * get_kafka_queue_object(zval *zrkqu);
extern zend_class_entry * ce_kafka_queue;
diff --git a/rdkafka.c b/rdkafka.c
-index 2accdd9..2052708 100644
+index 2accdd9..50cf5b3 100644
--- a/rdkafka.c
+++ b/rdkafka.c
@@ -70,17 +70,17 @@ static void stop_consuming_toppar_pp(toppar ** tp) {
@@ -2517,7 +3355,8 @@ index 2accdd9..2052708 100644
-static void kafka_free(zend_object *object TSRMLS_DC) /* {{{ */
+static void kafka_free(zend_object *object) /* {{{ */
{
- kafka_object *intern = get_custom_object(kafka_object, object);
+- kafka_object *intern = get_custom_object(kafka_object, object);
++ kafka_object *intern = php_kafka_from_obj(kafka_object, object);
if (intern->rk) {
if (intern->type == RD_KAFKA_CONSUMER) {
@@ -2526,7 +3365,7 @@ index 2accdd9..2052708 100644
zend_hash_destroy(&intern->consuming);
zend_hash_destroy(&intern->queues);
}
-@@ -90,9 +90,9 @@ static void kafka_free(zend_object *object TSRMLS_DC) /* {{{ */
+@@ -90,11 +90,9 @@ static void kafka_free(zend_object *object TSRMLS_DC) /* {{{ */
intern->rk = NULL;
}
@@ -2534,11 +3373,13 @@ index 2accdd9..2052708 100644
+ kafka_conf_callbacks_dtor(&intern->cbs);
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+-
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
-@@ -116,7 +116,7 @@ static void kafka_topic_object_pre_free(kafka_topic_object ** pp) {
+ /* }}} */
+
+@@ -116,7 +114,7 @@ static void kafka_topic_object_pre_free(kafka_topic_object ** pp) {
zval_ptr_dtor(&intern->zrk);
}
@@ -2547,7 +3388,12 @@ index 2accdd9..2052708 100644
{
char errstr[512];
rd_kafka_t *rk;
-@@ -128,10 +128,10 @@ static void kafka_init(zval *this_ptr, rd_kafka_type_t type, zval *zconf TSRMLS_
+@@ -124,14 +122,14 @@ static void kafka_init(zval *this_ptr, rd_kafka_type_t type, zval *zconf TSRMLS_
+ kafka_conf_object *conf_intern;
+ rd_kafka_conf_t *conf = NULL;
+
+- intern = get_custom_object_zval(kafka_object, this_ptr);
++ intern = Z_RDKAFKA_P(kafka_object, this_ptr);
intern->type = type;
if (zconf) {
@@ -2560,7 +3406,7 @@ index 2accdd9..2052708 100644
intern->cbs.zrk = *this_ptr;
rd_kafka_conf_set_opaque(conf, &intern->cbs);
}
-@@ -140,7 +140,7 @@ static void kafka_init(zval *this_ptr, rd_kafka_type_t type, zval *zconf TSRMLS_
+@@ -140,7 +138,7 @@ static void kafka_init(zval *this_ptr, rd_kafka_type_t type, zval *zconf TSRMLS_
rk = rd_kafka_new(type, conf, errstr, sizeof(errstr));
if (rk == NULL) {
@@ -2569,30 +3415,37 @@ index 2accdd9..2052708 100644
return;
}
-@@ -159,13 +159,13 @@ static void kafka_init(zval *this_ptr, rd_kafka_type_t type, zval *zconf TSRMLS_
+@@ -159,28 +157,28 @@ static void kafka_init(zval *this_ptr, rd_kafka_type_t type, zval *zconf TSRMLS_
}
/* }}} */
-static zend_object_value kafka_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value kafka_new(zend_class_entry *class_type) /* {{{ */
++static zend_object *kafka_new(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
kafka_object *intern;
- intern = alloc_object(intern, class_type);
+- intern = alloc_object(intern, class_type);
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
++ intern = zend_object_alloc(sizeof(*intern), class_type);
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_free, NULL);
-@@ -175,12 +175,12 @@ static zend_object_value kafka_new(zend_class_entry *class_type TSRMLS_DC) /* {{
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_free, NULL);
+- SET_OBJECT_HANDLERS(retval, &kafka_object_handlers);
++ retval = &intern->std;
++ retval->handlers = &kafka_object_handlers;
+
+ return retval;
}
/* }}} */
-kafka_object * get_kafka_object(zval *zrk TSRMLS_DC)
+kafka_object * get_kafka_object(zval *zrk)
{
- kafka_object *ork = get_custom_object_zval(kafka_object, zrk);
+- kafka_object *ork = get_custom_object_zval(kafka_object, zrk);
++ kafka_object *ork = Z_RDKAFKA_P(kafka_object, zrk);
if (!ork->rk) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Kafka::__construct() has not been called" TSRMLS_CC);
@@ -2600,7 +3453,7 @@ index 2accdd9..2052708 100644
return NULL;
}
-@@ -241,7 +241,7 @@ int is_consuming_toppar(kafka_object * intern, rd_kafka_topic_t * rkt, int32_t p
+@@ -241,7 +239,7 @@ int is_consuming_toppar(kafka_object * intern, rd_kafka_topic_t * rkt, int32_t p
/* {{{ private constructor */
PHP_METHOD(RdKafka, __construct)
{
@@ -2609,7 +3462,7 @@ index 2accdd9..2052708 100644
return;
}
/* }}} */
-@@ -257,16 +257,16 @@ PHP_METHOD(RdKafka__Consumer, __construct)
+@@ -257,16 +255,16 @@ PHP_METHOD(RdKafka__Consumer, __construct)
zval *zconf = NULL;
zend_error_handling error_handling;
@@ -2631,7 +3484,7 @@ index 2accdd9..2052708 100644
}
/* }}} */
-@@ -282,11 +282,11 @@ PHP_METHOD(RdKafka__Consumer, newQueue)
+@@ -282,11 +280,11 @@ PHP_METHOD(RdKafka__Consumer, newQueue)
kafka_object *intern;
kafka_queue_object *queue_intern;
@@ -2645,8 +3498,36 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -341,11 +341,11 @@ PHP_METHOD(RdKafka__Kafka, addBrokers)
- arglen_t broker_list_len;
+@@ -301,7 +299,7 @@ PHP_METHOD(RdKafka__Consumer, newQueue)
+ return;
+ }
+
+- queue_intern = get_custom_object_zval(kafka_queue_object, return_value);
++ queue_intern = Z_RDKAFKA_P(kafka_queue_object, return_value);
+ if (!queue_intern) {
+ return;
+ }
+@@ -311,12 +309,9 @@ PHP_METHOD(RdKafka__Consumer, newQueue)
+ // Keep a reference to the parent Kafka object, attempts to ensure that
+ // the Queue object is destroyed before the Kafka object.
+ // This avoids rd_kafka_destroy() hanging.
+-#if PHP_MAJOR_VERSION >= 7
+ queue_intern->zrk = *getThis();
+-#else
+- queue_intern->zrk = getThis();
+-#endif
+- Z_ADDREF_P(P_ZEVAL(queue_intern->zrk));
++
++ Z_ADDREF_P(&queue_intern->zrk);
+
+ zend_hash_index_add_ptr(&intern->queues, (zend_ulong)queue_intern, queue_intern);
+ }
+@@ -338,14 +333,14 @@ ZEND_END_ARG_INFO()
+ PHP_METHOD(RdKafka__Kafka, addBrokers)
+ {
+ char *broker_list;
+- arglen_t broker_list_len;
++ size_t broker_list_len;
kafka_object *intern;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &broker_list, &broker_list_len) == FAILURE) {
@@ -2659,7 +3540,7 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -372,17 +372,17 @@ PHP_METHOD(RdKafka__Kafka, getMetadata)
+@@ -372,17 +367,17 @@ PHP_METHOD(RdKafka__Kafka, getMetadata)
const rd_kafka_metadata_t *metadata;
kafka_topic_object *only_orkt = NULL;
@@ -2680,7 +3561,7 @@ index 2accdd9..2052708 100644
if (!only_orkt) {
return;
}
-@@ -391,11 +391,11 @@ PHP_METHOD(RdKafka__Kafka, getMetadata)
+@@ -391,14 +386,14 @@ PHP_METHOD(RdKafka__Kafka, getMetadata)
err = rd_kafka_metadata(intern->rk, all_topics, only_orkt ? only_orkt->rkt : NULL, &metadata, timeout_ms);
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -2693,8 +3574,12 @@ index 2accdd9..2052708 100644
+ kafka_metadata_init(return_value, metadata);
}
/* }}} */
+-
++
+ /* {{{ proto void RdKafka\Kafka::setLogLevel(int $level)
+ Specifies the maximum logging level produced by internal kafka logging and debugging */
-@@ -411,11 +411,11 @@ PHP_METHOD(RdKafka__Kafka, setLogLevel)
+@@ -411,11 +406,11 @@ PHP_METHOD(RdKafka__Kafka, setLogLevel)
kafka_object *intern;
zend_long level;
@@ -2708,7 +3593,16 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -444,17 +444,17 @@ PHP_METHOD(RdKafka__Kafka, newTopic)
+@@ -435,7 +430,7 @@ ZEND_END_ARG_INFO()
+ PHP_METHOD(RdKafka__Kafka, newTopic)
+ {
+ char *topic;
+- arglen_t topic_len;
++ size_t topic_len;
+ rd_kafka_topic_t *rkt;
+ kafka_object *intern;
+ kafka_topic_object *topic_intern;
+@@ -444,17 +439,17 @@ PHP_METHOD(RdKafka__Kafka, newTopic)
rd_kafka_topic_conf_t *conf = NULL;
kafka_conf_object *conf_intern;
@@ -2729,7 +3623,29 @@ index 2accdd9..2052708 100644
if (conf_intern) {
conf = rd_kafka_topic_conf_dup(conf_intern->u.topic_conf);
}
-@@ -508,11 +508,11 @@ PHP_METHOD(RdKafka__Kafka, getOutQLen)
+@@ -481,18 +476,15 @@ PHP_METHOD(RdKafka__Kafka, newTopic)
+ return;
+ }
+
+- topic_intern = get_custom_object_zval(kafka_topic_object, return_value);
++ topic_intern = Z_RDKAFKA_P(kafka_topic_object, return_value);
+ if (!topic_intern) {
+ return;
+ }
+
+ topic_intern->rkt = rkt;
+-#if PHP_MAJOR_VERSION >= 7
+ topic_intern->zrk = *getThis();
+-#else
+- topic_intern->zrk = getThis();
+-#endif
+- Z_ADDREF_P(P_ZEVAL(topic_intern->zrk));
++
++ Z_ADDREF_P(&topic_intern->zrk);
+
+ zend_hash_index_add_ptr(&intern->topics, (zend_ulong)topic_intern, topic_intern);
+ }
+@@ -508,11 +500,11 @@ PHP_METHOD(RdKafka__Kafka, getOutQLen)
{
kafka_object *intern;
@@ -2743,7 +3659,7 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -533,11 +533,11 @@ PHP_METHOD(RdKafka__Kafka, poll)
+@@ -533,11 +525,11 @@ PHP_METHOD(RdKafka__Kafka, poll)
kafka_object *intern;
zend_long timeout;
@@ -2757,7 +3673,7 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -558,11 +558,11 @@ PHP_METHOD(RdKafka__Kafka, flush)
+@@ -558,11 +550,11 @@ PHP_METHOD(RdKafka__Kafka, flush)
kafka_object *intern;
zend_long timeout;
@@ -2771,7 +3687,7 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -584,11 +584,11 @@ PHP_METHOD(RdKafka__Kafka, purge)
+@@ -584,11 +576,11 @@ PHP_METHOD(RdKafka__Kafka, purge)
kafka_object *intern;
zend_long purge_flags;
@@ -2785,7 +3701,14 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -619,14 +619,14 @@ PHP_METHOD(RdKafka__Kafka, queryWatermarkOffsets)
+@@ -613,20 +605,20 @@ PHP_METHOD(RdKafka__Kafka, queryWatermarkOffsets)
+ {
+ kafka_object *intern;
+ char *topic;
+- arglen_t topic_length;
++ size_t topic_length;
+ long low, high;
+ zend_long partition, timeout;
zval *lowResult, *highResult;
rd_kafka_resp_err_t err;
@@ -2794,15 +3717,17 @@ index 2accdd9..2052708 100644
return;
}
- ZEVAL_DEREF(lowResult);
- ZEVAL_DEREF(highResult);
+- ZEVAL_DEREF(lowResult);
+- ZEVAL_DEREF(highResult);
++ ZVAL_DEREF(lowResult);
++ ZVAL_DEREF(highResult);
- intern = get_kafka_object(getThis() TSRMLS_CC);
+ intern = get_kafka_object(getThis());
if (!intern) {
return;
}
-@@ -634,7 +634,7 @@ PHP_METHOD(RdKafka__Kafka, queryWatermarkOffsets)
+@@ -634,7 +626,7 @@ PHP_METHOD(RdKafka__Kafka, queryWatermarkOffsets)
err = rd_kafka_query_watermark_offsets(intern->rk, topic, partition, &low, &high, timeout);
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -2811,7 +3736,7 @@ index 2accdd9..2052708 100644
return;
}
-@@ -657,16 +657,16 @@ PHP_METHOD(RdKafka__Kafka, offsetsForTimes)
+@@ -657,16 +649,16 @@ PHP_METHOD(RdKafka__Kafka, offsetsForTimes)
zend_long timeout_ms;
rd_kafka_resp_err_t err;
@@ -2831,7 +3756,7 @@ index 2accdd9..2052708 100644
if (!topicPartitions) {
return;
}
-@@ -675,10 +675,10 @@ PHP_METHOD(RdKafka__Kafka, offsetsForTimes)
+@@ -675,15 +667,14 @@ PHP_METHOD(RdKafka__Kafka, offsetsForTimes)
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
rd_kafka_topic_partition_list_destroy(topicPartitions);
@@ -2844,7 +3769,12 @@ index 2accdd9..2052708 100644
rd_kafka_topic_partition_list_destroy(topicPartitions);
}
/* }}} */
-@@ -697,11 +697,11 @@ PHP_METHOD(RdKafka__Kafka, setLogger)
+
+-
+ /* {{{ proto void RdKafka::setLogger(mixed $logger)
+ Sets the log callback */
+
+@@ -697,11 +688,11 @@ PHP_METHOD(RdKafka__Kafka, setLogger)
zend_long id;
void (*logger) (const rd_kafka_t * rk, int level, const char *fac, const char *buf);
@@ -2858,7 +3788,7 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -719,7 +719,7 @@ PHP_METHOD(RdKafka__Kafka, setLogger)
+@@ -719,7 +710,7 @@ PHP_METHOD(RdKafka__Kafka, setLogger)
logger = kafka_log_syslog_print;
break;
default:
@@ -2867,7 +3797,7 @@ index 2accdd9..2052708 100644
return;
}
-@@ -757,16 +757,16 @@ PHP_METHOD(RdKafka__Producer, __construct)
+@@ -757,21 +748,20 @@ PHP_METHOD(RdKafka__Producer, __construct)
zval *zconf = NULL;
zend_error_handling error_handling;
@@ -2889,7 +3819,12 @@ index 2accdd9..2052708 100644
}
/* }}} */
-@@ -784,11 +784,11 @@ PHP_METHOD(RdKafka__Producer, initTransactions)
+ #ifdef HAS_RD_KAFKA_TRANSACTIONS
+-
+ /* {{{ proto int RdKafka\Producer::initTransactions(int timeout_ms)
+ Initializes transactions, needs to be done before producing and starting a transaction */
+ ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_init_transactions, 0, 0, 1)
+@@ -784,11 +774,11 @@ PHP_METHOD(RdKafka__Producer, initTransactions)
zend_long timeout_ms;
const rd_kafka_error_t *error;
@@ -2903,7 +3838,7 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -799,8 +799,8 @@ PHP_METHOD(RdKafka__Producer, initTransactions)
+@@ -799,8 +789,8 @@ PHP_METHOD(RdKafka__Producer, initTransactions)
return;
}
@@ -2914,7 +3849,7 @@ index 2accdd9..2052708 100644
}
/* }}} */
-@@ -815,7 +815,7 @@ PHP_METHOD(RdKafka__Producer, beginTransaction)
+@@ -815,7 +805,7 @@ PHP_METHOD(RdKafka__Producer, beginTransaction)
kafka_object *intern;
const rd_kafka_error_t *error;
@@ -2923,7 +3858,7 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -826,8 +826,8 @@ PHP_METHOD(RdKafka__Producer, beginTransaction)
+@@ -826,8 +816,8 @@ PHP_METHOD(RdKafka__Producer, beginTransaction)
return;
}
@@ -2934,7 +3869,7 @@ index 2accdd9..2052708 100644
}
/* }}} */
-@@ -844,11 +844,11 @@ PHP_METHOD(RdKafka__Producer, commitTransaction)
+@@ -844,11 +834,11 @@ PHP_METHOD(RdKafka__Producer, commitTransaction)
zend_long timeout_ms;
const rd_kafka_error_t *error;
@@ -2948,7 +3883,7 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -859,8 +859,8 @@ PHP_METHOD(RdKafka__Producer, commitTransaction)
+@@ -859,8 +849,8 @@ PHP_METHOD(RdKafka__Producer, commitTransaction)
return;
}
@@ -2959,7 +3894,7 @@ index 2accdd9..2052708 100644
}
/* }}} */
-@@ -877,11 +877,11 @@ PHP_METHOD(RdKafka__Producer, abortTransaction)
+@@ -877,11 +867,11 @@ PHP_METHOD(RdKafka__Producer, abortTransaction)
zend_long timeout_ms;
const rd_kafka_error_t *error;
@@ -2973,7 +3908,7 @@ index 2accdd9..2052708 100644
if (!intern) {
return;
}
-@@ -892,8 +892,8 @@ PHP_METHOD(RdKafka__Producer, abortTransaction)
+@@ -892,11 +882,10 @@ PHP_METHOD(RdKafka__Producer, abortTransaction)
return;
}
@@ -2983,18 +3918,31 @@ index 2accdd9..2052708 100644
+ zend_throw_exception_object(return_value);
}
/* }}} */
-
-@@ -939,7 +939,7 @@ void register_err_constants(INIT_FUNC_ARGS) /* {{{ */
- len += 1;
+-
#endif
+ static const zend_function_entry kafka_producer_fe[] = {
+@@ -935,11 +924,7 @@ void register_err_constants(INIT_FUNC_ARGS) /* {{{ */
+ len = sizeof(buf)-1;
+ }
+
+-#if PHP_MAJOR_VERSION < 7
+- len += 1;
+-#endif
+-
- zend_register_long_constant(buf, len, desc->code, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
+ zend_register_long_constant(buf, len, desc->code, CONST_CS | CONST_PERSISTENT, module_number);
}
} /* }}} */
-@@ -989,32 +989,32 @@ PHP_MINIT_FUNCTION(rdkafka)
- set_object_handler_offset(&kafka_object_handlers, XtOffsetOf(kafka_object, std));
+@@ -985,36 +970,36 @@ PHP_MINIT_FUNCTION(rdkafka)
+ kafka_default_object_handlers.clone_obj = NULL;
+
+ kafka_object_handlers = kafka_default_object_handlers;
+- set_object_handler_free_obj(&kafka_object_handlers, kafka_free);
+- set_object_handler_offset(&kafka_object_handlers, XtOffsetOf(kafka_object, std));
++ kafka_object_handlers.free_obj = kafka_free;
++ kafka_object_handlers.offset = XtOffsetOf(kafka_object, std);
INIT_CLASS_ENTRY(ce, "RdKafka", kafka_fe);
- ce_kafka = zend_register_internal_class(&ce TSRMLS_CC);
@@ -3009,18 +3957,18 @@ index 2accdd9..2052708 100644
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Consumer", kafka_consumer_fe);
- ce_kafka_consumer = rdkafka_register_internal_class_ex(&ce, ce_kafka TSRMLS_CC);
-+ ce_kafka_consumer = rdkafka_register_internal_class_ex(&ce, ce_kafka);
++ ce_kafka_consumer = zend_register_internal_class_ex(&ce, ce_kafka);
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Producer", kafka_producer_fe);
- ce_kafka_producer = rdkafka_register_internal_class_ex(&ce, ce_kafka TSRMLS_CC);
-+ ce_kafka_producer = rdkafka_register_internal_class_ex(&ce, ce_kafka);
++ ce_kafka_producer = zend_register_internal_class_ex(&ce, ce_kafka);
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Exception", NULL);
- ce_kafka_exception = rdkafka_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C) TSRMLS_CC);
-+ ce_kafka_exception = rdkafka_register_internal_class_ex(&ce, zend_exception_get_default());
++ ce_kafka_exception = zend_register_internal_class_ex(&ce, zend_ce_exception);
- kafka_conf_minit(TSRMLS_C);
-+ kafka_conf_minit();
++ kafka_conf_minit(INIT_FUNC_ARGS_PASSTHRU);
#ifdef HAS_RD_KAFKA_TRANSACTIONS
- kafka_error_minit(TSRMLS_C);
+ kafka_error_minit();
@@ -3031,15 +3979,65 @@ index 2accdd9..2052708 100644
- kafka_metadata_topic_partition_minit(TSRMLS_C);
- kafka_queue_minit(TSRMLS_C);
- kafka_topic_minit(TSRMLS_C);
-+ kafka_kafka_consumer_minit();
-+ kafka_message_minit();
-+ kafka_metadata_minit();
-+ kafka_metadata_topic_partition_minit();
-+ kafka_queue_minit();
-+ kafka_topic_minit();
++ kafka_kafka_consumer_minit(INIT_FUNC_ARGS_PASSTHRU);
++ kafka_message_minit(INIT_FUNC_ARGS_PASSTHRU);
++ kafka_metadata_minit(INIT_FUNC_ARGS_PASSTHRU);
++ kafka_metadata_topic_partition_minit(INIT_FUNC_ARGS_PASSTHRU);
++ kafka_queue_minit(INIT_FUNC_ARGS_PASSTHRU);
++ kafka_topic_minit(INIT_FUNC_ARGS_PASSTHRU);
return SUCCESS;
}
+diff --git a/tests/bug115.phpt b/tests/bug115.phpt
+index 5ea0af8..8c1620d 100644
+--- a/tests/bug115.phpt
++++ b/tests/bug115.phpt
+@@ -17,12 +17,6 @@ $conf->setErrorCb(function ($producer, $err, $errstr) {
+ printf("%s: %s\n", rd_kafka_err2str($err), $errstr);
+ exit;
+ });
+-$conf->setDrMsgCb(function ($producer, $msg) use (&$delivered) {
+- if ($msg->err) {
+- throw new Exception("Message delivery failed: " . $msg->errstr());
+- }
+- $delivered++;
+-});
+ $conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
+
+ $topicName = sprintf("test_rdkafka_%s", uniqid());
+diff --git a/tests/bug74.phpt b/tests/bug74.phpt
+index 8cb23fd..04f4857 100644
+--- a/tests/bug74.phpt
++++ b/tests/bug74.phpt
+@@ -1,10 +1,14 @@
+ --TEST--
+ Bug 74
++--SKIPIF--
++<?php
++require __DIR__ . '/integration-tests-check.php';
+ --FILE--
+ <?php
++require __DIR__ . '/integration-tests-check.php';
+
+ $conf = new RdKafka\Conf();
+-$conf->set('metadata.broker.list', 'localhost:9092');
++$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
+
+ $consumer = new RdKafka\Consumer($conf);
+ $topic = $consumer->newTopic("batman", null);
+diff --git a/tests/conf_setDefaultTopicConf.phpt b/tests/conf_setDefaultTopicConf.phpt
+index 6b48505..ad08f3b 100644
+--- a/tests/conf_setDefaultTopicConf.phpt
++++ b/tests/conf_setDefaultTopicConf.phpt
+@@ -2,7 +2,7 @@
+ RdKafka\Conf::setDefaultTopicConf()
+ --SKIPIF--
+ <?php
+-if (!method_exists('RdKafka\Conf', 'setDefaultTopicConf')) {
++if (!method_exists('RdKafka\Conf', 'setDefaultTopicConf') || 7 < PHP_MAJOR_VERSION) {
+ echo "skip";
+ }
+ ?>
diff --git a/tests/conf_setDefaultTopicConf8.phpt b/tests/conf_setDefaultTopicConf8.phpt
new file mode 100644
index 0000000..e5fdfe1
@@ -3084,52 +4082,171 @@ index 0000000..e5fdfe1
+10
+0
+
+diff --git a/tests/message_headers.phpt b/tests/message_headers.phpt
+index 61436ae..a244089 100644
+--- a/tests/message_headers.phpt
++++ b/tests/message_headers.phpt
+@@ -15,13 +15,16 @@ $conf->setErrorCb(function ($producer, $err, $errstr) {
+ printf("%s: %s\n", rd_kafka_err2str($err), $errstr);
+ exit;
+ });
++$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
++
++$consumer = new RdKafka\Consumer($conf);
++
+ $conf->setDrMsgCb(function ($producer, $msg) use (&$delivered) {
+ if ($msg->err) {
+ throw new Exception("Message delivery failed: " . $msg->errstr());
+ }
+ $delivered++;
+ });
+-$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
+
+ $producer = new RdKafka\Producer($conf);
+
+@@ -57,8 +60,6 @@ while ($producer->getOutQLen()) {
+
+ printf("%d messages delivered\n", $delivered);
+
+-$consumer = new RdKafka\Consumer($conf);
+-
+ $topic = $consumer->newTopic($topicName);
+ $topic->consumeStart(0, RD_KAFKA_OFFSET_BEGINNING);
+
+diff --git a/tests/produce_consume.phpt b/tests/produce_consume.phpt
+index c10ed1e..9f87208 100644
+--- a/tests/produce_consume.phpt
++++ b/tests/produce_consume.phpt
+@@ -17,13 +17,17 @@ $conf->setErrorCb(function ($producer, $err, $errstr) {
+ printf("%s: %s\n", rd_kafka_err2str($err), $errstr);
+ exit;
+ });
++
++$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
++
++$consumer = new RdKafka\Consumer($conf);
++
+ $conf->setDrMsgCb(function ($producer, $msg) use (&$delivered) {
+ if ($msg->err) {
+ throw new Exception("Message delivery failed: " . $msg->errstr());
+ }
+ $delivered++;
+ });
+-$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
+
+ $producer = new RdKafka\Producer($conf);
+
+@@ -46,8 +50,6 @@ while ($producer->getOutQLen()) {
+
+ printf("%d messages delivered\n", $delivered);
+
+-$consumer = new RdKafka\Consumer($conf);
+-
+ $topic = $consumer->newTopic($topicName);
+ $topic->consumeStart(0, RD_KAFKA_OFFSET_BEGINNING);
+
+diff --git a/tests/produce_consume_queue.phpt b/tests/produce_consume_queue.phpt
+index 9e3dda1..275daf7 100644
+--- a/tests/produce_consume_queue.phpt
++++ b/tests/produce_consume_queue.phpt
+@@ -10,8 +10,6 @@ require __DIR__ . '/integration-tests-check.php';
+ $delivered = 0;
+
+ $conf = new RdKafka\Conf();
+-// Required to detect actual reaching of partition EOF for both topics
+-$conf->set('enable.partition.eof', 'true');
+ if (RD_KAFKA_VERSION >= 0x090000 && false !== getenv('TEST_KAFKA_BROKER_VERSION')) {
+ $conf->set('broker.version.fallback', getenv('TEST_KAFKA_BROKER_VERSION'));
+ }
+@@ -53,6 +51,19 @@ while ($producer->getOutQLen()) {
+
+ printf("%d messages delivered\n", $delivered);
+
++$conf = new RdKafka\Conf();
++// Required to detect actual reaching of partition EOF for both topics
++$conf->set('enable.partition.eof', 'true');
++if (RD_KAFKA_VERSION >= 0x090000 && false !== getenv('TEST_KAFKA_BROKER_VERSION')) {
++ $conf->set('broker.version.fallback', getenv('TEST_KAFKA_BROKER_VERSION'));
++}
++$conf->setErrorCb(function ($producer, $err, $errstr) {
++ printf("%s: %s\n", rd_kafka_err2str($err), $errstr);
++ exit;
++});
++
++$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
++
+ $consumer = new RdKafka\Consumer($conf);
+
+ $queue = $consumer->newQueue();
diff --git a/topic.c b/topic.c
-index 63ae06a..389ae4a 100644
+index 63ae06a..bc274d6 100644
--- a/topic.c
+++ b/topic.c
-@@ -43,30 +43,30 @@ typedef struct _php_callback {
+@@ -43,34 +43,32 @@ typedef struct _php_callback {
zend_fcall_info_cache fcc;
} php_callback;
-static void kafka_topic_free(zend_object *object TSRMLS_DC) /* {{{ */
+static void kafka_topic_free(zend_object *object) /* {{{ */
{
- kafka_topic_object *intern = get_custom_object(kafka_topic_object, object);
+- kafka_topic_object *intern = get_custom_object(kafka_topic_object, object);
++ kafka_topic_object *intern = php_kafka_from_obj(kafka_topic_object, object);
- if (ZE_ISDEF(intern->zrk) && intern->rkt) {
+- if (ZE_ISDEF(intern->zrk) && intern->rkt) {
- kafka_object *kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk) TSRMLS_CC);
-+ kafka_object *kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
++ if (Z_TYPE(intern->zrk) != IS_UNDEF && intern->rkt) {
++ kafka_object *kafka_intern = get_kafka_object(&intern->zrk);
if (kafka_intern) {
zend_hash_index_del(&kafka_intern->topics, (zend_ulong)intern);
}
}
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+-
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
/* }}} */
-static zend_object_value kafka_topic_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value kafka_topic_new(zend_class_entry *class_type) /* {{{ */
++static zend_object *kafka_topic_new(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
kafka_topic_object *intern;
- intern = alloc_object(intern, class_type);
+- intern = alloc_object(intern, class_type);
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
++ intern = zend_object_alloc(sizeof(*intern), class_type);
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_topic_free, NULL);
-@@ -93,19 +93,19 @@ static void consume_callback(rd_kafka_message_t *msg, void *opaque)
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_topic_free, NULL);
+- SET_OBJECT_HANDLERS(retval, &object_handlers);
++ retval = &intern->std;
++ retval->handlers = &object_handlers;
+
+ return retval;
+ }
+@@ -80,8 +78,7 @@ static zend_object_value kafka_topic_new(zend_class_entry *class_type TSRMLS_DC)
+ static void consume_callback(rd_kafka_message_t *msg, void *opaque)
+ {
+ php_callback *cb = (php_callback*) opaque;
+- zeval args[1];
+- TSRMLS_FETCH();
++ zval args[1];
+
+ if (!opaque) {
+ return;
+@@ -91,21 +88,21 @@ static void consume_callback(rd_kafka_message_t *msg, void *opaque)
+ return;
+ }
- MAKE_STD_ZEVAL(args[0]);
+- MAKE_STD_ZEVAL(args[0]);
++ ZVAL_NULL(&args[0]);
- kafka_message_new(P_ZEVAL(args[0]), msg TSRMLS_CC);
-+ kafka_message_new(P_ZEVAL(args[0]), msg);
++ kafka_message_new(&args[0], msg);
- rdkafka_call_function(&cb->fci, &cb->fcc, NULL, 1, args TSRMLS_CC);
+ rdkafka_call_function(&cb->fci, &cb->fcc, NULL, 1, args);
@@ -3140,7 +4257,8 @@ index 63ae06a..389ae4a 100644
-kafka_topic_object * get_kafka_topic_object(zval *zrkt TSRMLS_DC)
+kafka_topic_object * get_kafka_topic_object(zval *zrkt)
{
- kafka_topic_object *orkt = get_custom_object_zval(kafka_topic_object, zrkt);
+- kafka_topic_object *orkt = get_custom_object_zval(kafka_topic_object, zrkt);
++ kafka_topic_object *orkt = Z_RDKAFKA_P(kafka_topic_object, zrkt);
if (!orkt->rkt) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Topic::__construct() has not been called" TSRMLS_CC);
@@ -3148,7 +4266,7 @@ index 63ae06a..389ae4a 100644
return NULL;
}
-@@ -128,16 +128,16 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeCallback)
+@@ -128,21 +125,21 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeCallback)
long result;
kafka_topic_object *intern;
@@ -3168,7 +4286,13 @@ index 63ae06a..389ae4a 100644
if (!intern) {
return;
}
-@@ -172,26 +172,26 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeQueueStart)
+
+- Z_ADDREF_P(P_ZEVAL(cb.fci.function_name));
++ Z_ADDREF_P(&cb.fci.function_name);
+
+ result = rd_kafka_consume_callback(intern->rkt, partition, timeout_ms, consume_callback, &cb);
+
+@@ -172,26 +169,26 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeQueueStart)
rd_kafka_resp_err_t err;
kafka_object *kafka_intern;
@@ -3196,11 +4320,11 @@ index 63ae06a..389ae4a 100644
}
- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk) TSRMLS_CC);
-+ kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
++ kafka_intern = get_kafka_object(&intern->zrk);
if (!kafka_intern) {
return;
}
-@@ -199,7 +199,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeQueueStart)
+@@ -199,7 +196,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeQueueStart)
if (is_consuming_toppar(kafka_intern, intern->rkt, partition)) {
zend_throw_exception_ex(
ce_kafka_exception,
@@ -3209,7 +4333,7 @@ index 63ae06a..389ae4a 100644
"%s:" ZEND_LONG_FMT " is already being consumed by the same Consumer instance",
rd_kafka_topic_name(intern->rkt),
partition
-@@ -211,7 +211,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeQueueStart)
+@@ -211,7 +208,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeQueueStart)
if (ret == -1) {
err = rd_kafka_last_error();
@@ -3218,7 +4342,7 @@ index 63ae06a..389ae4a 100644
return;
}
-@@ -236,21 +236,21 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStart)
+@@ -236,21 +233,21 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStart)
rd_kafka_resp_err_t err;
kafka_object *kafka_intern;
@@ -3240,11 +4364,11 @@ index 63ae06a..389ae4a 100644
}
- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk) TSRMLS_CC);
-+ kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
++ kafka_intern = get_kafka_object(&intern->zrk);
if (!kafka_intern) {
return;
}
-@@ -258,7 +258,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStart)
+@@ -258,7 +255,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStart)
if (is_consuming_toppar(kafka_intern, intern->rkt, partition)) {
zend_throw_exception_ex(
ce_kafka_exception,
@@ -3253,7 +4377,7 @@ index 63ae06a..389ae4a 100644
"%s:" ZEND_LONG_FMT " is already being consumed by the same Consumer instance",
rd_kafka_topic_name(intern->rkt),
partition
-@@ -270,7 +270,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStart)
+@@ -270,7 +267,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStart)
if (ret == -1) {
err = rd_kafka_last_error();
@@ -3262,7 +4386,7 @@ index 63ae06a..389ae4a 100644
return;
}
-@@ -293,21 +293,21 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStop)
+@@ -293,21 +290,21 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStop)
rd_kafka_resp_err_t err;
kafka_object *kafka_intern;
@@ -3284,11 +4408,11 @@ index 63ae06a..389ae4a 100644
}
- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk) TSRMLS_CC);
-+ kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
++ kafka_intern = get_kafka_object(&intern->zrk);
if (!kafka_intern) {
return;
}
-@@ -316,7 +316,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStop)
+@@ -316,7 +313,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStop)
if (ret == -1) {
err = rd_kafka_last_error();
@@ -3297,7 +4421,7 @@ index 63ae06a..389ae4a 100644
return;
}
-@@ -340,16 +340,16 @@ PHP_METHOD(RdKafka__ConsumerTopic, consume)
+@@ -340,16 +337,16 @@ PHP_METHOD(RdKafka__ConsumerTopic, consume)
rd_kafka_message_t *message;
rd_kafka_resp_err_t err;
@@ -3317,7 +4441,7 @@ index 63ae06a..389ae4a 100644
if (!intern) {
return;
}
-@@ -361,11 +361,11 @@ PHP_METHOD(RdKafka__ConsumerTopic, consume)
+@@ -361,11 +358,11 @@ PHP_METHOD(RdKafka__ConsumerTopic, consume)
if (err == RD_KAFKA_RESP_ERR__TIMED_OUT) {
return;
}
@@ -3331,7 +4455,7 @@ index 63ae06a..389ae4a 100644
rd_kafka_message_destroy(message);
}
-@@ -388,21 +388,21 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeBatch)
+@@ -388,21 +385,21 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeBatch)
rd_kafka_message_t **rkmessages;
rd_kafka_resp_err_t err;
@@ -3357,7 +4481,7 @@ index 63ae06a..389ae4a 100644
if (!intern) {
return;
}
-@@ -414,12 +414,12 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeBatch)
+@@ -414,12 +411,12 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeBatch)
if (result == -1) {
free(rkmessages);
err = rd_kafka_last_error();
@@ -3372,7 +4496,7 @@ index 63ae06a..389ae4a 100644
for (i = 0; i < result; ++i) {
rd_kafka_message_destroy(rkmessages[i]);
}
-@@ -443,16 +443,16 @@ PHP_METHOD(RdKafka__ConsumerTopic, offsetStore)
+@@ -443,16 +440,16 @@ PHP_METHOD(RdKafka__ConsumerTopic, offsetStore)
zend_long offset;
rd_kafka_resp_err_t err;
@@ -3392,7 +4516,7 @@ index 63ae06a..389ae4a 100644
if (!intern) {
return;
}
-@@ -460,7 +460,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, offsetStore)
+@@ -460,7 +457,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, offsetStore)
err = rd_kafka_offset_store(intern->rkt, partition, offset);
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
@@ -3401,7 +4525,16 @@ index 63ae06a..389ae4a 100644
return;
}
}
-@@ -509,27 +509,27 @@ PHP_METHOD(RdKafka__ProducerTopic, produce)
+@@ -502,34 +499,34 @@ PHP_METHOD(RdKafka__ProducerTopic, produce)
+ zend_long partition;
+ zend_long msgflags;
+ char *payload = NULL;
+- arglen_t payload_len = 0;
++ size_t payload_len = 0;
+ char *key = NULL;
+- arglen_t key_len = 0;
++ size_t key_len = 0;
+ int ret;
rd_kafka_resp_err_t err;
kafka_topic_object *intern;
@@ -3434,7 +4567,24 @@ index 63ae06a..389ae4a 100644
return;
}
}
-@@ -567,17 +567,17 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
+@@ -553,31 +550,31 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
+ zend_long partition;
+ zend_long msgflags;
+ char *payload = NULL;
+- arglen_t payload_len = 0;
++ size_t payload_len = 0;
+ char *key = NULL;
+- arglen_t key_len = 0;
++ size_t key_len = 0;
+ rd_kafka_resp_err_t err;
+ kafka_topic_object *intern;
+ kafka_object *kafka_intern;
+ HashTable *headersParam = NULL;
+ HashPosition headersParamPos;
+ char *header_key;
+- zeval *header_value;
++ zval *header_value;
+ rd_kafka_headers_t *headers;
zend_long timestamp_ms = 0;
zend_bool timestamp_ms_is_null = 0;
@@ -3455,7 +4605,7 @@ index 63ae06a..389ae4a 100644
return;
}
-@@ -585,7 +585,7 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
+@@ -585,12 +582,12 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
timestamp_ms = 0;
}
@@ -3464,16 +4614,32 @@ index 63ae06a..389ae4a 100644
if (headersParam != NULL && zend_hash_num_elements(headersParam) > 0) {
headers = rd_kafka_headers_new(zend_hash_num_elements(headersParam));
-@@ -606,7 +606,7 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
+ for (zend_hash_internal_pointer_reset_ex(headersParam, &headersParamPos);
+- (header_value = rdkafka_hash_get_current_data_ex(headersParam, &headersParamPos)) != NULL &&
++ (header_value = zend_hash_get_current_data_ex(headersParam, &headersParamPos)) != NULL &&
+ (header_key = rdkafka_hash_get_current_key_ex(headersParam, &headersParamPos)) != NULL;
+ zend_hash_move_forward_ex(headersParam, &headersParamPos)) {
+ convert_to_string_ex(header_value);
+@@ -598,15 +595,15 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
+ headers,
+ header_key,
+ -1, // Auto detect header title length
+- Z_STRVAL_P(ZEVAL(header_value)),
+- Z_STRLEN_P(ZEVAL(header_value))
++ Z_STRVAL_P(header_value),
++ Z_STRLEN_P(header_value)
+ );
+ }
+ } else {
headers = rd_kafka_headers_new(0);
}
- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk) TSRMLS_CC);
-+ kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
++ kafka_intern = get_kafka_object(&intern->zrk);
if (!kafka_intern) {
return;
}
-@@ -625,7 +625,7 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
+@@ -625,7 +622,7 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
if (err != RD_KAFKA_RESP_ERR_NO_ERROR) {
rd_kafka_headers_destroy(headers);
@@ -3482,7 +4648,7 @@ index 63ae06a..389ae4a 100644
return;
}
}
-@@ -654,7 +654,7 @@ PHP_METHOD(RdKafka__Topic, getName)
+@@ -654,12 +651,12 @@ PHP_METHOD(RdKafka__Topic, getName)
return;
}
@@ -3491,17 +4657,27 @@ index 63ae06a..389ae4a 100644
if (!intern) {
return;
}
-@@ -668,7 +668,7 @@ static const zend_function_entry kafka_topic_fe[] = {
+
+- RDKAFKA_RETURN_STRING(rd_kafka_topic_name(intern->rkt));
++ RETURN_STRING(rd_kafka_topic_name(intern->rkt));
+ }
+ /* }}} */
+
+@@ -668,26 +665,26 @@ static const zend_function_entry kafka_topic_fe[] = {
PHP_FE_END
};
-void kafka_topic_minit(TSRMLS_D) { /* {{{ */
-+void kafka_topic_minit() { /* {{{ */
++void kafka_topic_minit(INIT_FUNC_ARGS) { /* {{{ */
zend_class_entry ce;
-@@ -678,16 +678,16 @@ void kafka_topic_minit(TSRMLS_D) { /* {{{ */
- set_object_handler_offset(&object_handlers, XtOffsetOf(kafka_topic_object, std));
+ memcpy(&object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ object_handlers.clone_obj = NULL;
+- set_object_handler_free_obj(&object_handlers, kafka_topic_free);
+- set_object_handler_offset(&object_handlers, XtOffsetOf(kafka_topic_object, std));
++ object_handlers.free_obj = kafka_topic_free;
++ object_handlers.offset = XtOffsetOf(kafka_topic_object, std);
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Topic", kafka_topic_fe);
- ce_kafka_topic = zend_register_internal_class(&ce TSRMLS_CC);
@@ -3511,41 +4687,59 @@ index 63ae06a..389ae4a 100644
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "ConsumerTopic", kafka_consumer_topic_fe);
- ce_kafka_consumer_topic = rdkafka_register_internal_class_ex(&ce, ce_kafka_topic TSRMLS_CC);
-+ ce_kafka_consumer_topic = rdkafka_register_internal_class_ex(&ce, ce_kafka_topic);
++ ce_kafka_consumer_topic = zend_register_internal_class_ex(&ce, ce_kafka_topic);
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "KafkaConsumerTopic", kafka_kafka_consumer_topic_fe);
- ce_kafka_kafka_consumer_topic = rdkafka_register_internal_class_ex(&ce, ce_kafka_topic TSRMLS_CC);
-+ ce_kafka_kafka_consumer_topic = rdkafka_register_internal_class_ex(&ce, ce_kafka_topic);
++ ce_kafka_kafka_consumer_topic = zend_register_internal_class_ex(&ce, ce_kafka_topic);
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "ProducerTopic", kafka_producer_topic_fe);
- ce_kafka_producer_topic = rdkafka_register_internal_class_ex(&ce, ce_kafka_topic TSRMLS_CC);
-+ ce_kafka_producer_topic = rdkafka_register_internal_class_ex(&ce, ce_kafka_topic);
++ ce_kafka_producer_topic = zend_register_internal_class_ex(&ce, ce_kafka_topic);
} /* }}} */
diff --git a/topic.h b/topic.h
-index 07f49ae..78beec3 100644
+index 07f49ae..4e712e9 100644
--- a/topic.h
+++ b/topic.h
-@@ -29,8 +29,8 @@ typedef struct _kafka_topic_object {
- #endif
+@@ -16,21 +16,14 @@
+ +----------------------------------------------------------------------+
+ */
+
+-#include "zeval.h"
+-
+ typedef struct _kafka_topic_object {
+-#if PHP_MAJOR_VERSION < 7
+- zend_object std;
+-#endif
+ rd_kafka_topic_t *rkt;
+- zeval zrk;
+-#if PHP_MAJOR_VERSION >= 7
++ zval zrk;
+ zend_object std;
+-#endif
} kafka_topic_object;
-void kafka_topic_minit(TSRMLS_D);
-kafka_topic_object * get_kafka_topic_object(zval *zrkt TSRMLS_DC);
-+void kafka_topic_minit();
++void kafka_topic_minit(INIT_FUNC_ARGS);
+kafka_topic_object * get_kafka_topic_object(zval *zrkt);
extern zend_class_entry * ce_kafka_consumer_topic;
extern zend_class_entry * ce_kafka_kafka_consumer_topic;
diff --git a/topic_partition.c b/topic_partition.c
-index 2e6d334..f9a08d9 100644
+index 2e6d334..9d1b1f7 100644
--- a/topic_partition.c
+++ b/topic_partition.c
-@@ -33,13 +33,13 @@
+@@ -29,64 +29,61 @@
+ #include "Zend/zend_exceptions.h"
+ #include "ext/spl/spl_exceptions.h"
+ #include "topic_partition.h"
+-#include "zeval.h"
typedef kafka_topic_partition_intern object_intern;
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC);
-+static HashTable *get_debug_info(zval *object, int *is_temp);
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
zend_class_entry * ce_kafka_topic_partition;
@@ -3554,23 +4748,25 @@ index 2e6d334..f9a08d9 100644
-static void free_object(zend_object *object TSRMLS_DC) /* {{{ */
+static void free_object(zend_object *object) /* {{{ */
{
- object_intern *intern = get_custom_object(object_intern, object);
+- object_intern *intern = get_custom_object(object_intern, object);
++ object_intern *intern = php_kafka_from_obj(object_intern, object);
-@@ -47,19 +47,19 @@ static void free_object(zend_object *object TSRMLS_DC) /* {{{ */
+ if (intern->topic) {
efree(intern->topic);
}
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+-
+- free_custom_object(intern);
+ zend_object_std_dtor(&intern->std);
-
- free_custom_object(intern);
}
/* }}} */
-static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
-+static zend_object_value create_object(zend_class_entry *class_type) /* {{{ */
++static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
{
- zend_object_value retval;
+- zend_object_value retval;
++ zend_object* retval;
object_intern *intern;
intern = ecalloc(1, sizeof(*intern));
@@ -3578,15 +4774,20 @@ index 2e6d334..f9a08d9 100644
+ zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
-@@ -69,24 +69,24 @@ static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) /
+- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
+- SET_OBJECT_HANDLERS(retval, &handlers);
++ retval = &intern->std;
++ retval->handlers = &handlers;
+
+ return retval;
}
/* }}} */
-static object_intern * get_object(zval *z TSRMLS_DC) /* {{{ */
+static object_intern * get_object(zval *z) /* {{{ */
{
- object_intern * intern = get_custom_object_zval(object_intern, z);
+- object_intern * intern = get_custom_object_zval(object_intern, z);
++ object_intern *intern = Z_RDKAFKA_P(object_intern, z);
if (!intern->topic) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\TopicPartition::__construct() has not been called");
@@ -3605,20 +4806,28 @@ index 2e6d334..f9a08d9 100644
} /* }}} */
-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
-+static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
++static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
{
zval ary;
object_intern *intern;
-@@ -95,7 +95,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
+@@ -95,13 +92,14 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
array_init(&ary);
- intern = get_object(object TSRMLS_CC);
-+ intern = get_object(object);
++ intern = rdkafka_get_debug_object(object_intern, object);
++
if (!intern) {
return Z_ARRVAL(ary);
}
-@@ -113,7 +113,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
+
+ if (intern->topic) {
+- rdkafka_add_assoc_string(&ary, "topic", intern->topic);
++ add_assoc_string(&ary, "topic", intern->topic);
+ } else {
+ add_assoc_null(&ary, "topic");
+ }
+@@ -113,11 +111,11 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
}
/* }}} */
@@ -3627,7 +4836,12 @@ index 2e6d334..f9a08d9 100644
{
object_intern *intern;
-@@ -131,7 +131,7 @@ void kafka_topic_partition_init(zval *zobj, char * topic, int32_t partition, int
+- intern = get_custom_object_zval(object_intern, zobj);
++ intern = Z_RDKAFKA_P(object_intern, zobj);
+ if (!intern) {
+ return;
+ }
+@@ -131,51 +129,51 @@ void kafka_topic_partition_init(zval *zobj, char * topic, int32_t partition, int
intern->offset = offset;
} /* }}} */
@@ -3635,14 +4849,22 @@ index 2e6d334..f9a08d9 100644
+void kafka_topic_partition_list_to_array(zval *return_value, rd_kafka_topic_partition_list_t *list) /* {{{ */
{
rd_kafka_topic_partition_t *topar;
- zeval ztopar;
-@@ -143,12 +143,12 @@ void kafka_topic_partition_list_to_array(zval *return_value, rd_kafka_topic_part
+- zeval ztopar;
++ zval ztopar;
+ int i;
+
+ array_init_size(return_value, list->cnt);
+
+ for (i = 0; i < list->cnt; i++) {
topar = &list->elems[i];
- MAKE_STD_ZEVAL(ztopar);
- object_init_ex(P_ZEVAL(ztopar), ce_kafka_topic_partition);
+- MAKE_STD_ZEVAL(ztopar);
+- object_init_ex(P_ZEVAL(ztopar), ce_kafka_topic_partition);
- kafka_topic_partition_init(P_ZEVAL(ztopar), topar->topic, topar->partition, topar->offset TSRMLS_CC);
-+ kafka_topic_partition_init(P_ZEVAL(ztopar), topar->topic, topar->partition, topar->offset);
- add_next_index_zval(return_value, P_ZEVAL(ztopar));
+- add_next_index_zval(return_value, P_ZEVAL(ztopar));
++ ZVAL_NULL(&ztopar);
++ object_init_ex(&ztopar, ce_kafka_topic_partition);
++ kafka_topic_partition_init(&ztopar, topar->topic, topar->partition, topar->offset);
++ add_next_index_zval(return_value, &ztopar);
}
} /* }}} */
@@ -3651,12 +4873,20 @@ index 2e6d334..f9a08d9 100644
HashPosition pos;
rd_kafka_topic_partition_list_t *list;
-@@ -162,20 +162,20 @@ rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int ar
+- zeval *zv;
++ zval *zv;
+
+ list = rd_kafka_topic_partition_list_new(zend_hash_num_elements(ary));
+
+ for (zend_hash_internal_pointer_reset_ex(ary, &pos);
+- (zv = rdkafka_hash_get_current_data_ex(ary, &pos)) != NULL;
++ (zv = zend_hash_get_current_data_ex(ary, &pos)) != NULL;
+ zend_hash_move_forward_ex(ary, &pos)) {
kafka_topic_partition_intern *topar_intern;
rd_kafka_topic_partition_t *topar;
- if (Z_TYPE_P(ZEVAL(zv)) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(ZEVAL(zv)), ce_kafka_topic_partition TSRMLS_CC)) {
-+ if (Z_TYPE_P(ZEVAL(zv)) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(ZEVAL(zv)), ce_kafka_topic_partition)) {
++ if (Z_TYPE_P(zv) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(zv), ce_kafka_topic_partition)) {
const char *space;
- const char *class_name = get_active_class_name(&space TSRMLS_CC);
+ const char *class_name = get_active_class_name(&space);
@@ -3666,17 +4896,24 @@ index 2e6d334..f9a08d9 100644
argnum,
class_name, space,
- get_active_function_name(TSRMLS_C),
+- zend_zval_type_name(ZEVAL(zv)));
+ get_active_function_name(),
- zend_zval_type_name(ZEVAL(zv)));
++ zend_zval_type_name(zv));
return NULL;
}
- topar_intern = get_topic_partition_object(ZEVAL(zv) TSRMLS_CC);
-+ topar_intern = get_topic_partition_object(ZEVAL(zv));
++ topar_intern = get_topic_partition_object(zv);
if (!topar_intern) {
rd_kafka_topic_partition_list_destroy(list);
return NULL;
-@@ -206,16 +206,16 @@ PHP_METHOD(RdKafka__TopicPartition, __construct)
+@@ -201,21 +199,21 @@ ZEND_END_ARG_INFO()
+ PHP_METHOD(RdKafka__TopicPartition, __construct)
+ {
+ char *topic;
+- arglen_t topic_len;
++ size_t topic_len;
+ zend_long partition;
zend_long offset = 0;
zend_error_handling error_handling;
@@ -3698,7 +4935,7 @@ index 2e6d334..f9a08d9 100644
}
/* }}} */
-@@ -233,7 +233,7 @@ PHP_METHOD(RdKafka__TopicPartition, getTopic)
+@@ -233,13 +231,13 @@ PHP_METHOD(RdKafka__TopicPartition, getTopic)
return;
}
@@ -3707,8 +4944,19 @@ index 2e6d334..f9a08d9 100644
if (!intern) {
return;
}
-@@ -259,11 +259,11 @@ PHP_METHOD(RdKafka__TopicPartition, setTopic)
- arglen_t topic_len;
+
+ if (intern->topic) {
+- RDKAFKA_RETURN_STRING(intern->topic);
++ RETURN_STRING(intern->topic);
+ } else {
+ RETURN_NULL();
+ }
+@@ -256,14 +254,14 @@ ZEND_END_ARG_INFO()
+ PHP_METHOD(RdKafka__TopicPartition, setTopic)
+ {
+ char * topic;
+- arglen_t topic_len;
++ size_t topic_len;
object_intern *intern;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &topic, &topic_len) == FAILURE) {
@@ -3721,7 +4969,7 @@ index 2e6d334..f9a08d9 100644
if (!intern) {
return;
}
-@@ -292,7 +292,7 @@ PHP_METHOD(RdKafka__TopicPartition, getPartition)
+@@ -292,7 +290,7 @@ PHP_METHOD(RdKafka__TopicPartition, getPartition)
return;
}
@@ -3730,7 +4978,7 @@ index 2e6d334..f9a08d9 100644
if (!intern) {
return;
}
-@@ -313,11 +313,11 @@ PHP_METHOD(RdKafka__TopicPartition, setPartition)
+@@ -313,11 +311,11 @@ PHP_METHOD(RdKafka__TopicPartition, setPartition)
zend_long partition;
object_intern *intern;
@@ -3744,7 +4992,7 @@ index 2e6d334..f9a08d9 100644
if (!intern) {
return;
}
-@@ -342,7 +342,7 @@ PHP_METHOD(RdKafka__TopicPartition, getOffset)
+@@ -342,7 +340,7 @@ PHP_METHOD(RdKafka__TopicPartition, getOffset)
return;
}
@@ -3753,7 +5001,7 @@ index 2e6d334..f9a08d9 100644
if (!intern) {
return;
}
-@@ -363,11 +363,11 @@ PHP_METHOD(RdKafka__TopicPartition, setOffset)
+@@ -363,11 +361,11 @@ PHP_METHOD(RdKafka__TopicPartition, setOffset)
zend_long offset;
object_intern *intern;
@@ -3767,12 +5015,12 @@ index 2e6d334..f9a08d9 100644
if (!intern) {
return;
}
-@@ -389,12 +389,12 @@ static const zend_function_entry fe[] = { /* {{{ */
+@@ -389,16 +387,16 @@ static const zend_function_entry fe[] = { /* {{{ */
PHP_FE_END
}; /* }}} */
-void kafka_metadata_topic_partition_minit(TSRMLS_D) /* {{{ */
-+void kafka_metadata_topic_partition_minit() /* {{{ */
++void kafka_metadata_topic_partition_minit(INIT_FUNC_ARGS) /* {{{ */
{
zend_class_entry tmpce;
@@ -3782,2490 +5030,6 @@ index 2e6d334..f9a08d9 100644
ce_kafka_topic_partition->create_object = create_object;
handlers = kafka_default_object_handlers;
-diff --git a/topic_partition.h b/topic_partition.h
-index cbc0f43..a7aab8b 100644
---- a/topic_partition.h
-+++ b/topic_partition.h
-@@ -28,12 +28,12 @@ typedef struct _kafka_topic_partition_intern {
- #endif
- } kafka_topic_partition_intern;
-
--void kafka_metadata_topic_partition_minit(TSRMLS_D);
-+void kafka_metadata_topic_partition_minit();
-
--kafka_topic_partition_intern * get_topic_partition_object(zval *z TSRMLS_DC);
--void kafka_topic_partition_init(zval *z, char *topic, int32_t partition, int64_t offset TSRMLS_DC);
-+kafka_topic_partition_intern * get_topic_partition_object(zval *z);
-+void kafka_topic_partition_init(zval *z, char *topic, int32_t partition, int64_t offset);
-
--void kafka_topic_partition_list_to_array(zval *return_value, rd_kafka_topic_partition_list_t *list TSRMLS_DC);
--rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int argnum, HashTable *ary TSRMLS_DC);
-+void kafka_topic_partition_list_to_array(zval *return_value, rd_kafka_topic_partition_list_t *list);
-+rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int argnum, HashTable *ary);
-
- extern zend_class_entry * ce_kafka_topic_partition;
-From 134024a653f53618ed3208a3ec1867d1ec2c3747 Mon Sep 17 00:00:00 2001
-From: Arnaud Le Blanc <arnaud.lb@gmail.com>
-Date: Mon, 7 Dec 2020 11:26:57 +0100
-Subject: [PATCH] Drop the php5 compatibility layer: zeval.h (#403)
-
-Co-authored-by: Nick <nickjobszh@gmail.com>
----
- conf.c | 109 ++++++++++++++++++++--------------------
- fun.c | 19 ++++---
- kafka_consumer.c | 10 ++--
- kafka_error_exception.c | 1 -
- kafka_error_exception.h | 3 +-
- message.c | 8 +--
- metadata.c | 17 +++----
- metadata_broker.c | 1 -
- metadata_collection.c | 9 ++--
- metadata_topic.c | 9 ++--
- queue.c | 2 +-
- queue.h | 2 +-
- rdkafka.c | 8 +--
- topic.c | 26 +++++-----
- topic.h | 4 +-
- topic_partition.c | 19 ++++---
- zeval.h | 71 --------------------------
- 17 files changed, 119 insertions(+), 199 deletions(-)
- delete mode 100644 zeval.h
-
-diff --git a/conf.c b/conf.c
-index 69d1863..6e814b7 100644
---- a/conf.c
-+++ b/conf.c
-@@ -31,7 +31,6 @@
- #include "conf.h"
- #include "topic_partition.h"
- #include "message.h"
--#include "zeval.h"
-
- zend_class_entry * ce_kafka_conf;
- zend_class_entry * ce_kafka_topic_conf;
-@@ -143,7 +142,7 @@ kafka_conf_object * get_kafka_conf_object(zval *zconf)
- static void kafka_conf_error_cb(rd_kafka_t *rk, int err, const char *reason, void *opaque)
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
-- zeval args[3];
-+ zval args[3];
- TSRMLS_FETCH();
-
- if (!opaque) {
-@@ -154,13 +153,13 @@ static void kafka_conf_error_cb(rd_kafka_t *rk, int err, const char *reason, voi
- return;
- }
-
-- MAKE_STD_ZEVAL(args[0]);
-- MAKE_STD_ZEVAL(args[1]);
-- MAKE_STD_ZEVAL(args[2]);
-+ ZVAL_NULL(&args[0]);
-+ ZVAL_NULL(&args[1]);
-+ ZVAL_NULL(&args[2]);
-
-- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
-- ZVAL_LONG(P_ZEVAL(args[1]), err);
-- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[2]), reason);
-+ KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ ZVAL_LONG(&args[1], err);
-+ RDKAFKA_ZVAL_STRING(&args[2], reason);
-
- rdkafka_call_function(&cbs->error->fci, &cbs->error->fcc, NULL, 3, args);
-
-@@ -172,7 +171,7 @@ static void kafka_conf_error_cb(rd_kafka_t *rk, int err, const char *reason, voi
- static void kafka_conf_dr_msg_cb(rd_kafka_t *rk, const rd_kafka_message_t *msg, void *opaque)
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
-- zeval args[2];
-+ zval args[2];
- TSRMLS_FETCH();
-
- if (!opaque) {
-@@ -183,11 +182,11 @@ static void kafka_conf_dr_msg_cb(rd_kafka_t *rk, const rd_kafka_message_t *msg,
- return;
- }
-
-- MAKE_STD_ZEVAL(args[0]);
-- MAKE_STD_ZEVAL(args[1]);
-+ ZVAL_NULL(&args[0]);
-+ ZVAL_NULL(&args[1]);
-
-- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
-- kafka_message_new(P_ZEVAL(args[1]), msg);
-+ KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ kafka_message_new(&args[1], msg);
-
- rdkafka_call_function(&cbs->dr_msg->fci, &cbs->dr_msg->fcc, NULL, 2, args);
-
-@@ -198,7 +197,7 @@ static void kafka_conf_dr_msg_cb(rd_kafka_t *rk, const rd_kafka_message_t *msg,
- static int kafka_conf_stats_cb(rd_kafka_t *rk, char *json, size_t json_len, void *opaque)
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
-- zeval args[3];
-+ zval args[3];
- TSRMLS_FETCH();
-
- if (!opaque) {
-@@ -209,13 +208,13 @@ static int kafka_conf_stats_cb(rd_kafka_t *rk, char *json, size_t json_len, void
- return 0;
- }
-
-- MAKE_STD_ZEVAL(args[0]);
-- MAKE_STD_ZEVAL(args[1]);
-- MAKE_STD_ZEVAL(args[2]);
-+ ZVAL_NULL(&args[0]);
-+ ZVAL_NULL(&args[1]);
-+ ZVAL_NULL(&args[2]);
-
-- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
-- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[1]), json);
-- ZVAL_LONG(P_ZEVAL(args[2]), json_len);
-+ KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ RDKAFKA_ZVAL_STRING(&args[1], json);
-+ ZVAL_LONG(&args[2], json_len);
-
- rdkafka_call_function(&cbs->stats->fci, &cbs->stats->fcc, NULL, 3, args);
-
-@@ -229,7 +228,7 @@ static int kafka_conf_stats_cb(rd_kafka_t *rk, char *json, size_t json_len, void
- static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_kafka_topic_partition_list_t *partitions, void *opaque)
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
-- zeval args[3];
-+ zval args[3];
- TSRMLS_FETCH();
-
- if (!opaque) {
-@@ -247,13 +246,13 @@ static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_
- return;
- }
-
-- MAKE_STD_ZEVAL(args[0]);
-- MAKE_STD_ZEVAL(args[1]);
-- MAKE_STD_ZEVAL(args[2]);
-+ ZVAL_NULL(&args[0]);
-+ ZVAL_NULL(&args[1]);
-+ ZVAL_NULL(&args[2]);
-
-- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
-- ZVAL_LONG(P_ZEVAL(args[1]), err);
-- kafka_topic_partition_list_to_array(P_ZEVAL(args[2]), partitions);
-+ KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ ZVAL_LONG(&args[1], err);
-+ kafka_topic_partition_list_to_array(&args[2], partitions);
-
- rdkafka_call_function(&cbs->rebalance->fci, &cbs->rebalance->fcc, NULL, 3, args);
-
-@@ -265,7 +264,7 @@ static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_
- static void kafka_conf_consume_cb(rd_kafka_message_t *msg, void *opaque)
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
-- zeval args[2];
-+ zval args[2];
- TSRMLS_FETCH();
-
- if (!opaque) {
-@@ -276,11 +275,11 @@ static void kafka_conf_consume_cb(rd_kafka_message_t *msg, void *opaque)
- return;
- }
-
-- MAKE_STD_ZEVAL(args[0]);
-- MAKE_STD_ZEVAL(args[1]);
-+ ZVAL_NULL(&args[0]);
-+ ZVAL_NULL(&args[1]);
-
-- kafka_message_new(P_ZEVAL(args[0]), msg);
-- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[1]), &cbs->zrk, 1, 0);
-+ kafka_message_new(&args[0], msg);
-+ KAFKA_ZVAL_ZVAL(&args[1], &cbs->zrk, 1, 0);
-
-
- rdkafka_call_function(&cbs->consume->fci, &cbs->consume->fcc, NULL, 2, args);
-@@ -292,7 +291,7 @@ static void kafka_conf_consume_cb(rd_kafka_message_t *msg, void *opaque)
- static void kafka_conf_offset_commit_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_kafka_topic_partition_list_t *partitions, void *opaque)
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
-- zeval args[3];
-+ zval args[3];
- TSRMLS_FETCH();
-
- if (!opaque) {
-@@ -303,13 +302,13 @@ static void kafka_conf_offset_commit_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err,
- return;
- }
-
-- MAKE_STD_ZEVAL(args[0]);
-- MAKE_STD_ZEVAL(args[1]);
-- MAKE_STD_ZEVAL(args[2]);
-+ ZVAL_NULL(&args[0]);
-+ ZVAL_NULL(&args[1]);
-+ ZVAL_NULL(&args[2]);
-
-- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
-- ZVAL_LONG(P_ZEVAL(args[1]), err);
-- kafka_topic_partition_list_to_array(P_ZEVAL(args[2]), partitions);
-+ KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ ZVAL_LONG(&args[1], err);
-+ kafka_topic_partition_list_to_array(&args[2], partitions);
-
- rdkafka_call_function(&cbs->offset_commit->fci, &cbs->offset_commit->fcc, NULL, 3, args);
-
-@@ -320,7 +319,7 @@ static void kafka_conf_offset_commit_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err,
-
- static void kafka_conf_log_cb(const rd_kafka_t *rk, int level, const char *facility, const char *message)
- {
-- zeval args[4];
-+ zval args[4];
- TSRMLS_FETCH();
-
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) rd_kafka_opaque(rk);
-@@ -329,15 +328,15 @@ static void kafka_conf_log_cb(const rd_kafka_t *rk, int level, const char *facil
- return;
- }
-
-- MAKE_STD_ZEVAL(args[0]);
-- MAKE_STD_ZEVAL(args[1]);
-- MAKE_STD_ZEVAL(args[2]);
-- MAKE_STD_ZEVAL(args[3]);
-+ ZVAL_NULL(&args[0]);
-+ ZVAL_NULL(&args[1]);
-+ ZVAL_NULL(&args[2]);
-+ ZVAL_NULL(&args[3]);
-
-- KAFKA_ZVAL_ZVAL(P_ZEVAL(args[0]), &cbs->zrk, 1, 0);
-- ZVAL_LONG(P_ZEVAL(args[1]), level);
-- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[2]), facility);
-- RDKAFKA_ZVAL_STRING(P_ZEVAL(args[3]), message);
-+ KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ ZVAL_LONG(&args[1], level);
-+ RDKAFKA_ZVAL_STRING(&args[2], facility);
-+ RDKAFKA_ZVAL_STRING(&args[3], message);
-
- rdkafka_call_function(&cbs->log->fci, &cbs->log->fcc, NULL, 4, args);
-
-@@ -523,7 +522,7 @@ PHP_METHOD(RdKafka__Conf, setErrorCb)
- return;
- }
-
-- Z_ADDREF_P(P_ZEVAL(fci.function_name));
-+ Z_ADDREF_P(&fci.function_name);
-
- if (intern->cbs.error) {
- zval_ptr_dtor(&intern->cbs.error->fci.function_name);
-@@ -560,7 +559,7 @@ PHP_METHOD(RdKafka__Conf, setDrMsgCb)
- return;
- }
-
-- Z_ADDREF_P(P_ZEVAL(fci.function_name));
-+ Z_ADDREF_P(&fci.function_name);
-
- if (intern->cbs.dr_msg) {
- zval_ptr_dtor(&intern->cbs.dr_msg->fci.function_name);
-@@ -597,7 +596,7 @@ PHP_METHOD(RdKafka__Conf, setStatsCb)
- return;
- }
-
-- Z_ADDREF_P(P_ZEVAL(fci.function_name));
-+ Z_ADDREF_P(&fci.function_name);
-
- if (intern->cbs.stats) {
- zval_ptr_dtor(&intern->cbs.stats->fci.function_name);
-@@ -634,7 +633,7 @@ PHP_METHOD(RdKafka__Conf, setRebalanceCb)
- return;
- }
-
-- Z_ADDREF_P(P_ZEVAL(fci.function_name));
-+ Z_ADDREF_P(&fci.function_name);
-
- if (intern->cbs.rebalance) {
- zval_ptr_dtor(&intern->cbs.rebalance->fci.function_name);
-@@ -671,7 +670,7 @@ PHP_METHOD(RdKafka__Conf, setConsumeCb)
- return;
- }
-
-- Z_ADDREF_P(P_ZEVAL(fci.function_name));
-+ Z_ADDREF_P(&fci.function_name);
-
- if (intern->cbs.consume) {
- zval_ptr_dtor(&intern->cbs.consume->fci.function_name);
-@@ -708,7 +707,7 @@ PHP_METHOD(RdKafka__Conf, setOffsetCommitCb)
- return;
- }
-
-- Z_ADDREF_P(P_ZEVAL(fci.function_name));
-+ Z_ADDREF_P(&fci.function_name);
-
- if (intern->cbs.offset_commit) {
- zval_ptr_dtor(&intern->cbs.offset_commit->fci.function_name);
-@@ -746,7 +745,7 @@ PHP_METHOD(RdKafka__Conf, setLogCb)
- return;
- }
-
-- Z_ADDREF_P(P_ZEVAL(fci.function_name));
-+ Z_ADDREF_P(&fci.function_name);
-
- if (conf->cbs.log) {
- zval_ptr_dtor(&conf->cbs.log->fci.function_name);
-diff --git a/fun.c b/fun.c
-index ee21814..77053ec 100644
---- a/fun.c
-+++ b/fun.c
-@@ -26,7 +26,6 @@
- #include "librdkafka/rdkafka.h"
- #include "Zend/zend_exceptions.h"
- #include "ext/spl/spl_exceptions.h"
--#include "zeval.h"
-
- /* {{{ arginfo */
- ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_get_err_descs, 0, 0, 0)
-@@ -71,7 +70,7 @@ PHP_FUNCTION(rd_kafka_get_err_descs)
-
- for (i = 0; i < cnt; i++) {
- const struct rd_kafka_err_desc *desc = &errdescs[i];
-- zeval el;
-+ zval el;
-
- if (desc->code == 0) {
- if (seen_zero) {
-@@ -80,20 +79,20 @@ PHP_FUNCTION(rd_kafka_get_err_descs)
- seen_zero = 1;
- }
-
-- MAKE_STD_ZEVAL(el);
-- array_init(P_ZEVAL(el));
-- add_assoc_long(P_ZEVAL(el), "code", desc->code);
-+ ZVAL_NULL(&el);
-+ array_init(&el);
-+ add_assoc_long(&el, "code", desc->code);
- if (desc->name) {
-- rdkafka_add_assoc_string(P_ZEVAL(el), "name", (char*) desc->name);
-+ rdkafka_add_assoc_string(&el, "name", (char*) desc->name);
- } else {
-- add_assoc_null(P_ZEVAL(el), "name");
-+ add_assoc_null(&el, "name");
- }
- if (desc->desc) {
-- rdkafka_add_assoc_string(P_ZEVAL(el), "desc", (char*) desc->desc);
-+ rdkafka_add_assoc_string(&el, "desc", (char*) desc->desc);
- }else {
-- add_assoc_null(P_ZEVAL(el), "desc");
-+ add_assoc_null(&el, "desc");
- }
-- add_next_index_zval(return_value, P_ZEVAL(el));
-+ add_next_index_zval(return_value, &el);
- }
- }
- /* }}} */
-diff --git a/kafka_consumer.c b/kafka_consumer.c
-index 8b6c4c2..0c604b6 100644
---- a/kafka_consumer.c
-+++ b/kafka_consumer.c
-@@ -271,7 +271,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, subscribe)
- object_intern *intern;
- rd_kafka_topic_partition_list_t *topics;
- rd_kafka_resp_err_t err;
-- zeval *zv;
-+ zval *zv;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "h", &htopics) == FAILURE) {
- return;
-@@ -288,7 +288,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, subscribe)
- (zv = rdkafka_hash_get_current_data_ex(htopics, &pos)) != NULL;
- zend_hash_move_forward_ex(htopics, &pos)) {
- convert_to_string_ex(zv);
-- rd_kafka_topic_partition_list_add(topics, Z_STRVAL_P(ZEVAL(zv)), RD_KAFKA_PARTITION_UA);
-+ rd_kafka_topic_partition_list_add(topics, Z_STRVAL_P(zv), RD_KAFKA_PARTITION_UA);
- }
-
- err = rd_kafka_subscribe(intern->rk, topics);
-@@ -334,7 +334,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, getSubscription)
- array_init_size(return_value, topics->cnt);
-
- for (i = 0; i < topics->cnt; i++) {
-- add_next_index_string(return_value, topics->elems[i].topic ZEVAL_DUP_CC);
-+ add_next_index_string(return_value, topics->elems[i].topic);
- }
-
- rd_kafka_topic_partition_list_destroy(topics);
-@@ -785,8 +785,8 @@ PHP_METHOD(RdKafka__KafkaConsumer, queryWatermarkOffsets)
- return;
- }
-
-- ZEVAL_DEREF(lowResult);
-- ZEVAL_DEREF(highResult);
-+ ZVAL_DEREF(lowResult);
-+ ZVAL_DEREF(highResult);
-
- intern = get_object(getThis());
- if (!intern) {
-diff --git a/kafka_error_exception.c b/kafka_error_exception.c
-index ea3bdba..5ab27e5 100644
---- a/kafka_error_exception.c
-+++ b/kafka_error_exception.c
-@@ -26,7 +26,6 @@
- #include "Zend/zend_interfaces.h"
- #include "Zend/zend_exceptions.h"
- #include "kafka_error_exception.h"
--#include "zeval.h"
-
- zend_class_entry * ce_kafka_error;
-
-diff --git a/kafka_error_exception.h b/kafka_error_exception.h
-index 12068a6..9193877 100644
---- a/kafka_error_exception.h
-+++ b/kafka_error_exception.h
-@@ -17,8 +17,9 @@
- */
- #ifdef HAS_RD_KAFKA_TRANSACTIONS
-
--#include "zeval.h"
- #include "librdkafka/rdkafka.h"
-+#include "php.h"
-+
- extern zend_class_entry * ce_kafka_error;
- void kafka_error_minit();
- void create_kafka_error(zval *return_value, const rd_kafka_error_t *error);
-diff --git a/message.c b/message.c
-index c09bc26..7348971 100644
---- a/message.c
-+++ b/message.c
-@@ -89,16 +89,16 @@ void kafka_message_new(zval *return_value, const rd_kafka_message_t *message)
- void kafka_message_list_to_array(zval *return_value, rd_kafka_message_t **messages, long size) /* {{{ */
- {
- rd_kafka_message_t *msg;
-- zeval zmsg;
-+ zval zmsg;
- int i;
-
- array_init_size(return_value, size);
-
- for (i = 0; i < size; i++) {
- msg = messages[i];
-- MAKE_STD_ZEVAL(zmsg);
-- kafka_message_new(P_ZEVAL(zmsg), msg);
-- add_next_index_zval(return_value, P_ZEVAL(zmsg));
-+ ZVAL_NULL(&zmsg);
-+ kafka_message_new(&zmsg, msg);
-+ add_next_index_zval(return_value, &zmsg);
- }
- } /* }}} */
-
-diff --git a/metadata.c b/metadata.c
-index 86cdbf5..7d7a6d1 100644
---- a/metadata.c
-+++ b/metadata.c
-@@ -29,7 +29,6 @@
- #include "metadata_broker.h"
- #include "metadata_partition.h"
- #include "Zend/zend_exceptions.h"
--#include "zeval.h"
-
- typedef struct _object_intern {
- #if PHP_MAJOR_VERSION < 7
-@@ -102,8 +101,8 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
- {
- zval ary;
- object_intern *intern;
-- zeval brokers;
-- zeval topics;
-+ zval brokers;
-+ zval topics;
-
- *is_temp = 1;
-
-@@ -114,13 +113,13 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
- return Z_ARRVAL(ary);
- }
-
-- MAKE_STD_ZEVAL(brokers);
-- brokers_collection(P_ZEVAL(brokers), object, intern);
-- add_assoc_zval(&ary, "brokers", P_ZEVAL(brokers));
-+ ZVAL_NULL(&brokers);
-+ brokers_collection(&brokers, object, intern);
-+ add_assoc_zval(&ary, "brokers", &brokers);
-
-- MAKE_STD_ZEVAL(topics);
-- topics_collection(P_ZEVAL(topics), object, intern);
-- add_assoc_zval(&ary, "topics", P_ZEVAL(topics));
-+ ZVAL_NULL(&topics);
-+ topics_collection(&topics, object, intern);
-+ add_assoc_zval(&ary, "topics", &topics);
-
- add_assoc_long(&ary, "orig_broker_id", intern->metadata->orig_broker_id);
- rdkafka_add_assoc_string(&ary, "orig_broker_name", intern->metadata->orig_broker_name);
-diff --git a/metadata_broker.c b/metadata_broker.c
-index 540b278..d7df197 100644
---- a/metadata_broker.c
-+++ b/metadata_broker.c
-@@ -27,7 +27,6 @@
- #include "ext/spl/spl_iterators.h"
- #include "Zend/zend_interfaces.h"
- #include "Zend/zend_exceptions.h"
--#include "zeval.h"
-
- typedef struct _object_intern {
- #if PHP_MAJOR_VERSION < 7
-diff --git a/metadata_collection.c b/metadata_collection.c
-index 8b19083..168465f 100644
---- a/metadata_collection.c
-+++ b/metadata_collection.c
-@@ -28,7 +28,6 @@
- #include "Zend/zend_interfaces.h"
- #include "metadata_collection.h"
- #include "Zend/zend_exceptions.h"
--#include "zeval.h"
-
- typedef struct _object_intern {
- #if PHP_MAJOR_VERSION < 7
-@@ -97,7 +96,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
- zval ary;
- object_intern *intern;
- size_t i;
-- zeval item;
-+ zval item;
-
- *is_temp = 1;
-
-@@ -109,9 +108,9 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
- }
-
- for (i = 0; i < intern->item_cnt; i++) {
-- MAKE_STD_ZEVAL(item);
-- intern->ctor(P_ZEVAL(item), &intern->zmetadata, (char *)intern->items + i * intern->item_size);
-- add_next_index_zval(&ary, P_ZEVAL(item));
-+ ZVAL_NULL(&item);
-+ intern->ctor(&item, &intern->zmetadata, (char *)intern->items + i * intern->item_size);
-+ add_next_index_zval(&ary, &item);
- }
-
- return Z_ARRVAL(ary);
-diff --git a/metadata_topic.c b/metadata_topic.c
-index 8a54757..512c83e 100644
---- a/metadata_topic.c
-+++ b/metadata_topic.c
-@@ -29,7 +29,6 @@
- #include "metadata_partition.h"
- #include "metadata_collection.h"
- #include "Zend/zend_exceptions.h"
--#include "zeval.h"
-
- typedef struct _object_intern {
- #if PHP_MAJOR_VERSION < 7
-@@ -98,7 +97,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
- {
- zval ary;
- object_intern *intern;
-- zeval partitions;
-+ zval partitions;
-
- *is_temp = 1;
-
-@@ -111,9 +110,9 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-
- rdkafka_add_assoc_string(&ary, "topic", intern->metadata_topic->topic);
-
-- MAKE_STD_ZEVAL(partitions);
-- partitions_collection(P_ZEVAL(partitions), object, intern);
-- add_assoc_zval(&ary, "partitions", P_ZEVAL(partitions));
-+ ZVAL_NULL(&partitions);
-+ partitions_collection(&partitions, object, intern);
-+ add_assoc_zval(&ary, "partitions", &partitions);
-
- add_assoc_long(&ary, "err", intern->metadata_topic->err);
-
-diff --git a/queue.c b/queue.c
-index 3b0c517..0f0dadc 100644
---- a/queue.c
-+++ b/queue.c
-@@ -40,7 +40,7 @@ static void kafka_queue_free(zend_object *object) /* {{{ */
- kafka_queue_object *intern = get_custom_object(kafka_queue_object, object);
-
- if (intern->rkqu) {
-- kafka_object *kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
-+ kafka_object *kafka_intern = get_kafka_object(&intern->zrk);
- if (kafka_intern) {
- zend_hash_index_del(&kafka_intern->queues, (zend_ulong)intern);
- }
-diff --git a/queue.h b/queue.h
-index 532621c..3349f18 100644
---- a/queue.h
-+++ b/queue.h
-@@ -21,7 +21,7 @@ typedef struct _kafka_queue_object {
- zend_object std;
- #endif
- rd_kafka_queue_t *rkqu;
-- zeval zrk;
-+ zval zrk;
- #if PHP_MAJOR_VERSION >= 7
- zend_object std;
- #endif
-diff --git a/rdkafka.c b/rdkafka.c
-index 2052708..71d0aae 100644
---- a/rdkafka.c
-+++ b/rdkafka.c
-@@ -316,7 +316,7 @@ PHP_METHOD(RdKafka__Consumer, newQueue)
- #else
- queue_intern->zrk = getThis();
- #endif
-- Z_ADDREF_P(P_ZEVAL(queue_intern->zrk));
-+ Z_ADDREF_P(&queue_intern->zrk);
-
- zend_hash_index_add_ptr(&intern->queues, (zend_ulong)queue_intern, queue_intern);
- }
-@@ -492,7 +492,7 @@ PHP_METHOD(RdKafka__Kafka, newTopic)
- #else
- topic_intern->zrk = getThis();
- #endif
-- Z_ADDREF_P(P_ZEVAL(topic_intern->zrk));
-+ Z_ADDREF_P(&topic_intern->zrk);
-
- zend_hash_index_add_ptr(&intern->topics, (zend_ulong)topic_intern, topic_intern);
- }
-@@ -623,8 +623,8 @@ PHP_METHOD(RdKafka__Kafka, queryWatermarkOffsets)
- return;
- }
-
-- ZEVAL_DEREF(lowResult);
-- ZEVAL_DEREF(highResult);
-+ ZVAL_DEREF(lowResult);
-+ ZVAL_DEREF(highResult);
-
- intern = get_kafka_object(getThis());
- if (!intern) {
-diff --git a/topic.c b/topic.c
-index 389ae4a..f834ce3 100644
---- a/topic.c
-+++ b/topic.c
-@@ -47,8 +47,8 @@ static void kafka_topic_free(zend_object *object) /* {{{ */
- {
- kafka_topic_object *intern = get_custom_object(kafka_topic_object, object);
-
-- if (ZE_ISDEF(intern->zrk) && intern->rkt) {
-- kafka_object *kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
-+ if (Z_TYPE(intern->zrk) != IS_UNDEF && intern->rkt) {
-+ kafka_object *kafka_intern = get_kafka_object(&intern->zrk);
- if (kafka_intern) {
- zend_hash_index_del(&kafka_intern->topics, (zend_ulong)intern);
- }
-@@ -80,7 +80,7 @@ static zend_object_value kafka_topic_new(zend_class_entry *class_type) /* {{{ */
- static void consume_callback(rd_kafka_message_t *msg, void *opaque)
- {
- php_callback *cb = (php_callback*) opaque;
-- zeval args[1];
-+ zval args[1];
- TSRMLS_FETCH();
-
- if (!opaque) {
-@@ -91,9 +91,9 @@ static void consume_callback(rd_kafka_message_t *msg, void *opaque)
- return;
- }
-
-- MAKE_STD_ZEVAL(args[0]);
-+ ZVAL_NULL(&args[0]);
-
-- kafka_message_new(P_ZEVAL(args[0]), msg);
-+ kafka_message_new(&args[0], msg);
-
- rdkafka_call_function(&cb->fci, &cb->fcc, NULL, 1, args);
-
-@@ -142,7 +142,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeCallback)
- return;
- }
-
-- Z_ADDREF_P(P_ZEVAL(cb.fci.function_name));
-+ Z_ADDREF_P(&cb.fci.function_name);
-
- result = rd_kafka_consume_callback(intern->rkt, partition, timeout_ms, consume_callback, &cb);
-
-@@ -191,7 +191,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeQueueStart)
- return;
- }
-
-- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
-+ kafka_intern = get_kafka_object(&intern->zrk);
- if (!kafka_intern) {
- return;
- }
-@@ -250,7 +250,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStart)
- return;
- }
-
-- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
-+ kafka_intern = get_kafka_object(&intern->zrk);
- if (!kafka_intern) {
- return;
- }
-@@ -307,7 +307,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStop)
- return;
- }
-
-- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
-+ kafka_intern = get_kafka_object(&intern->zrk);
- if (!kafka_intern) {
- return;
- }
-@@ -562,7 +562,7 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
- HashTable *headersParam = NULL;
- HashPosition headersParamPos;
- char *header_key;
-- zeval *header_value;
-+ zval *header_value;
- rd_kafka_headers_t *headers;
- zend_long timestamp_ms = 0;
- zend_bool timestamp_ms_is_null = 0;
-@@ -598,15 +598,15 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
- headers,
- header_key,
- -1, // Auto detect header title length
-- Z_STRVAL_P(ZEVAL(header_value)),
-- Z_STRLEN_P(ZEVAL(header_value))
-+ Z_STRVAL_P(header_value),
-+ Z_STRLEN_P(header_value)
- );
- }
- } else {
- headers = rd_kafka_headers_new(0);
- }
-
-- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk));
-+ kafka_intern = get_kafka_object(&intern->zrk);
- if (!kafka_intern) {
- return;
- }
-diff --git a/topic.h b/topic.h
-index 78beec3..e6bbbd5 100644
---- a/topic.h
-+++ b/topic.h
-@@ -16,14 +16,12 @@
- +----------------------------------------------------------------------+
- */
-
--#include "zeval.h"
--
- typedef struct _kafka_topic_object {
- #if PHP_MAJOR_VERSION < 7
- zend_object std;
- #endif
- rd_kafka_topic_t *rkt;
-- zeval zrk;
-+ zval zrk;
- #if PHP_MAJOR_VERSION >= 7
- zend_object std;
- #endif
-diff --git a/topic_partition.c b/topic_partition.c
-index f9a08d9..c71a17b 100644
---- a/topic_partition.c
-+++ b/topic_partition.c
-@@ -29,7 +29,6 @@
- #include "Zend/zend_exceptions.h"
- #include "ext/spl/spl_exceptions.h"
- #include "topic_partition.h"
--#include "zeval.h"
-
- typedef kafka_topic_partition_intern object_intern;
-
-@@ -134,17 +133,17 @@ void kafka_topic_partition_init(zval *zobj, char * topic, int32_t partition, int
- void kafka_topic_partition_list_to_array(zval *return_value, rd_kafka_topic_partition_list_t *list) /* {{{ */
- {
- rd_kafka_topic_partition_t *topar;
-- zeval ztopar;
-+ zval ztopar;
- int i;
-
- array_init_size(return_value, list->cnt);
-
- for (i = 0; i < list->cnt; i++) {
- topar = &list->elems[i];
-- MAKE_STD_ZEVAL(ztopar);
-- object_init_ex(P_ZEVAL(ztopar), ce_kafka_topic_partition);
-- kafka_topic_partition_init(P_ZEVAL(ztopar), topar->topic, topar->partition, topar->offset);
-- add_next_index_zval(return_value, P_ZEVAL(ztopar));
-+ ZVAL_NULL(&ztopar);
-+ object_init_ex(&ztopar, ce_kafka_topic_partition);
-+ kafka_topic_partition_init(&ztopar, topar->topic, topar->partition, topar->offset);
-+ add_next_index_zval(return_value, &ztopar);
- }
- } /* }}} */
-
-@@ -152,7 +151,7 @@ rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int ar
-
- HashPosition pos;
- rd_kafka_topic_partition_list_t *list;
-- zeval *zv;
-+ zval *zv;
-
- list = rd_kafka_topic_partition_list_new(zend_hash_num_elements(ary));
-
-@@ -162,7 +161,7 @@ rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int ar
- kafka_topic_partition_intern *topar_intern;
- rd_kafka_topic_partition_t *topar;
-
-- if (Z_TYPE_P(ZEVAL(zv)) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(ZEVAL(zv)), ce_kafka_topic_partition)) {
-+ if (Z_TYPE_P(zv) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(zv), ce_kafka_topic_partition)) {
- const char *space;
- const char *class_name = get_active_class_name(&space);
- rd_kafka_topic_partition_list_destroy(list);
-@@ -171,11 +170,11 @@ rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int ar
- argnum,
- class_name, space,
- get_active_function_name(),
-- zend_zval_type_name(ZEVAL(zv)));
-+ zend_zval_type_name(zv));
- return NULL;
- }
-
-- topar_intern = get_topic_partition_object(ZEVAL(zv));
-+ topar_intern = get_topic_partition_object(zv);
- if (!topar_intern) {
- rd_kafka_topic_partition_list_destroy(list);
- return NULL;
-diff --git a/zeval.h b/zeval.h
-deleted file mode 100644
-index 74c2711..0000000
---- a/zeval.h
-+++ /dev/null
-@@ -1,71 +0,0 @@
--#ifndef incl_ZEVAL_H
--#define incl_ZEVAL_H
--
--#ifdef HAVE_CONFIG_H
--# include "config.h"
--#endif
--
--#include "php.h"
--
--/***************************************************************************/
--#ifdef ZEND_ENGINE_3
--
--typedef zval zeval;
--
--#define ZEVAL(v) (v)
--#define P_ZEVAL(v) (&(v))
--
--#define MAKE_STD_ZEVAL(v) ZVAL_NULL(&v)
--#define ZEVAL_UNINIT(v) ZVAL_NULL(v)
--
--#define ZE_ISDEF(v) (Z_TYPE(v) != IS_UNDEF)
--#define ZE_TYPE(v) Z_TYPE(v)
--#define ZE_BVAL(v) Z_BVAL(v)
--#define ZE_LVAL(V) Z_LVAL(v)
--#define ZE_DVAL(v) Z_DVAL(v)
--#define ZE_STRVAL(v) Z_STRVAL(v)
--#define ZE_STRLEN(v) Z_STRLEN(v)
--#define ZE_ARRVAL(v) Z_ARRVAL(v)
--#define ZE_OBJCE(v) Z_OBJCE(v)
--
--#define ZEVAL_DUP_C
--#define ZEVAL_DUP_CC
--
--#define ZEVAL_DEREF(v) ZVAL_DEREF(v)
--
--/***************************************************************************/
--#elif defined(ZEND_ENGINE_2)
--
--typedef zval* zeval;
--
--#define ZEVAL(v) (*(v))
--#define P_ZEVAL(v) (v)
--
--#define MAKE_STD_ZEVAL(v) MAKE_STD_ZVAL(v)
--#define ZEVAL_UNINIT(v) (v = NULL)
--
--#define ZE_ISDEF(v) (v)
--#define IS_TRUE 14
--#define IS_FALSE 15
--#define ZE_TYPE(v) ((Z_TYPE_P(v) == IS_BOOL) \
-- ? (Z_BVAL_P(v) ? IS_TRUE : IS_FALSE) \
-- : Z_TYPE_P(v))
--#define ZE_BVAL(v) Z_BVAL_P(v)
--#define ZE_LVAL(V) Z_LVAL_P(v)
--#define ZE_DVAL(v) Z_DVAL_P(v)
--#define ZE_STRVAL(v) Z_STRVAL_P(v)
--#define ZE_STRLEN(v) Z_STRLEN_P(v)
--#define ZE_ARRVAL(v) Z_ARRVAL_P(v)
--#define ZE_OBJCE(v) Z_OBJCE_P(v)
--
--#define ZEVAL_DUP_C 1
--#define ZEVAL_DUP_CC , 1
--
--#define ZEVAL_DEREF(v) (v)
--
--/***************************************************************************/
--#else
--# error "Unknown Zend Engine version"
--#endif
--
--#endif
-From b2af8a5ce918287ded20a6ebc0a3d46c530e2626 Mon Sep 17 00:00:00 2001
-From: Arnaud Le Blanc <arnaud.lb@gmail.com>
-Date: Mon, 7 Dec 2020 12:46:13 +0100
-Subject: [PATCH] Drop remaining php5 compatibility code (#405)
-
-Co-authored-by: Nick <nickjobszh@gmail.com>
----
- compat.c | 33 --------
- compat.h | 33 --------
- conf.c | 55 +++++--------
- conf.h | 5 --
- config.m4 | 2 +-
- config.w32 | 2 +-
- fun.c | 6 +-
- kafka_consumer.c | 27 +++---
- kafka_error_exception.c | 20 +----
- message.c | 4 +-
- metadata.c | 25 ++----
- metadata_broker.c | 25 ++----
- metadata_collection.c | 21 ++---
- metadata_partition.c | 21 ++---
- metadata_topic.c | 25 ++----
- php_rdkafka.h | 6 --
- php_rdkafka_priv.h | 178 ----------------------------------------
- queue.c | 16 ++--
- queue.h | 5 --
- rdkafka.c | 40 +++------
- topic.c | 35 ++++----
- topic.h | 5 --
- topic_partition.c | 24 +++---
- topic_partition.h | 5 --
- 24 files changed, 128 insertions(+), 490 deletions(-)
- delete mode 100644 compat.c
- delete mode 100644 compat.h
-
-diff --git a/compat.c b/compat.c
-deleted file mode 100644
-index 6643978..0000000
---- a/compat.c
-+++ /dev/null
-@@ -1,33 +0,0 @@
--/*
-- +----------------------------------------------------------------------+
-- | php-rdkafka |
-- +----------------------------------------------------------------------+
-- | Copyright (c) 2016 Arnaud Le Blanc |
-- +----------------------------------------------------------------------+
-- | This source file is subject to version 3.01 of the PHP license, |
-- | that is bundled with this package in the file LICENSE, and is |
-- | available through the world-wide-web at the following url: |
-- | http://www.php.net/license/3_01.txt |
-- | If you did not receive a copy of the PHP license and are unable to |
-- | obtain it through the world-wide-web, please send a note to |
-- | license@php.net so we can mail you a copy immediately. |
-- +----------------------------------------------------------------------+
-- | Author: Arnaud Le Blanc <arnaud.lb@gmail.com> |
-- +----------------------------------------------------------------------+
--*/
--
--#ifdef HAVE_CONFIG_H
--#include "config.h"
--#endif
--
--#include "php.h"
--#include "php_ini.h"
--
--#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4
--void rdkafka_object_properties_init_53(zend_object *object, zend_class_entry *class_type) /* {{{ */
--{
-- zval * tmp;
-- zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
--}
--/* }}} */
--#endif
-diff --git a/compat.h b/compat.h
-deleted file mode 100644
-index c9f8b6d..0000000
---- a/compat.h
-+++ /dev/null
-@@ -1,33 +0,0 @@
--/*
-- +----------------------------------------------------------------------+
-- | php-rdkafka |
-- +----------------------------------------------------------------------+
-- | Copyright (c) 2016 Arnaud Le Blanc |
-- +----------------------------------------------------------------------+
-- | This source file is subject to version 3.01 of the PHP license, |
-- | that is bundled with this package in the file LICENSE, and is |
-- | available through the world-wide-web at the following url: |
-- | http://www.php.net/license/3_01.txt |
-- | If you did not receive a copy of the PHP license and are unable to |
-- | obtain it through the world-wide-web, please send a note to |
-- | license@php.net so we can mail you a copy immediately. |
-- +----------------------------------------------------------------------+
-- | Author: Arnaud Le Blanc <arnaud.lb@gmail.com> |
-- +----------------------------------------------------------------------+
--*/
--
--#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4
--void rdkafka_object_properties_init_53(zend_object *object, zend_class_entry *class_type);
--#define object_properties_init rdkafka_object_properties_init_53
--#endif
--
--#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 6
--# define KAFKA_ZVAL_ZVAL(z, zv, copy, dtor) do { \
-- zval * ___z = (z); \
-- zval * ___zv = (zv); \
-- ZVAL_ZVAL(___z, ___zv, copy, dtor); \
-- } while (0)
--#else
--# define KAFKA_ZVAL_ZVAL ZVAL_ZVAL
--#endif
--
-diff --git a/conf.c b/conf.c
-index 6e814b7..ec171c6 100644
---- a/conf.c
-+++ b/conf.c
-@@ -68,11 +68,7 @@ static void kafka_conf_callback_copy(kafka_conf_callback **to, kafka_conf_callba
- if (from) {
- *to = emalloc(sizeof(**to));
- **to = *from;
--#if PHP_MAJOR_VERSION >= 7
- zval_copy_ctor(&(*to)->fci.function_name);
--#else
-- Z_ADDREF_P((*to)->fci.function_name);
--#endif
- }
- } /* }}} */
-
-@@ -106,22 +102,20 @@ static void kafka_conf_free(zend_object *object) /* {{{ */
- }
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
--static zend_object_value kafka_conf_new(zend_class_entry *class_type) /* {{{ */
-+static zend_object *kafka_conf_new(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- kafka_conf_object *intern;
-
-- intern = alloc_object(intern, class_type);
-+ intern = zend_object_alloc(sizeof(*intern), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_conf_free, NULL);
-- SET_OBJECT_HANDLERS(retval, &handlers);
-+ retval = &intern->std;
-+ retval->handlers = &handlers;
-
- return retval;
- }
-@@ -143,7 +137,6 @@ static void kafka_conf_error_cb(rd_kafka_t *rk, int err, const char *reason, voi
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
- zval args[3];
-- TSRMLS_FETCH();
-
- if (!opaque) {
- return;
-@@ -157,9 +150,9 @@ static void kafka_conf_error_cb(rd_kafka_t *rk, int err, const char *reason, voi
- ZVAL_NULL(&args[1]);
- ZVAL_NULL(&args[2]);
-
-- KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
- ZVAL_LONG(&args[1], err);
-- RDKAFKA_ZVAL_STRING(&args[2], reason);
-+ ZVAL_STRING(&args[2], reason);
-
- rdkafka_call_function(&cbs->error->fci, &cbs->error->fcc, NULL, 3, args);
-
-@@ -172,7 +165,6 @@ static void kafka_conf_dr_msg_cb(rd_kafka_t *rk, const rd_kafka_message_t *msg,
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
- zval args[2];
-- TSRMLS_FETCH();
-
- if (!opaque) {
- return;
-@@ -185,7 +177,7 @@ static void kafka_conf_dr_msg_cb(rd_kafka_t *rk, const rd_kafka_message_t *msg,
- ZVAL_NULL(&args[0]);
- ZVAL_NULL(&args[1]);
-
-- KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
- kafka_message_new(&args[1], msg);
-
- rdkafka_call_function(&cbs->dr_msg->fci, &cbs->dr_msg->fcc, NULL, 2, args);
-@@ -198,7 +190,6 @@ static int kafka_conf_stats_cb(rd_kafka_t *rk, char *json, size_t json_len, void
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
- zval args[3];
-- TSRMLS_FETCH();
-
- if (!opaque) {
- return 0;
-@@ -212,8 +203,8 @@ static int kafka_conf_stats_cb(rd_kafka_t *rk, char *json, size_t json_len, void
- ZVAL_NULL(&args[1]);
- ZVAL_NULL(&args[2]);
-
-- KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-- RDKAFKA_ZVAL_STRING(&args[1], json);
-+ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ ZVAL_STRING(&args[1], json);
- ZVAL_LONG(&args[2], json_len);
-
- rdkafka_call_function(&cbs->stats->fci, &cbs->stats->fcc, NULL, 3, args);
-@@ -229,7 +220,6 @@ static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
- zval args[3];
-- TSRMLS_FETCH();
-
- if (!opaque) {
- return;
-@@ -250,7 +240,7 @@ static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_
- ZVAL_NULL(&args[1]);
- ZVAL_NULL(&args[2]);
-
-- KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
- ZVAL_LONG(&args[1], err);
- kafka_topic_partition_list_to_array(&args[2], partitions);
-
-@@ -265,7 +255,6 @@ static void kafka_conf_consume_cb(rd_kafka_message_t *msg, void *opaque)
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
- zval args[2];
-- TSRMLS_FETCH();
-
- if (!opaque) {
- return;
-@@ -279,7 +268,7 @@ static void kafka_conf_consume_cb(rd_kafka_message_t *msg, void *opaque)
- ZVAL_NULL(&args[1]);
-
- kafka_message_new(&args[0], msg);
-- KAFKA_ZVAL_ZVAL(&args[1], &cbs->zrk, 1, 0);
-+ ZVAL_ZVAL(&args[1], &cbs->zrk, 1, 0);
-
-
- rdkafka_call_function(&cbs->consume->fci, &cbs->consume->fcc, NULL, 2, args);
-@@ -292,7 +281,6 @@ static void kafka_conf_offset_commit_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err,
- {
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) opaque;
- zval args[3];
-- TSRMLS_FETCH();
-
- if (!opaque) {
- return;
-@@ -306,7 +294,7 @@ static void kafka_conf_offset_commit_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err,
- ZVAL_NULL(&args[1]);
- ZVAL_NULL(&args[2]);
-
-- KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
- ZVAL_LONG(&args[1], err);
- kafka_topic_partition_list_to_array(&args[2], partitions);
-
-@@ -320,7 +308,6 @@ static void kafka_conf_offset_commit_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err,
- static void kafka_conf_log_cb(const rd_kafka_t *rk, int level, const char *facility, const char *message)
- {
- zval args[4];
-- TSRMLS_FETCH();
-
- kafka_conf_callbacks *cbs = (kafka_conf_callbacks*) rd_kafka_opaque(rk);
-
-@@ -333,10 +320,10 @@ static void kafka_conf_log_cb(const rd_kafka_t *rk, int level, const char *facil
- ZVAL_NULL(&args[2]);
- ZVAL_NULL(&args[3]);
-
-- KAFKA_ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
-+ ZVAL_ZVAL(&args[0], &cbs->zrk, 1, 0);
- ZVAL_LONG(&args[1], level);
-- RDKAFKA_ZVAL_STRING(&args[2], facility);
-- RDKAFKA_ZVAL_STRING(&args[3], message);
-+ ZVAL_STRING(&args[2], facility);
-+ ZVAL_STRING(&args[3], message);
-
- rdkafka_call_function(&cbs->log->fci, &cbs->log->fcc, NULL, 4, args);
-
-@@ -409,7 +396,7 @@ PHP_METHOD(RdKafka__Conf, dump)
- for (i = 0; i < cntp; i+=2) {
- const char *key = dump[i];
- const char *value = dump[i+1];
-- rdkafka_add_assoc_string(return_value, (char*)key, (char*)value);
-+ add_assoc_string(return_value, (char*)key, (char*)value);
- }
-
- rd_kafka_conf_dump_free(dump, cntp);
-@@ -427,9 +414,9 @@ ZEND_END_ARG_INFO()
- PHP_METHOD(RdKafka__Conf, set)
- {
- char *name;
-- arglen_t name_len;
-+ size_t name_len;
- char *value;
-- arglen_t value_len;
-+ size_t value_len;
- kafka_conf_object *intern;
- rd_kafka_conf_res_t ret = 0;
- char errstr[512];
-@@ -858,8 +845,8 @@ void kafka_conf_minit()
- zend_class_entry tmpce;
-
- handlers = kafka_default_object_handlers;
-- set_object_handler_free_obj(&handlers, kafka_conf_free);
-- set_object_handler_offset(&handlers, XtOffsetOf(kafka_conf_object, std));
-+ handlers.free_obj = kafka_conf_free;
-+ handlers.offset = XtOffsetOf(kafka_conf_object, std);
-
- INIT_NS_CLASS_ENTRY(tmpce, "RdKafka", "Conf", kafka_conf_fe);
- ce_kafka_conf = zend_register_internal_class(&tmpce);
-diff --git a/conf.h b/conf.h
-index 4bf13b2..673e14c 100644
---- a/conf.h
-+++ b/conf.h
-@@ -49,18 +49,13 @@ typedef struct _kafka_conf_callbacks {
- } kafka_conf_callbacks;
-
- typedef struct _kafka_conf_object {
--#if PHP_MAJOR_VERSION < 7
-- zend_object std;
--#endif
- kafka_conf_type type;
- union {
- rd_kafka_conf_t *conf;
- rd_kafka_topic_conf_t *topic_conf;
- } u;
- kafka_conf_callbacks cbs;
--#if PHP_MAJOR_VERSION >= 7
- zend_object std;
--#endif
- } kafka_conf_object;
-
- kafka_conf_object * get_kafka_conf_object(zval *zconf);
-diff --git a/config.m4 b/config.m4
-index 3f4a654..9df6b31 100644
---- a/config.m4
-+++ b/config.m4
-@@ -27,7 +27,7 @@ if test "$PHP_RDKAFKA" != "no"; then
-
- PHP_ADD_INCLUDE($RDKAFKA_DIR/include)
-
-- SOURCES="rdkafka.c metadata.c metadata_broker.c metadata_topic.c metadata_partition.c metadata_collection.c compat.c conf.c topic.c queue.c message.c fun.c kafka_consumer.c topic_partition.c"
-+ SOURCES="rdkafka.c metadata.c metadata_broker.c metadata_topic.c metadata_partition.c metadata_collection.c conf.c topic.c queue.c message.c fun.c kafka_consumer.c topic_partition.c"
-
- LIBNAME=rdkafka
- LIBSYMBOL=rd_kafka_new
-diff --git a/config.w32 b/config.w32
-index 451692e..837ef38 100644
---- a/config.w32
-+++ b/config.w32
-@@ -11,7 +11,7 @@ if (PHP_RDKAFKA != "no") {
- AC_DEFINE('HAVE_RD_KAFKA_GET_ERR_DESCS', 1, '');
- AC_DEFINE('HAVE_NEW_KAFKA_CONSUMER', 1, '');
- EXTENSION("rdkafka", "rdkafka.c metadata.c metadata_broker.c metadata_topic.c \
-- metadata_partition.c metadata_collection.c compat.c conf.c \
-+ metadata_partition.c metadata_collection.c conf.c \
- topic.c queue.c message.c fun.c kafka_consumer.c topic_partition.c kafka_error_exception.c");
-
- AC_DEFINE('HAVE_RDKAFKA', 1, '');
-diff --git a/fun.c b/fun.c
-index 77053ec..d73e202 100644
---- a/fun.c
-+++ b/fun.c
-@@ -83,12 +83,12 @@ PHP_FUNCTION(rd_kafka_get_err_descs)
- array_init(&el);
- add_assoc_long(&el, "code", desc->code);
- if (desc->name) {
-- rdkafka_add_assoc_string(&el, "name", (char*) desc->name);
-+ add_assoc_string(&el, "name", (char*) desc->name);
- } else {
- add_assoc_null(&el, "name");
- }
- if (desc->desc) {
-- rdkafka_add_assoc_string(&el, "desc", (char*) desc->desc);
-+ add_assoc_string(&el, "desc", (char*) desc->desc);
- }else {
- add_assoc_null(&el, "desc");
- }
-@@ -112,7 +112,7 @@ PHP_FUNCTION(rd_kafka_err2str)
- errstr = rd_kafka_err2str(err);
-
- if (errstr) {
-- RDKAFKA_RETURN_STRING(errstr);
-+ RETURN_STRING(errstr);
- }
- }
- /* }}} */
-diff --git a/kafka_consumer.c b/kafka_consumer.c
-index 0c604b6..8cc4b9d 100644
---- a/kafka_consumer.c
-+++ b/kafka_consumer.c
-@@ -33,14 +33,9 @@
- #include "metadata.h"
-
- typedef struct _object_intern {
--#if PHP_MAJOR_VERSION < 7
-- zend_object std;
--#endif
- rd_kafka_t *rk;
- kafka_conf_callbacks cbs;
--#if PHP_MAJOR_VERSION >= 7
- zend_object std;
--#endif
- } object_intern;
-
- static zend_class_entry * ce;
-@@ -66,22 +61,20 @@ static void kafka_consumer_free(zend_object *object) /* {{{ */
- kafka_conf_callbacks_dtor(&intern->cbs);
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
--static zend_object_value kafka_consumer_new(zend_class_entry *class_type) /* {{{ */
-+static zend_object *kafka_consumer_new(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- object_intern *intern;
-
-- intern = alloc_object(intern, class_type);
-+ intern = zend_object_alloc(sizeof(*intern), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_consumer_free, NULL);
-- SET_OBJECT_HANDLERS(retval, &handlers);
-+ retval = &intern->std;
-+ retval->handlers = &handlers;
-
- return retval;
- }
-@@ -285,7 +278,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, subscribe)
- topics = rd_kafka_topic_partition_list_new(zend_hash_num_elements(htopics));
-
- for (zend_hash_internal_pointer_reset_ex(htopics, &pos);
-- (zv = rdkafka_hash_get_current_data_ex(htopics, &pos)) != NULL;
-+ (zv = zend_hash_get_current_data_ex(htopics, &pos)) != NULL;
- zend_hash_move_forward_ex(htopics, &pos)) {
- convert_to_string_ex(zv);
- rd_kafka_topic_partition_list_add(topics, Z_STRVAL_P(zv), RD_KAFKA_PARTITION_UA);
-@@ -593,7 +586,7 @@ ZEND_END_ARG_INFO()
- PHP_METHOD(RdKafka__KafkaConsumer, newTopic)
- {
- char *topic;
-- arglen_t topic_len;
-+ size_t topic_len;
- rd_kafka_topic_t *rkt;
- object_intern *intern;
- kafka_topic_object *topic_intern;
-@@ -775,7 +768,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, queryWatermarkOffsets)
- {
- object_intern *intern;
- char *topic;
-- arglen_t topic_length;
-+ size_t topic_length;
- long low, high;
- zend_long partition, timeout;
- zval *lowResult, *highResult;
-@@ -834,8 +827,8 @@ void kafka_kafka_consumer_minit() /* {{{ */
- ce->create_object = kafka_consumer_new;
-
- handlers = kafka_default_object_handlers;
-- set_object_handler_free_obj(&handlers, kafka_consumer_free);
-- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
-+ handlers.free_obj = kafka_consumer_free;
-+ handlers.offset = XtOffsetOf(object_intern, std);
-
- zend_declare_property_null(ce, ZEND_STRL("error_cb"), ZEND_ACC_PRIVATE);
- zend_declare_property_null(ce, ZEND_STRL("rebalance_cb"), ZEND_ACC_PRIVATE);
-diff --git a/kafka_error_exception.c b/kafka_error_exception.c
-index 5ab27e5..b1cd9a8 100644
---- a/kafka_error_exception.c
-+++ b/kafka_error_exception.c
-@@ -57,7 +57,7 @@ ZEND_END_ARG_INFO()
- PHP_METHOD(RdKafka__KafkaErrorException, __construct)
- {
- char *message, *error_string = "";
-- arglen_t message_length = 0, error_string_length = 0;
-+ size_t message_length = 0, error_string_length = 0;
- zend_bool isFatal = 0, isRetriable = 0, transactionRequiresAbort = 0;
- zend_long code = 0;
-
-@@ -94,12 +94,8 @@ PHP_METHOD(RdKafka__KafkaErrorException, getErrorString)
- return;
- }
-
--#if PHP_MAJOR_VERSION >= 7
- ZVAL_DEREF(res);
- ZVAL_COPY(return_value, res);
--#else
-- RETURN_ZVAL(res, 1, 0)
--#endif
- }
- /* }}} */
-
-@@ -120,16 +116,12 @@ PHP_METHOD(RdKafka__KafkaErrorException, isFatal)
-
- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("isFatal"), 0);
-
--#if PHP_MAJOR_VERSION >= 7
- if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) {
- return;
- }
-
- ZVAL_DEREF(res);
- ZVAL_COPY(return_value, res);
--#else
-- RETURN_ZVAL(res, 1, 0)
--#endif
- }
- /* }}} */
-
-@@ -149,16 +141,12 @@ PHP_METHOD(RdKafka__KafkaErrorException, isRetriable)
-
- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("isRetriable"), 0);
-
--#if PHP_MAJOR_VERSION >= 7
- if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) {
- return;
- }
-
- ZVAL_DEREF(res);
- ZVAL_COPY(return_value, res);
--#else
-- RETURN_ZVAL(res, 1, 0)
--#endif
- }
- /* }}} */
-
-@@ -178,16 +166,12 @@ PHP_METHOD(RdKafka__KafkaErrorException, transactionRequiresAbort)
-
- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("transactionRequiresAbort"), 0);
-
--#if PHP_MAJOR_VERSION >= 7
- if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) {
- return;
- }
-
- ZVAL_DEREF(res);
- ZVAL_COPY(return_value, res);
--#else
-- RETURN_ZVAL(res, 1, 0)
--#endif
- }
- /* }}} */
-
-@@ -205,7 +189,7 @@ void kafka_error_minit() /* {{{ */
- zend_class_entry ce;
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "KafkaErrorException", kafka_error_fe);
-- ce_kafka_error = rdkafka_register_internal_class_ex(&ce, ce_kafka_exception);
-+ ce_kafka_error = zend_register_internal_class_ex(&ce, ce_kafka_exception);
-
- zend_declare_property_null(ce_kafka_error, ZEND_STRL("error_string"), ZEND_ACC_PRIVATE);
- zend_declare_property_bool(ce_kafka_error, ZEND_STRL("isFatal"), 0, ZEND_ACC_PRIVATE);
-diff --git a/message.c b/message.c
-index 7348971..a6ed916 100644
---- a/message.c
-+++ b/message.c
-@@ -77,7 +77,7 @@ void kafka_message_new(zval *return_value, const rd_kafka_message_t *message)
- if (header_response != RD_KAFKA_RESP_ERR_NO_ERROR) {
- break;
- }
-- rdkafka_add_assoc_stringl(&headers_array, header_name, (const char*)header_value, header_size);
-+ add_assoc_stringl(&headers_array, header_name, (const char*)header_value, header_size);
- }
- zend_update_property(NULL, return_value, ZEND_STRL("headers"), &headers_array);
- zval_ptr_dtor(&headers_array);
-@@ -128,7 +128,7 @@ PHP_METHOD(RdKafka__Message, errstr)
- errstr = rd_kafka_err2str(Z_LVAL_P(zerr));
-
- if (errstr) {
-- RDKAFKA_RETURN_STRING(errstr);
-+ RETURN_STRING(errstr);
- }
-
- zpayload = rdkafka_read_property(NULL, getThis(), ZEND_STRL("payload"), 0);
-diff --git a/metadata.c b/metadata.c
-index 7d7a6d1..a43123c 100644
---- a/metadata.c
-+++ b/metadata.c
-@@ -31,13 +31,8 @@
- #include "Zend/zend_exceptions.h"
-
- typedef struct _object_intern {
--#if PHP_MAJOR_VERSION < 7
-- zend_object std;
--#endif
- const rd_kafka_metadata_t *metadata;
--#if PHP_MAJOR_VERSION >= 7
- zend_object std;
--#endif
- } object_intern;
-
- static HashTable *get_debug_info(zval *object, int *is_temp);
-@@ -64,22 +59,20 @@ static void kafka_metadata_free(zend_object *object) /* {{{ */
- }
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
--static zend_object_value kafka_metadata_new(zend_class_entry *class_type) /* {{{ */
-+static zend_object *kafka_metadata_new(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- object_intern *intern;
-
-- intern = alloc_object(intern, class_type);
-+ intern = zend_object_alloc(sizeof(*intern), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_metadata_free, NULL);
-- SET_OBJECT_HANDLERS(retval, &handlers);
-+ retval = &intern->std;
-+ retval->handlers = &handlers;
-
- return retval;
- }
-@@ -122,7 +115,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
- add_assoc_zval(&ary, "topics", &topics);
-
- add_assoc_long(&ary, "orig_broker_id", intern->metadata->orig_broker_id);
-- rdkafka_add_assoc_string(&ary, "orig_broker_name", intern->metadata->orig_broker_name);
-+ add_assoc_string(&ary, "orig_broker_name", intern->metadata->orig_broker_name);
-
- return Z_ARRVAL(ary);
- }
-@@ -170,7 +163,7 @@ PHP_METHOD(RdKafka__Metadata, getOrigBrokerName)
- return;
- }
-
-- RDKAFKA_RETURN_STRING(intern->metadata->orig_broker_name);
-+ RETURN_STRING(intern->metadata->orig_broker_name);
- }
- /* }}} */
-
-@@ -238,8 +231,8 @@ void kafka_metadata_minit()
-
- handlers = kafka_default_object_handlers;
- handlers.get_debug_info = get_debug_info;
-- set_object_handler_free_obj(&handlers, kafka_metadata_free);
-- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
-+ handlers.free_obj = kafka_metadata_free;
-+ handlers.offset = XtOffsetOf(object_intern, std);
-
- kafka_metadata_topic_minit();
- kafka_metadata_broker_minit();
-diff --git a/metadata_broker.c b/metadata_broker.c
-index d7df197..db9b4e3 100644
---- a/metadata_broker.c
-+++ b/metadata_broker.c
-@@ -29,14 +29,9 @@
- #include "Zend/zend_exceptions.h"
-
- typedef struct _object_intern {
--#if PHP_MAJOR_VERSION < 7
-- zend_object std;
--#endif
- zval zmetadata;
- const rd_kafka_metadata_broker_t *metadata_broker;
--#if PHP_MAJOR_VERSION >= 7
- zend_object std;
--#endif
- } object_intern;
-
- static HashTable *get_debug_info(zval *object, int *is_temp);
-@@ -53,23 +48,21 @@ static void free_object(zend_object *object) /* {{{ */
- }
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
--static zend_object_value create_object(zend_class_entry *class_type) /* {{{ */
-+static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- object_intern *intern;
-
-- intern = alloc_object(intern, class_type);
-+ intern = zend_object_alloc(sizeof(*intern), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
-- SET_OBJECT_HANDLERS(retval, &handlers);
-+ retval = &intern->std;
-+ retval->handlers = &handlers;
-
- return retval;
- }
-@@ -102,7 +95,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
- }
-
- add_assoc_long(&ary, "id", intern->metadata_broker->id);
-- rdkafka_add_assoc_string(&ary, "host", intern->metadata_broker->host);
-+ add_assoc_string(&ary, "host", intern->metadata_broker->host);
- add_assoc_long(&ary, "port", intern->metadata_broker->port);
-
- return Z_ARRVAL(ary);
-@@ -151,7 +144,7 @@ PHP_METHOD(RdKafka__Metadata__Broker, getHost)
- return;
- }
-
-- RDKAFKA_RETURN_STRING(intern->metadata_broker->host);
-+ RETURN_STRING(intern->metadata_broker->host);
- }
- /* }}} */
-
-@@ -195,8 +188,8 @@ void kafka_metadata_broker_minit()
-
- handlers = kafka_default_object_handlers;
- handlers.get_debug_info = get_debug_info;
-- set_object_handler_free_obj(&handlers, free_object);
-- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
-+ handlers.free_obj = free_object;
-+ handlers.offset = XtOffsetOf(object_intern, std);
- }
-
- void kafka_metadata_broker_ctor(zval *return_value, zval *zmetadata, const void *data)
-diff --git a/metadata_collection.c b/metadata_collection.c
-index 168465f..460b3bc 100644
---- a/metadata_collection.c
-+++ b/metadata_collection.c
-@@ -30,18 +30,13 @@
- #include "Zend/zend_exceptions.h"
-
- typedef struct _object_intern {
--#if PHP_MAJOR_VERSION < 7
-- zend_object std;
--#endif
- zval zmetadata;
- const void *items;
- size_t item_cnt;
- size_t item_size;
- size_t position;
- kafka_metadata_collection_ctor_t ctor;
--#if PHP_MAJOR_VERSION >= 7
- zend_object std;
--#endif
- } object_intern;
-
- static HashTable *get_debug_info(zval *object, int *is_temp);
-@@ -58,22 +53,20 @@ static void free_object(zend_object *object) /* {{{ */
- }
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
--static zend_object_value create_object(zend_class_entry *class_type) /* {{{ */
-+static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- object_intern *intern;
-
-- intern = alloc_object(intern, class_type);
-+ intern = zend_object_alloc(sizeof(*intern), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
-- SET_OBJECT_HANDLERS(retval, &handlers);
-+ retval = &intern->std;
-+ retval->handlers = &handlers;
-
- return retval;
- }
-@@ -286,8 +279,8 @@ void kafka_metadata_collection_minit()
-
- handlers = kafka_default_object_handlers;
- handlers.get_debug_info = get_debug_info;
-- set_object_handler_free_obj(&handlers, free_object);
-- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
-+ handlers.free_obj = free_object;
-+ handlers.offset = XtOffsetOf(object_intern, std);
- }
-
- void kafka_metadata_collection_init(zval *return_value, zval *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor)
-diff --git a/metadata_partition.c b/metadata_partition.c
-index 70b7430..6f5f08f 100644
---- a/metadata_partition.c
-+++ b/metadata_partition.c
-@@ -30,14 +30,9 @@
- #include "metadata_collection.h"
-
- typedef struct _object_intern {
--#if PHP_MAJOR_VERSION < 7
-- zend_object std;
--#endif
- zval zmetadata;
- const rd_kafka_metadata_partition_t *metadata_partition;
--#if PHP_MAJOR_VERSION >= 7
- zend_object std;
--#endif
- } object_intern;
-
- static HashTable *get_debug_info(zval *object, int *is_temp);
-@@ -54,22 +49,20 @@ static void free_object(zend_object *object) /* {{{ */
- }
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
--static zend_object_value create_object(zend_class_entry *class_type) /* {{{ */
-+static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- object_intern *intern;
-
-- intern = alloc_object(intern, class_type);
-+ intern = zend_object_alloc(sizeof(*intern), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
-- SET_OBJECT_HANDLERS(retval, &handlers);
-+ retval = &intern->std;
-+ retval->handlers = &handlers;
-
- return retval;
- }
-@@ -249,8 +242,8 @@ void kafka_metadata_partition_minit()
-
- handlers = kafka_default_object_handlers;
- handlers.get_debug_info = get_debug_info;
-- set_object_handler_free_obj(&handlers, free_object);
-- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
-+ handlers.free_obj = free_object;
-+ handlers.offset = XtOffsetOf(object_intern, std);
- }
-
- void kafka_metadata_partition_ctor(zval *return_value, zval *zmetadata, const void *data)
-diff --git a/metadata_topic.c b/metadata_topic.c
-index 512c83e..9830beb 100644
---- a/metadata_topic.c
-+++ b/metadata_topic.c
-@@ -31,14 +31,9 @@
- #include "Zend/zend_exceptions.h"
-
- typedef struct _object_intern {
--#if PHP_MAJOR_VERSION < 7
-- zend_object std;
--#endif
- zval zmetadata;
- const rd_kafka_metadata_topic_t *metadata_topic;
--#if PHP_MAJOR_VERSION >= 7
- zend_object std;
--#endif
- } object_intern;
-
- static HashTable *get_debug_info(zval *object, int *is_temp);
-@@ -60,22 +55,20 @@ static void free_object(zend_object *object) /* {{{ */
- }
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
--static zend_object_value create_object(zend_class_entry *class_type) /* {{{ */
-+static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- object_intern *intern;
-
-- intern = alloc_object(intern, class_type);
-+ intern = zend_object_alloc(sizeof(*intern), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
-- SET_OBJECT_HANDLERS(retval, &handlers);
-+ retval = &intern->std;
-+ retval->handlers = &handlers;
-
- return retval;
- }
-@@ -108,7 +101,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
- return Z_ARRVAL(ary);
- }
-
-- rdkafka_add_assoc_string(&ary, "topic", intern->metadata_topic->topic);
-+ add_assoc_string(&ary, "topic", intern->metadata_topic->topic);
-
- ZVAL_NULL(&partitions);
- partitions_collection(&partitions, object, intern);
-@@ -139,7 +132,7 @@ PHP_METHOD(RdKafka__Metadata__Topic, getTopic)
- return;
- }
-
-- RDKAFKA_RETURN_STRING(intern->metadata_topic->topic);
-+ RETURN_STRING(intern->metadata_topic->topic);
- }
- /* }}} */
-
-@@ -207,8 +200,8 @@ void kafka_metadata_topic_minit()
-
- handlers = kafka_default_object_handlers;
- handlers.get_debug_info = get_debug_info;
-- set_object_handler_free_obj(&handlers, free_object);
-- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
-+ handlers.free_obj = free_object;
-+ handlers.offset = XtOffsetOf(object_intern, std);
- }
-
- void kafka_metadata_topic_ctor(zval *return_value, zval *zmetadata, const void *data)
-diff --git a/php_rdkafka.h b/php_rdkafka.h
-index 1041b1c..77b40c8 100644
---- a/php_rdkafka.h
-+++ b/php_rdkafka.h
-@@ -22,7 +22,6 @@
- #define PHP_RDKAFKA_H
-
- #include "librdkafka/rdkafka.h"
--#include "compat.h"
- #include "conf.h"
-
- #ifndef PHP_FE_END
-@@ -30,18 +29,13 @@
- #endif
-
- typedef struct _kafka_object {
--#if PHP_MAJOR_VERSION < 7
-- zend_object std;
--#endif
- rd_kafka_type_t type;
- rd_kafka_t *rk;
- kafka_conf_callbacks cbs;
- HashTable consuming;
- HashTable topics;
- HashTable queues;
--#if PHP_MAJOR_VERSION >= 7
- zend_object std;
--#endif
- } kafka_object;
-
- PHP_METHOD(RdKafka, __construct);
-diff --git a/php_rdkafka_priv.h b/php_rdkafka_priv.h
-index d00a8eb..a2d44cf 100644
---- a/php_rdkafka_priv.h
-+++ b/php_rdkafka_priv.h
-@@ -19,22 +19,6 @@
- #ifndef PHP_RDKAFKA_PRIV_H
- #define PHP_RDKAFKA_PRIV_H
-
--#if PHP_MAJOR_VERSION >= 7
--
--typedef zend_object* zend_object_value;
--
--typedef size_t arglen_t;
--
--#define STORE_OBJECT(retval, intern, dtor, free, clone) do { \
-- retval = &intern->std; \
--} while (0)
--
--#define SET_OBJECT_HANDLERS(retval, _handlers) do { \
-- retval->handlers = _handlers; \
--} while (0)
--
--#define alloc_object(intern, ce) ecalloc(1, sizeof(*intern) + zend_object_properties_size(ce))
--
- static inline zval * is_zval(zval * zv) {
- return zv;
- }
-@@ -49,22 +33,6 @@ static inline zend_object * is_zend_object(zend_object * object) {
- #define get_custom_object(type, object) \
- ((type*)((char *)is_zend_object(object) - XtOffsetOf(type, std)))
-
--#define free_custom_object(object) /* no-op */
--
--static inline zend_class_entry *rdkafka_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce)
--{
-- return zend_register_internal_class_ex(class_entry, parent_ce);
--}
--
--static inline void set_object_handler_free_obj(zend_object_handlers * handlers, zend_object_free_obj_t free_obj)
--{
-- handlers->free_obj = free_obj;
--}
--static inline void set_object_handler_offset(zend_object_handlers * handlers, size_t offset)
--{
-- handlers->offset = offset;
--}
--
- static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zval *retval, uint32_t param_count, zval params[])
- {
- int local_retval;
-@@ -94,11 +62,6 @@ static inline zval *rdkafka_read_property(zend_class_entry *scope, zval *object,
- return zend_read_property(scope, object, name, name_length, silent, &rv);
- }
-
--static inline zval *rdkafka_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
--{
-- return zend_hash_get_current_data_ex(ht, pos);
--}
--
- static inline char *rdkafka_hash_get_current_key_ex(HashTable *ht, HashPosition *pos)
- {
- zend_string* key;
-@@ -111,147 +74,6 @@ static inline char *rdkafka_hash_get_current_key_ex(HashTable *ht, HashPosition
- return NULL;
- }
-
--#define rdkafka_add_assoc_string(arg, key, str) add_assoc_string(arg, key, str)
--
--#define rdkafka_add_assoc_stringl(arg, key, str, str_length) add_assoc_stringl(arg, key, str, str_length)
--
--#define RDKAFKA_RETURN_STRING(str) RETURN_STRING(str)
--#define RDKAFKA_ZVAL_STRING(zv, str) ZVAL_STRING(zv, str)
--#else /* PHP < 7 */
--
--typedef long zend_long;
--#define ZEND_LONG_FMT "%ld"
--
--typedef int arglen_t;
--
--#define STORE_OBJECT(retval, intern, dtor, free, clone) do { \
-- void (*___free_object_storage)(zend_object *object) = free; \
-- retval.handle = zend_objects_store_put(&intern->std, dtor, (zend_objects_free_object_storage_t)___free_object_storage, clone); \
--} while (0)
--
--#define SET_OBJECT_HANDLERS(retval, _handlers) do { \
-- retval.handlers = _handlers; \
--} while (0)
--
--#define alloc_object(intern, ce) ecalloc(1, sizeof(*intern))
--
--#define get_custom_object_zval(type, zobject) \
-- ((type*)zend_object_store_get_object(zobject))
--
--#define get_custom_object(type, object) \
-- ((type*)object)
--
--#define free_custom_object(object) efree(object)
--
--static inline void *zend_hash_str_add_ptr(HashTable *ht, const char *str, size_t len, void *pData)
--{
-- void *pDest;
-- zend_hash_add(ht, str, len, &pData, sizeof(pData), &pDest);
-- return pDest;
--}
--
--static inline int zend_hash_str_del(HashTable *ht, const char *str, size_t len)
--{
-- return zend_hash_del(ht, str, len);
--}
--
--static inline zend_bool zend_hash_str_exists(const HashTable *ht, const char *str, size_t len)
--{
-- return zend_hash_exists(ht, str, len);
--}
--
--static inline void *zend_hash_index_add_ptr(HashTable *ht, zend_ulong h, void *pData)
--{
-- void *pDest;
-- zend_hash_index_update(ht, h, &pData, sizeof(pData), &pDest);
-- return pDest;
--}
--
--static inline zend_class_entry *rdkafka_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce)
--{
-- return zend_register_internal_class_ex(class_entry, parent_ce, NULL);
--}
--
--typedef void (*zend_object_free_obj_t)(zend_object *object);
--static inline void set_object_handler_free_obj(zend_object_handlers * handlers, zend_object_free_obj_t free_obj)
--{
-- /* no-op */
--}
--
--static inline void set_object_handler_offset(zend_object_handlers * handlers, size_t offset)
--{
-- /* no-op */
--}
--
--static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zval **retval, uint32_t param_count, zval *params[])
--{
-- uint32_t i;
-- int local_retval;
-- zval *local_retval_zv;
-- zval ***params_array;
--
-- if (retval) {
-- local_retval = 0;
-- } else {
-- local_retval = 1;
-- retval = &local_retval_zv;
-- }
--
-- params_array = (zval ***) emalloc(sizeof(zval **)*param_count);
-- for (i = 0; i < param_count; i++) {
-- params_array[i] = &params[i];
-- }
--
-- fci->retval_ptr_ptr = retval;
-- fci->params = params_array;
-- fci->param_count = param_count;
--
-- zend_call_function(fci, fci_cache);
--
-- if (local_retval && *retval) {
-- zval_ptr_dtor(retval);
-- }
--
-- efree(params_array);
--}
--
--static inline zval *rdkafka_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent)
--{
-- return zend_read_property(scope, object, name, name_length, silent);
--}
--
--static inline zval **rdkafka_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
--{
-- zval **zv;
--
-- if (zend_hash_get_current_data_ex(ht, (void**)&zv, pos) == SUCCESS) {
-- return zv;
-- }
--
-- return NULL;
--}
--
--static inline char **rdkafka_hash_get_current_key_ex(HashTable *ht, HashPosition *pos)
--{
-- char *key = NULL;
-- uint klen;
-- ulong index;
--
-- if (zend_hash_get_current_key_ex(ht, &key, &klen, &index, 0, pos) == HASH_KEY_IS_STRING) {
-- return key;
-- }
--
-- return NULL;
--}
--
--#define rdkafka_add_assoc_string(arg, key, str) add_assoc_string(arg, key, str, 1)
--
--#define rdkafka_add_assoc_stringl(arg, key, str, str_length) add_assoc_stringl(arg, key, str, str_length, 1)
--
--#define RDKAFKA_RETURN_STRING(str) RETURN_STRING(str, 1)
--#define RDKAFKA_ZVAL_STRING(zv, str) ZVAL_STRING(zv, str, 1)
--#endif
--
- kafka_object * get_kafka_object(zval *zrk);
- void add_consuming_toppar(kafka_object * intern, rd_kafka_topic_t * rkt, int32_t partition);
- void del_consuming_toppar(kafka_object * intern, rd_kafka_topic_t * rkt, int32_t partition);
-diff --git a/queue.c b/queue.c
-index 0f0dadc..99ab609 100644
---- a/queue.c
-+++ b/queue.c
-@@ -47,22 +47,20 @@ static void kafka_queue_free(zend_object *object) /* {{{ */
- }
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
--static zend_object_value kafka_queue_new(zend_class_entry *class_type) /* {{{ */
-+static zend_object *kafka_queue_new(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- kafka_queue_object *intern;
-
-- intern = alloc_object(intern, class_type);
-+ intern = zend_object_alloc(sizeof(*intern), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_queue_free, NULL);
-- SET_OBJECT_HANDLERS(retval, &handlers);
-+ retval = &intern->std;
-+ retval->handlers = &handlers;
-
- return retval;
- }
-@@ -134,8 +132,8 @@ void kafka_queue_minit() { /* {{{ */
- zend_class_entry ce;
-
- handlers = kafka_default_object_handlers;
-- set_object_handler_free_obj(&handlers, kafka_queue_free);
-- set_object_handler_offset(&handlers, XtOffsetOf(kafka_queue_object, std));
-+ handlers.free_obj = kafka_queue_free;
-+ handlers.offset = XtOffsetOf(kafka_queue_object, std);
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Queue", kafka_queue_fe);
- ce_kafka_queue = zend_register_internal_class(&ce);
-diff --git a/queue.h b/queue.h
-index 3349f18..79e8b3c 100644
---- a/queue.h
-+++ b/queue.h
-@@ -17,14 +17,9 @@
- */
-
- typedef struct _kafka_queue_object {
--#if PHP_MAJOR_VERSION < 7
-- zend_object std;
--#endif
- rd_kafka_queue_t *rkqu;
- zval zrk;
--#if PHP_MAJOR_VERSION >= 7
- zend_object std;
--#endif
- } kafka_queue_object;
-
- void kafka_queue_minit();
-diff --git a/rdkafka.c b/rdkafka.c
-index 71d0aae..5d97b22 100644
---- a/rdkafka.c
-+++ b/rdkafka.c
-@@ -93,8 +93,6 @@ static void kafka_free(zend_object *object) /* {{{ */
- kafka_conf_callbacks_dtor(&intern->cbs);
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
-@@ -159,17 +157,17 @@ static void kafka_init(zval *this_ptr, rd_kafka_type_t type, zval *zconf) /* {{{
- }
- /* }}} */
-
--static zend_object_value kafka_new(zend_class_entry *class_type) /* {{{ */
-+static zend_object *kafka_new(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- kafka_object *intern;
-
-- intern = alloc_object(intern, class_type);
-+ intern = zend_object_alloc(sizeof(*intern), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_free, NULL);
-- SET_OBJECT_HANDLERS(retval, &kafka_object_handlers);
-+ retval = &intern->std;
-+ retval->handlers = &kafka_object_handlers;
-
- return retval;
- }
-@@ -311,11 +309,7 @@ PHP_METHOD(RdKafka__Consumer, newQueue)
- // Keep a reference to the parent Kafka object, attempts to ensure that
- // the Queue object is destroyed before the Kafka object.
- // This avoids rd_kafka_destroy() hanging.
--#if PHP_MAJOR_VERSION >= 7
- queue_intern->zrk = *getThis();
--#else
-- queue_intern->zrk = getThis();
--#endif
- Z_ADDREF_P(&queue_intern->zrk);
-
- zend_hash_index_add_ptr(&intern->queues, (zend_ulong)queue_intern, queue_intern);
-@@ -338,7 +332,7 @@ ZEND_END_ARG_INFO()
- PHP_METHOD(RdKafka__Kafka, addBrokers)
- {
- char *broker_list;
-- arglen_t broker_list_len;
-+ size_t broker_list_len;
- kafka_object *intern;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &broker_list, &broker_list_len) == FAILURE) {
-@@ -435,7 +429,7 @@ ZEND_END_ARG_INFO()
- PHP_METHOD(RdKafka__Kafka, newTopic)
- {
- char *topic;
-- arglen_t topic_len;
-+ size_t topic_len;
- rd_kafka_topic_t *rkt;
- kafka_object *intern;
- kafka_topic_object *topic_intern;
-@@ -487,11 +481,7 @@ PHP_METHOD(RdKafka__Kafka, newTopic)
- }
-
- topic_intern->rkt = rkt;
--#if PHP_MAJOR_VERSION >= 7
- topic_intern->zrk = *getThis();
--#else
-- topic_intern->zrk = getThis();
--#endif
- Z_ADDREF_P(&topic_intern->zrk);
-
- zend_hash_index_add_ptr(&intern->topics, (zend_ulong)topic_intern, topic_intern);
-@@ -613,7 +603,7 @@ PHP_METHOD(RdKafka__Kafka, queryWatermarkOffsets)
- {
- kafka_object *intern;
- char *topic;
-- arglen_t topic_length;
-+ size_t topic_length;
- long low, high;
- zend_long partition, timeout;
- zval *lowResult, *highResult;
-@@ -935,10 +925,6 @@ void register_err_constants(INIT_FUNC_ARGS) /* {{{ */
- len = sizeof(buf)-1;
- }
-
--#if PHP_MAJOR_VERSION < 7
-- len += 1;
--#endif
--
- zend_register_long_constant(buf, len, desc->code, CONST_CS | CONST_PERSISTENT, module_number);
- }
- } /* }}} */
-@@ -985,8 +971,8 @@ PHP_MINIT_FUNCTION(rdkafka)
- kafka_default_object_handlers.clone_obj = NULL;
-
- kafka_object_handlers = kafka_default_object_handlers;
-- set_object_handler_free_obj(&kafka_object_handlers, kafka_free);
-- set_object_handler_offset(&kafka_object_handlers, XtOffsetOf(kafka_object, std));
-+ kafka_object_handlers.free_obj = kafka_free;
-+ kafka_object_handlers.offset = XtOffsetOf(kafka_object, std);
-
- INIT_CLASS_ENTRY(ce, "RdKafka", kafka_fe);
- ce_kafka = zend_register_internal_class(&ce);
-@@ -997,13 +983,13 @@ PHP_MINIT_FUNCTION(rdkafka)
- zend_declare_property_null(ce_kafka, ZEND_STRL("dr_cb"), ZEND_ACC_PRIVATE);
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Consumer", kafka_consumer_fe);
-- ce_kafka_consumer = rdkafka_register_internal_class_ex(&ce, ce_kafka);
-+ ce_kafka_consumer = zend_register_internal_class_ex(&ce, ce_kafka);
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Producer", kafka_producer_fe);
-- ce_kafka_producer = rdkafka_register_internal_class_ex(&ce, ce_kafka);
-+ ce_kafka_producer = zend_register_internal_class_ex(&ce, ce_kafka);
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Exception", NULL);
-- ce_kafka_exception = rdkafka_register_internal_class_ex(&ce, zend_exception_get_default());
-+ ce_kafka_exception = zend_register_internal_class_ex(&ce, zend_exception_get_default());
-
- kafka_conf_minit();
- #ifdef HAS_RD_KAFKA_TRANSACTIONS
-diff --git a/topic.c b/topic.c
-index f834ce3..78887a3 100644
---- a/topic.c
-+++ b/topic.c
-@@ -55,22 +55,20 @@ static void kafka_topic_free(zend_object *object) /* {{{ */
- }
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
--static zend_object_value kafka_topic_new(zend_class_entry *class_type) /* {{{ */
-+static zend_object *kafka_topic_new(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- kafka_topic_object *intern;
-
-- intern = alloc_object(intern, class_type);
-+ intern = zend_object_alloc(sizeof(*intern), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, kafka_topic_free, NULL);
-- SET_OBJECT_HANDLERS(retval, &object_handlers);
-+ retval = &intern->std;
-+ retval->handlers = &object_handlers;
-
- return retval;
- }
-@@ -81,7 +79,6 @@ static void consume_callback(rd_kafka_message_t *msg, void *opaque)
- {
- php_callback *cb = (php_callback*) opaque;
- zval args[1];
-- TSRMLS_FETCH();
-
- if (!opaque) {
- return;
-@@ -502,9 +499,9 @@ PHP_METHOD(RdKafka__ProducerTopic, produce)
- zend_long partition;
- zend_long msgflags;
- char *payload = NULL;
-- arglen_t payload_len = 0;
-+ size_t payload_len = 0;
- char *key = NULL;
-- arglen_t key_len = 0;
-+ size_t key_len = 0;
- int ret;
- rd_kafka_resp_err_t err;
- kafka_topic_object *intern;
-@@ -553,9 +550,9 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
- zend_long partition;
- zend_long msgflags;
- char *payload = NULL;
-- arglen_t payload_len = 0;
-+ size_t payload_len = 0;
- char *key = NULL;
-- arglen_t key_len = 0;
-+ size_t key_len = 0;
- rd_kafka_resp_err_t err;
- kafka_topic_object *intern;
- kafka_object *kafka_intern;
-@@ -590,7 +587,7 @@ PHP_METHOD(RdKafka__ProducerTopic, producev)
- if (headersParam != NULL && zend_hash_num_elements(headersParam) > 0) {
- headers = rd_kafka_headers_new(zend_hash_num_elements(headersParam));
- for (zend_hash_internal_pointer_reset_ex(headersParam, &headersParamPos);
-- (header_value = rdkafka_hash_get_current_data_ex(headersParam, &headersParamPos)) != NULL &&
-+ (header_value = zend_hash_get_current_data_ex(headersParam, &headersParamPos)) != NULL &&
- (header_key = rdkafka_hash_get_current_key_ex(headersParam, &headersParamPos)) != NULL;
- zend_hash_move_forward_ex(headersParam, &headersParamPos)) {
- convert_to_string_ex(header_value);
-@@ -659,7 +656,7 @@ PHP_METHOD(RdKafka__Topic, getName)
- return;
- }
-
-- RDKAFKA_RETURN_STRING(rd_kafka_topic_name(intern->rkt));
-+ RETURN_STRING(rd_kafka_topic_name(intern->rkt));
- }
- /* }}} */
-
-@@ -674,8 +671,8 @@ void kafka_topic_minit() { /* {{{ */
-
- memcpy(&object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- object_handlers.clone_obj = NULL;
-- set_object_handler_free_obj(&object_handlers, kafka_topic_free);
-- set_object_handler_offset(&object_handlers, XtOffsetOf(kafka_topic_object, std));
-+ object_handlers.free_obj = kafka_topic_free;
-+ object_handlers.offset = XtOffsetOf(kafka_topic_object, std);
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Topic", kafka_topic_fe);
- ce_kafka_topic = zend_register_internal_class(&ce);
-@@ -683,11 +680,11 @@ void kafka_topic_minit() { /* {{{ */
- ce_kafka_topic->create_object = kafka_topic_new;
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "ConsumerTopic", kafka_consumer_topic_fe);
-- ce_kafka_consumer_topic = rdkafka_register_internal_class_ex(&ce, ce_kafka_topic);
-+ ce_kafka_consumer_topic = zend_register_internal_class_ex(&ce, ce_kafka_topic);
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "KafkaConsumerTopic", kafka_kafka_consumer_topic_fe);
-- ce_kafka_kafka_consumer_topic = rdkafka_register_internal_class_ex(&ce, ce_kafka_topic);
-+ ce_kafka_kafka_consumer_topic = zend_register_internal_class_ex(&ce, ce_kafka_topic);
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "ProducerTopic", kafka_producer_topic_fe);
-- ce_kafka_producer_topic = rdkafka_register_internal_class_ex(&ce, ce_kafka_topic);
-+ ce_kafka_producer_topic = zend_register_internal_class_ex(&ce, ce_kafka_topic);
- } /* }}} */
-diff --git a/topic.h b/topic.h
-index e6bbbd5..51aa186 100644
---- a/topic.h
-+++ b/topic.h
-@@ -17,14 +17,9 @@
- */
-
- typedef struct _kafka_topic_object {
--#if PHP_MAJOR_VERSION < 7
-- zend_object std;
--#endif
- rd_kafka_topic_t *rkt;
- zval zrk;
--#if PHP_MAJOR_VERSION >= 7
- zend_object std;
--#endif
- } kafka_topic_object;
-
- void kafka_topic_minit();
-diff --git a/topic_partition.c b/topic_partition.c
-index c71a17b..ebbbfaf 100644
---- a/topic_partition.c
-+++ b/topic_partition.c
-@@ -47,22 +47,20 @@ static void free_object(zend_object *object) /* {{{ */
- }
-
- zend_object_std_dtor(&intern->std);
--
-- free_custom_object(intern);
- }
- /* }}} */
-
--static zend_object_value create_object(zend_class_entry *class_type) /* {{{ */
-+static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
- {
-- zend_object_value retval;
-+ zend_object* retval;
- object_intern *intern;
-
- intern = ecalloc(1, sizeof(*intern));
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
-- STORE_OBJECT(retval, intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_object, NULL);
-- SET_OBJECT_HANDLERS(retval, &handlers);
-+ retval = &intern->std;
-+ retval->handlers = &handlers;
-
- return retval;
- }
-@@ -100,7 +98,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
- }
-
- if (intern->topic) {
-- rdkafka_add_assoc_string(&ary, "topic", intern->topic);
-+ add_assoc_string(&ary, "topic", intern->topic);
- } else {
- add_assoc_null(&ary, "topic");
- }
-@@ -156,7 +154,7 @@ rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int ar
- list = rd_kafka_topic_partition_list_new(zend_hash_num_elements(ary));
-
- for (zend_hash_internal_pointer_reset_ex(ary, &pos);
-- (zv = rdkafka_hash_get_current_data_ex(ary, &pos)) != NULL;
-+ (zv = zend_hash_get_current_data_ex(ary, &pos)) != NULL;
- zend_hash_move_forward_ex(ary, &pos)) {
- kafka_topic_partition_intern *topar_intern;
- rd_kafka_topic_partition_t *topar;
-@@ -200,7 +198,7 @@ ZEND_END_ARG_INFO()
- PHP_METHOD(RdKafka__TopicPartition, __construct)
- {
- char *topic;
-- arglen_t topic_len;
-+ size_t topic_len;
- zend_long partition;
- zend_long offset = 0;
- zend_error_handling error_handling;
-@@ -238,7 +236,7 @@ PHP_METHOD(RdKafka__TopicPartition, getTopic)
- }
-
- if (intern->topic) {
-- RDKAFKA_RETURN_STRING(intern->topic);
-+ RETURN_STRING(intern->topic);
- } else {
- RETURN_NULL();
- }
-@@ -255,7 +253,7 @@ ZEND_END_ARG_INFO()
- PHP_METHOD(RdKafka__TopicPartition, setTopic)
- {
- char * topic;
-- arglen_t topic_len;
-+ size_t topic_len;
- object_intern *intern;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &topic, &topic_len) == FAILURE) {
-@@ -398,6 +396,6 @@ void kafka_metadata_topic_partition_minit() /* {{{ */
-
- handlers = kafka_default_object_handlers;
handlers.get_debug_info = get_debug_info;
- set_object_handler_free_obj(&handlers, free_object);
- set_object_handler_offset(&handlers, XtOffsetOf(object_intern, std));
@@ -6273,10 +5037,10 @@ index c71a17b..ebbbfaf 100644
+ handlers.offset = XtOffsetOf(object_intern, std);
} /* }}} */
diff --git a/topic_partition.h b/topic_partition.h
-index a7aab8b..746b1a5 100644
+index cbc0f43..f2d405d 100644
--- a/topic_partition.h
+++ b/topic_partition.h
-@@ -17,15 +17,10 @@
+@@ -17,23 +17,18 @@
*/
typedef struct _kafka_topic_partition_intern {
@@ -6291,1393 +5055,17 @@ index a7aab8b..746b1a5 100644
-#endif
} kafka_topic_partition_intern;
- void kafka_metadata_topic_partition_minit();
-From a9e2af8f13d469f3f087f2a9f466edb66d6050be Mon Sep 17 00:00:00 2001
-From: Arnaud Le Blanc <arnaud.lb@gmail.com>
-Date: Mon, 7 Dec 2020 13:41:55 +0100
-Subject: [PATCH] PHP 8 support (#406)
-
-Co-authored-by: Nick <nickjobszh@gmail.com>
----
- .github/workflows/test.yml | 4 ---
- README.md | 4 +--
- conf.c | 10 +++----
- conf.h | 2 +-
- kafka_consumer.c | 18 ++++++-------
- kafka_consumer.h | 2 +-
- kafka_error_exception.c | 32 +++++++++++------------
- kafka_error_exception.h | 3 ++-
- message.c | 24 ++++++++---------
- message.h | 2 +-
- metadata.c | 30 ++++++++++-----------
- metadata.h | 2 +-
- metadata_broker.c | 15 +++++------
- metadata_broker.h | 2 +-
- metadata_collection.c | 18 +++++++------
- metadata_collection.h | 4 +--
- metadata_partition.c | 18 ++++++-------
- metadata_partition.h | 2 +-
- metadata_topic.c | 18 ++++++-------
- metadata_topic.h | 2 +-
- package.xml | 3 ---
- php_rdkafka.h | 4 ---
- php_rdkafka_priv.h | 32 +++++++++++++++--------
- queue.c | 6 ++---
- queue.h | 2 +-
- rdkafka.c | 33 ++++++++++++------------
- tests/bug115.phpt | 6 -----
- tests/bug74.phpt | 6 ++++-
- tests/conf_setDefaultTopicConf.phpt | 2 +-
- tests/message_headers.phpt | 7 ++---
- tests/produce_consume.phpt | 8 +++---
- tests/produce_consume_queue.phpt | 15 +++++++++--
- tests/produce_consume_transactional.phpt | 7 +++++
- topic.c | 6 ++---
- topic.h | 2 +-
- topic_partition.c | 15 ++++++-----
- topic_partition.h | 2 +-
- 37 files changed, 194 insertions(+), 174 deletions(-)
-
-diff --git a/README.md b/README.md
-index 8257df8..f946d43 100644
---- a/README.md
-+++ b/README.md
-@@ -2,9 +2,9 @@
-
- [![Join the chat at https://gitter.im/arnaud-lb/php-rdkafka](https://badges.gitter.im/arnaud-lb/php-rdkafka.svg)](https://gitter.im/arnaud-lb/php-rdkafka?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-
--[![Supported librdkafka versions: >= 0.11](https://img.shields.io/badge/librdkafka-%3E%3D%200.11-blue.svg)](https://github.com/edenhill/librdkafka/releases) [![Supported Kafka versions: >= 0.8](https://img.shields.io/badge/kafka-%3E%3D%200.8-blue.svg)](https://github.com/edenhill/librdkafka/wiki/Broker-version-compatibility) ![Supported PHP versions: 5.6 .. 7.x](https://img.shields.io/badge/php-5.6%20..%207.x-blue.svg) [![Build Status](https://travis-ci.org/arnaud-lb/php-rdkafka.svg)](https://travis-ci.org/arnaud-lb/php-rdkafka)
-+[![Supported librdkafka versions: >= 0.11](https://img.shields.io/badge/librdkafka-%3E%3D%200.11-blue.svg)](https://github.com/edenhill/librdkafka/releases) [![Supported Kafka versions: >= 0.8](https://img.shields.io/badge/kafka-%3E%3D%200.8-blue.svg)]()https://github.com/edenhill/librdkafka/blob/master/INTRODUCTION.md#broker-version-compatibility ![Supported PHP versions: 7.x .. 8.x](https://img.shields.io/badge/php-7.x%20..%208.x-blue.svg)
-
--PHP-rdkafka is a thin [librdkafka](https://github.com/edenhill/librdkafka) binding providing a working PHP 5 / PHP 7 [Kafka](https://kafka.apache.org/) client.
-+PHP-rdkafka is a thin [librdkafka](https://github.com/edenhill/librdkafka) binding providing a working PHP 7 / PHP 8 [Kafka](https://kafka.apache.org/) client.
-
- It supports the high level and low level *consumers*, *producer*, and *metadata* APIs.
-
-diff --git a/conf.c b/conf.c
-index ec171c6..1ec2e59 100644
---- a/conf.c
-+++ b/conf.c
-@@ -85,7 +85,7 @@ void kafka_conf_callbacks_copy(kafka_conf_callbacks *to, kafka_conf_callbacks *f
-
- static void kafka_conf_free(zend_object *object) /* {{{ */
- {
-- kafka_conf_object *intern = get_custom_object(kafka_conf_object, object);
-+ kafka_conf_object *intern = php_kafka_from_obj(kafka_conf_object, object);
-
- switch (intern->type) {
- case KAFKA_CONF:
-@@ -123,7 +123,7 @@ static zend_object *kafka_conf_new(zend_class_entry *class_type) /* {{{ */
-
- kafka_conf_object * get_kafka_conf_object(zval *zconf)
- {
-- kafka_conf_object *oconf = get_custom_object_zval(kafka_conf_object, zconf);
-+ kafka_conf_object *oconf = Z_RDKAFKA_P(kafka_conf_object, zconf);
-
- if (!oconf->type) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\Conf::__construct() has not been called");
-@@ -350,7 +350,7 @@ PHP_METHOD(RdKafka__Conf, __construct)
- return;
- }
-
-- intern = get_custom_object_zval(kafka_conf_object, getThis());
-+ intern = Z_RDKAFKA_P(kafka_conf_object, getThis());
- intern->type = KAFKA_CONF;
- intern->u.conf = rd_kafka_conf_new();
-
-@@ -761,7 +761,7 @@ PHP_METHOD(RdKafka__TopicConf, __construct)
- return;
- }
-
-- intern = get_custom_object_zval(kafka_conf_object, getThis());
-+ intern = Z_RDKAFKA_P(kafka_conf_object, getThis());
- intern->type = KAFKA_TOPIC_CONF;
- intern->u.topic_conf = rd_kafka_topic_conf_new();
-
-@@ -840,7 +840,7 @@ static const zend_function_entry kafka_conf_fe[] = {
- PHP_FE_END
- };
-
--void kafka_conf_minit()
-+void kafka_conf_minit(INIT_FUNC_ARGS)
- {
- zend_class_entry tmpce;
-
-diff --git a/conf.h b/conf.h
-index 673e14c..9778eb5 100644
---- a/conf.h
-+++ b/conf.h
-@@ -59,7 +59,7 @@ typedef struct _kafka_conf_object {
- } kafka_conf_object;
-
- kafka_conf_object * get_kafka_conf_object(zval *zconf);
--void kafka_conf_minit();
-+void kafka_conf_minit(INIT_FUNC_ARGS);
-
- void kafka_conf_callbacks_dtor(kafka_conf_callbacks *cbs);
- void kafka_conf_callbacks_copy(kafka_conf_callbacks *to, kafka_conf_callbacks *from);
-diff --git a/kafka_consumer.c b/kafka_consumer.c
-index 8cc4b9d..f1b596a 100644
---- a/kafka_consumer.c
-+++ b/kafka_consumer.c
-@@ -43,7 +43,7 @@ static zend_object_handlers handlers;
-
- static void kafka_consumer_free(zend_object *object) /* {{{ */
- {
-- object_intern *intern = get_custom_object(object_intern, object);
-+ object_intern *intern = php_kafka_from_obj(object_intern, object);
- rd_kafka_resp_err_t err;
- kafka_conf_callbacks_dtor(&intern->cbs);
-
-@@ -82,7 +82,7 @@ static zend_object *kafka_consumer_new(zend_class_entry *class_type) /* {{{ */
-
- static object_intern * get_object(zval *zconsumer) /* {{{ */
- {
-- object_intern *oconsumer = get_custom_object_zval(object_intern, zconsumer);
-+ object_intern *oconsumer = Z_RDKAFKA_P(object_intern, zconsumer);
-
- if (!oconsumer->rk) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\KafkaConsumer::__construct() has not been called");
-@@ -134,7 +134,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, __construct)
- return;
- }
-
-- intern = get_custom_object_zval(object_intern, getThis());
-+ intern = Z_RDKAFKA_P(object_intern, getThis());
-
- conf_intern = get_kafka_conf_object(zconf);
- if (conf_intern) {
-@@ -424,25 +424,25 @@ static void consumer_commit(int async, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
- zval *zoffset;
- rd_kafka_topic_partition_t *rktpar;
-
-- zerr = rdkafka_read_property(NULL, zarg, ZEND_STRL("err"), 0);
-+ zerr = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("err"), 0);
- if (zerr && Z_TYPE_P(zerr) != IS_NULL && (Z_TYPE_P(zerr) != IS_LONG || Z_LVAL_P(zerr) != RD_KAFKA_RESP_ERR_NO_ERROR)) {
- zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message has an error", RD_KAFKA_RESP_ERR__INVALID_ARG);
- return;
- }
-
-- ztopic = rdkafka_read_property(NULL, zarg, ZEND_STRL("topic_name"), 0);
-+ ztopic = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("topic_name"), 0);
- if (!ztopic || Z_TYPE_P(ztopic) != IS_STRING) {
- zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's topic_name is not a string", RD_KAFKA_RESP_ERR__INVALID_ARG);
- return;
- }
-
-- zpartition = rdkafka_read_property(NULL, zarg, ZEND_STRL("partition"), 0);
-+ zpartition = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("partition"), 0);
- if (!zpartition || Z_TYPE_P(zpartition) != IS_LONG) {
- zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's partition is not an int", RD_KAFKA_RESP_ERR__INVALID_ARG);
- return;
- }
-
-- zoffset = rdkafka_read_property(NULL, zarg, ZEND_STRL("offset"), 0);
-+ zoffset = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(zarg), ZEND_STRL("offset"), 0);
- if (!zoffset || Z_TYPE_P(zoffset) != IS_LONG) {
- zend_throw_exception(ce_kafka_exception, "Invalid argument: Specified Message's offset is not an int", RD_KAFKA_RESP_ERR__INVALID_ARG);
- return;
-@@ -620,7 +620,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, newTopic)
- return;
- }
-
-- topic_intern = get_custom_object_zval(kafka_topic_object, return_value);
-+ topic_intern = Z_RDKAFKA_P(kafka_topic_object, return_value);
- if (!topic_intern) {
- return;
- }
-@@ -818,7 +818,7 @@ static const zend_function_entry fe[] = { /* {{{ */
- PHP_FE_END
- }; /* }}} */
-
--void kafka_kafka_consumer_minit() /* {{{ */
-+void kafka_kafka_consumer_minit(INIT_FUNC_ARGS) /* {{{ */
- {
- zend_class_entry tmpce;
-
-diff --git a/kafka_consumer.h b/kafka_consumer.h
-index 0ac97f3..cc4be66 100644
---- a/kafka_consumer.h
-+++ b/kafka_consumer.h
-@@ -16,4 +16,4 @@
- +----------------------------------------------------------------------+
- */
-
--void kafka_kafka_consumer_minit();
-+void kafka_kafka_consumer_minit(INIT_FUNC_ARGS);
-diff --git a/kafka_error_exception.c b/kafka_error_exception.c
-index b1cd9a8..93e5848 100644
---- a/kafka_error_exception.c
-+++ b/kafka_error_exception.c
-@@ -33,12 +33,12 @@ void create_kafka_error(zval *return_value, const rd_kafka_error_t *error) /* {{
- {
- object_init_ex(return_value, ce_kafka_error);
-
-- zend_update_property_string(ce_kafka_error, return_value, ZEND_STRL("message"), rd_kafka_error_name(error));
-- zend_update_property_long(ce_kafka_error, return_value, ZEND_STRL("code"), rd_kafka_error_code(error));
-- zend_update_property_string(ce_kafka_error, return_value, ZEND_STRL("error_string"), rd_kafka_error_string(error));
-- zend_update_property_bool(ce_kafka_error, return_value, ZEND_STRL("isFatal"), rd_kafka_error_is_fatal(error));
-- zend_update_property_bool(ce_kafka_error, return_value, ZEND_STRL("isRetriable"), rd_kafka_error_is_retriable(error));
-- zend_update_property_bool(ce_kafka_error, return_value, ZEND_STRL("transactionRequiresAbort"), rd_kafka_error_txn_requires_abort(error));
-+ zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("message"), rd_kafka_error_name(error));
-+ zend_update_property_long(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("code"), rd_kafka_error_code(error));
-+ zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("error_string"), rd_kafka_error_string(error));
-+ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("isFatal"), rd_kafka_error_is_fatal(error));
-+ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("isRetriable"), rd_kafka_error_is_retriable(error));
-+ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("transactionRequiresAbort"), rd_kafka_error_txn_requires_abort(error));
-
- Z_ADDREF_P(return_value);
- }
-@@ -65,12 +65,12 @@ PHP_METHOD(RdKafka__KafkaErrorException, __construct)
- return;
- }
-
-- zend_update_property_string(ce_kafka_error, getThis(), ZEND_STRL("message"), message);
-- zend_update_property_long(ce_kafka_error, getThis(), ZEND_STRL("code"), code);
-- zend_update_property_string(ce_kafka_error, getThis(), ZEND_STRL("error_string"), error_string);
-- zend_update_property_bool(ce_kafka_error, getThis(), ZEND_STRL("isFatal"), isFatal);
-- zend_update_property_bool(ce_kafka_error, getThis(), ZEND_STRL("isRetriable"), isRetriable);
-- zend_update_property_bool(ce_kafka_error, getThis(), ZEND_STRL("transactionRequiresAbort"), transactionRequiresAbort);
-+ zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("message"), message);
-+ zend_update_property_long(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("code"), code);
-+ zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("error_string"), error_string);
-+ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isFatal"), isFatal);
-+ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isRetriable"), isRetriable);
-+ zend_update_property_bool(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("transactionRequiresAbort"), transactionRequiresAbort);
- }
- /* }}} */
-
-@@ -88,7 +88,7 @@ PHP_METHOD(RdKafka__KafkaErrorException, getErrorString)
- return;
- }
-
-- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("error_string"), 0);
-+ res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("error_string"), 0);
-
- if (!res || Z_TYPE_P(res) != IS_STRING) {
- return;
-@@ -114,7 +114,7 @@ PHP_METHOD(RdKafka__KafkaErrorException, isFatal)
- return;
- }
-
-- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("isFatal"), 0);
-+ res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isFatal"), 0);
-
- if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) {
- return;
-@@ -139,7 +139,7 @@ PHP_METHOD(RdKafka__KafkaErrorException, isRetriable)
- return;
- }
-
-- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("isRetriable"), 0);
-+ res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("isRetriable"), 0);
-
- if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) {
- return;
-@@ -164,7 +164,7 @@ PHP_METHOD(RdKafka__KafkaErrorException, transactionRequiresAbort)
- return;
- }
-
-- res = rdkafka_read_property(ce_kafka_error, getThis(), ZEND_STRL("transactionRequiresAbort"), 0);
-+ res = rdkafka_read_property(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("transactionRequiresAbort"), 0);
-
- if (!res || (Z_TYPE_P(res) != IS_TRUE && Z_TYPE_P(res) != IS_FALSE)) {
- return;
-diff --git a/kafka_error_exception.h b/kafka_error_exception.h
-index 9193877..d44b895 100644
---- a/kafka_error_exception.h
-+++ b/kafka_error_exception.h
-@@ -15,10 +15,11 @@
- | Author: Arnaud Le Blanc <arnaud.lb@gmail.com> |
- +----------------------------------------------------------------------+
- */
-+
- #ifdef HAS_RD_KAFKA_TRANSACTIONS
-
- #include "librdkafka/rdkafka.h"
--#include "php.h"
-+#include "Zend/zend_interfaces.h"
-
- extern zend_class_entry * ce_kafka_error;
- void kafka_error_minit();
-diff --git a/message.c b/message.c
-index a6ed916..f4c4c7f 100644
---- a/message.c
-+++ b/message.c
-@@ -51,21 +51,21 @@ void kafka_message_new(zval *return_value, const rd_kafka_message_t *message)
- uint i;
- #endif /* HAVE_RD_KAFKA_MESSAGE_HEADERS */
-
-- zend_update_property_long(NULL, return_value, ZEND_STRL("err"), message->err);
-+ zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("err"), message->err);
-
- if (message->rkt) {
-- zend_update_property_string(NULL, return_value, ZEND_STRL("topic_name"), rd_kafka_topic_name(message->rkt));
-+ zend_update_property_string(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("topic_name"), rd_kafka_topic_name(message->rkt));
- }
-- zend_update_property_long(NULL, return_value, ZEND_STRL("partition"), message->partition);
-+ zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("partition"), message->partition);
- if (message->payload) {
-- zend_update_property_long(NULL, return_value, ZEND_STRL("timestamp"), timestamp);
-- zend_update_property_stringl(NULL, return_value, ZEND_STRL("payload"), message->payload, message->len);
-- zend_update_property_long(NULL, return_value, ZEND_STRL("len"), message->len);
-+ zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("timestamp"), timestamp);
-+ zend_update_property_stringl(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("payload"), message->payload, message->len);
-+ zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("len"), message->len);
- }
- if (message->key) {
-- zend_update_property_stringl(NULL, return_value, ZEND_STRL("key"), message->key, message->key_len);
-+ zend_update_property_stringl(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("key"), message->key, message->key_len);
- }
-- zend_update_property_long(NULL, return_value, ZEND_STRL("offset"), message->offset);
-+ zend_update_property_long(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("offset"), message->offset);
-
- #ifdef HAVE_RD_KAFKA_MESSAGE_HEADERS
- if (message->err == RD_KAFKA_RESP_ERR_NO_ERROR) {
-@@ -79,7 +79,7 @@ void kafka_message_new(zval *return_value, const rd_kafka_message_t *message)
- }
- add_assoc_stringl(&headers_array, header_name, (const char*)header_value, header_size);
- }
-- zend_update_property(NULL, return_value, ZEND_STRL("headers"), &headers_array);
-+ zend_update_property(NULL, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("headers"), &headers_array);
- zval_ptr_dtor(&headers_array);
- }
- }
-@@ -119,7 +119,7 @@ PHP_METHOD(RdKafka__Message, errstr)
- return;
- }
-
-- zerr = rdkafka_read_property(NULL, getThis(), ZEND_STRL("err"), 0);
-+ zerr = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("err"), 0);
-
- if (!zerr || Z_TYPE_P(zerr) != IS_LONG) {
- return;
-@@ -131,7 +131,7 @@ PHP_METHOD(RdKafka__Message, errstr)
- RETURN_STRING(errstr);
- }
-
-- zpayload = rdkafka_read_property(NULL, getThis(), ZEND_STRL("payload"), 0);
-+ zpayload = rdkafka_read_property(NULL, Z_RDKAFKA_PROP_OBJ(getThis()), ZEND_STRL("payload"), 0);
-
- if (zpayload && Z_TYPE_P(zpayload) == IS_STRING) {
- RETURN_ZVAL(zpayload, 1, 0);
-@@ -144,7 +144,7 @@ static const zend_function_entry kafka_message_fe[] = {
- PHP_FE_END
- };
-
--void kafka_message_minit() { /* {{{ */
-+void kafka_message_minit(INIT_FUNC_ARGS) { /* {{{ */
- zend_class_entry ce;
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Message", kafka_message_fe);
-diff --git a/message.h b/message.h
-index 5db24ce..3a0f701 100644
---- a/message.h
-+++ b/message.h
-@@ -16,7 +16,7 @@
- +----------------------------------------------------------------------+
- */
-
--void kafka_message_minit();
-+void kafka_message_minit(INIT_FUNC_ARGS);
- void kafka_message_new(zval *return_value, const rd_kafka_message_t *message);
- void kafka_message_list_to_array(zval *return_value, rd_kafka_message_t **messages, long size);
-
-diff --git a/metadata.c b/metadata.c
-index a43123c..4d3f12d 100644
---- a/metadata.c
-+++ b/metadata.c
-@@ -35,24 +35,24 @@ typedef struct _object_intern {
- zend_object std;
- } object_intern;
-
--static HashTable *get_debug_info(zval *object, int *is_temp);
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
-
- static zend_class_entry * ce;
- static zend_object_handlers handlers;
-
--static void brokers_collection(zval *return_value, zval *parent, object_intern *intern) { /* {{{ */
-+static void brokers_collection(zval *return_value, Z_RDKAFKA_OBJ *parent, object_intern *intern) { /* {{{ */
- kafka_metadata_collection_init(return_value, parent, intern->metadata->brokers, intern->metadata->broker_cnt, sizeof(*intern->metadata->brokers), kafka_metadata_broker_ctor);
- }
- /* }}} */
-
--static void topics_collection(zval *return_value, zval *parent, object_intern *intern) { /* {{{ */
-+static void topics_collection(zval *return_value, Z_RDKAFKA_OBJ *parent, object_intern *intern) { /* {{{ */
- kafka_metadata_collection_init(return_value, parent, intern->metadata->topics, intern->metadata->topic_cnt, sizeof(*intern->metadata->topics), kafka_metadata_topic_ctor);
- }
- /* }}} */
-
- static void kafka_metadata_free(zend_object *object) /* {{{ */
- {
-- object_intern *intern = get_custom_object(object_intern, object);
-+ object_intern *intern = php_kafka_from_obj(object_intern, object);
-
- if (intern->metadata) {
- rd_kafka_metadata_destroy(intern->metadata);
-@@ -80,7 +80,7 @@ static zend_object *kafka_metadata_new(zend_class_entry *class_type) /* {{{ */
-
- static object_intern * get_object(zval *zmetadata)
- {
-- object_intern *ometadata = get_custom_object_zval(object_intern, zmetadata);
-+ object_intern *ometadata = Z_RDKAFKA_P(object_intern, zmetadata);
-
- if (!ometadata->metadata) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\Metadata::__construct() has not been called");
-@@ -90,7 +90,7 @@ static object_intern * get_object(zval *zmetadata)
- return ometadata;
- }
-
--static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
- {
- zval ary;
- object_intern *intern;
-@@ -101,7 +101,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-
- array_init(&ary);
-
-- intern = get_object(object);
-+ intern = rdkafka_get_debug_object(object_intern, object);
- if (!intern) {
- return Z_ARRVAL(ary);
- }
-@@ -186,7 +186,7 @@ PHP_METHOD(RdKafka__Metadata, getBrokers)
- return;
- }
-
-- brokers_collection(return_value, getThis(), intern);
-+ brokers_collection(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern);
- }
- /* }}} */
-
-@@ -209,7 +209,7 @@ PHP_METHOD(RdKafka__Metadata, getTopics)
- return;
- }
-
-- topics_collection(return_value, getThis(), intern);
-+ topics_collection(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern);
- }
- /* }}} */
-
-@@ -221,7 +221,7 @@ static const zend_function_entry kafka_metadata_fe[] = {
- PHP_FE_END
- };
-
--void kafka_metadata_minit()
-+void kafka_metadata_minit(INIT_FUNC_ARGS)
- {
- zend_class_entry tmpce;
-
-@@ -234,10 +234,10 @@ void kafka_metadata_minit()
- handlers.free_obj = kafka_metadata_free;
- handlers.offset = XtOffsetOf(object_intern, std);
-
-- kafka_metadata_topic_minit();
-- kafka_metadata_broker_minit();
-- kafka_metadata_partition_minit();
-- kafka_metadata_collection_minit();
-+ kafka_metadata_topic_minit(INIT_FUNC_ARGS_PASSTHRU);
-+ kafka_metadata_broker_minit(INIT_FUNC_ARGS_PASSTHRU);
-+ kafka_metadata_partition_minit(INIT_FUNC_ARGS_PASSTHRU);
-+ kafka_metadata_collection_minit(INIT_FUNC_ARGS_PASSTHRU);
- }
-
- void kafka_metadata_init(zval *return_value, const rd_kafka_metadata_t *metadata)
-@@ -248,7 +248,7 @@ void kafka_metadata_init(zval *return_value, const rd_kafka_metadata_t *metadata
- return;
- }
-
-- intern = get_custom_object_zval(object_intern, return_value);
-+ intern = Z_RDKAFKA_P(object_intern, return_value);
- if (!intern) {
- return;
- }
-diff --git a/metadata.h b/metadata.h
-index b68592b..d09d2db 100644
---- a/metadata.h
-+++ b/metadata.h
-@@ -16,5 +16,5 @@
- +----------------------------------------------------------------------+
- */
-
--void kafka_metadata_minit();
-+void kafka_metadata_minit(INIT_FUNC_ARGS);
- void kafka_metadata_init(zval *return_value, const rd_kafka_metadata_t *metadata);
-diff --git a/metadata_broker.c b/metadata_broker.c
-index db9b4e3..b964231 100644
---- a/metadata_broker.c
-+++ b/metadata_broker.c
-@@ -34,14 +34,14 @@ typedef struct _object_intern {
- zend_object std;
- } object_intern;
-
--static HashTable *get_debug_info(zval *object, int *is_temp);
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
-
- static zend_class_entry * ce;
- static zend_object_handlers handlers;
-
- static void free_object(zend_object *object) /* {{{ */
- {
-- object_intern *intern = get_custom_object(object_intern, object);
-+ object_intern *intern = php_kafka_from_obj(object_intern, object);
-
- if (intern->metadata_broker) {
- zval_dtor(&intern->zmetadata);
-@@ -60,7 +60,6 @@ static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
-
--
- retval = &intern->std;
- retval->handlers = &handlers;
-
-@@ -70,7 +69,7 @@ static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
-
- static object_intern * get_object(zval *zmt)
- {
-- object_intern *omt = get_custom_object_zval(object_intern, zmt);
-+ object_intern *omt = Z_RDKAFKA_P(object_intern, zmt);
-
- if (!omt->metadata_broker) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\Metadata\\Broker::__construct() has not been called");
-@@ -80,7 +79,7 @@ static object_intern * get_object(zval *zmt)
- return omt;
- }
-
--static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
- {
- zval ary;
- object_intern *intern;
-@@ -89,7 +88,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-
- array_init(&ary);
-
-- intern = get_object(object);
-+ intern = rdkafka_get_debug_object(object_intern, object);
- if (!intern) {
- return Z_ARRVAL(ary);
- }
-@@ -178,7 +177,7 @@ static const zend_function_entry fe[] = {
- PHP_FE_END
- };
-
--void kafka_metadata_broker_minit()
-+void kafka_metadata_broker_minit(INIT_FUNC_ARGS)
- {
- zend_class_entry tmpce;
-
-@@ -201,7 +200,7 @@ void kafka_metadata_broker_ctor(zval *return_value, zval *zmetadata, const void
- return;
- }
-
-- intern = get_custom_object_zval(object_intern, return_value);
-+ intern = Z_RDKAFKA_P(object_intern, return_value);
- if (!intern) {
- return;
- }
-diff --git a/metadata_broker.h b/metadata_broker.h
-index c860495..6f64928 100644
---- a/metadata_broker.h
-+++ b/metadata_broker.h
-@@ -16,5 +16,5 @@
- +----------------------------------------------------------------------+
- */
-
--void kafka_metadata_broker_minit();
-+void kafka_metadata_broker_minit(INIT_FUNC_ARGS);
- void kafka_metadata_broker_ctor(zval *return_value, zval *zmetadata, const void *metadata_broker);
-diff --git a/metadata_collection.c b/metadata_collection.c
-index 460b3bc..af986ff 100644
---- a/metadata_collection.c
-+++ b/metadata_collection.c
-@@ -39,14 +39,14 @@ typedef struct _object_intern {
- zend_object std;
- } object_intern;
-
--static HashTable *get_debug_info(zval *object, int *is_temp);
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
-
- static zend_class_entry *ce;
- static zend_object_handlers handlers;
-
- static void free_object(zend_object *object) /* {{{ */
- {
-- object_intern *intern = get_custom_object(object_intern, object);
-+ object_intern *intern = php_kafka_from_obj(object_intern, object);
-
- if (intern->items) {
- zval_dtor(&intern->zmetadata);
-@@ -74,7 +74,7 @@ static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
-
- static object_intern * get_object(zval *zmti)
- {
-- object_intern *omti = get_custom_object_zval(object_intern, zmti);
-+ object_intern *omti = Z_RDKAFKA_P(object_intern, zmti);
-
- if (!omti->items) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\Metadata\\Collection::__construct() has not been called");
-@@ -84,7 +84,7 @@ static object_intern * get_object(zval *zmti)
- return omti;
- }
-
--static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
- {
- zval ary;
- object_intern *intern;
-@@ -95,7 +95,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-
- array_init(&ary);
-
-- intern = get_object(object);
-+ intern = rdkafka_get_debug_object(object_intern, object);
- if (!intern) {
- return Z_ARRVAL(ary);
- }
-@@ -268,7 +268,7 @@ static const zend_function_entry fe[] = {
- PHP_FE_END
- };
-
--void kafka_metadata_collection_minit()
-+void kafka_metadata_collection_minit(INIT_FUNC_ARGS)
- {
- zend_class_entry tmpce;
-
-@@ -283,7 +283,7 @@ void kafka_metadata_collection_minit()
- handlers.offset = XtOffsetOf(object_intern, std);
- }
-
--void kafka_metadata_collection_init(zval *return_value, zval *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor)
-+void kafka_metadata_collection_init(zval *return_value, Z_RDKAFKA_OBJ *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor)
- {
- object_intern *intern;
-
-@@ -291,12 +291,14 @@ void kafka_metadata_collection_init(zval *return_value, zval *zmetadata, const v
- return;
- }
-
-- intern = get_custom_object_zval(object_intern, return_value);
-+ intern = Z_RDKAFKA_P(object_intern, return_value);
- if (!intern) {
- return;
- }
-
-+#if PHP_MAJOR_VERSION < 8
- ZVAL_ZVAL(&intern->zmetadata, zmetadata, 1, 0);
-+#endif
- intern->items = items;
- intern->item_cnt = item_cnt;
- intern->item_size = item_size;
-diff --git a/metadata_collection.h b/metadata_collection.h
-index 13c6123..fff2fd6 100644
---- a/metadata_collection.h
-+++ b/metadata_collection.h
-@@ -18,5 +18,5 @@
-
- typedef void (*kafka_metadata_collection_ctor_t)(zval *renurn_value, zval *zmetadata, const void *object);
-
--void kafka_metadata_collection_minit();
--void kafka_metadata_collection_init(zval *return_value, zval *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor);
-+void kafka_metadata_collection_minit(INIT_FUNC_ARGS);
-+void kafka_metadata_collection_init(zval *return_value, Z_RDKAFKA_OBJ *zmetadata, const void * items, size_t item_cnt, size_t item_size, kafka_metadata_collection_ctor_t ctor);
-diff --git a/metadata_partition.c b/metadata_partition.c
-index 6f5f08f..7fcabc2 100644
---- a/metadata_partition.c
-+++ b/metadata_partition.c
-@@ -35,14 +35,14 @@ typedef struct _object_intern {
- zend_object std;
- } object_intern;
-
--static HashTable *get_debug_info(zval *object, int *is_temp);
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
-
- static zend_class_entry * ce;
- static zend_object_handlers handlers;
-
- static void free_object(zend_object *object) /* {{{ */
- {
-- object_intern *intern = get_custom_object(object_intern, object);
-+ object_intern *intern = php_kafka_from_obj(object_intern, object);
-
- if (intern->metadata_partition) {
- zval_dtor(&intern->zmetadata);
-@@ -70,7 +70,7 @@ static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
-
- static object_intern * get_object(zval *zmt)
- {
-- object_intern *omt = get_custom_object_zval(object_intern, zmt);
-+ object_intern *omt = Z_RDKAFKA_P(object_intern, zmt);
-
- if (!omt->metadata_partition) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\Metadata\\Partition::__construct() has not been called");
-@@ -80,7 +80,7 @@ static object_intern * get_object(zval *zmt)
- return omt;
- }
-
--static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
- {
- zval ary;
- object_intern *intern;
-@@ -89,7 +89,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-
- array_init(&ary);
-
-- intern = get_object(object);
-+ intern = rdkafka_get_debug_object(object_intern, object);
- if (!intern) {
- return Z_ARRVAL(ary);
- }
-@@ -196,7 +196,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getReplicas)
- return;
- }
-
-- kafka_metadata_collection_init(return_value, getThis(), intern->metadata_partition->replicas, intern->metadata_partition->replica_cnt, sizeof(*intern->metadata_partition->replicas), int32_ctor);
-+ kafka_metadata_collection_init(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern->metadata_partition->replicas, intern->metadata_partition->replica_cnt, sizeof(*intern->metadata_partition->replicas), int32_ctor);
- }
- /* }}} */
-
-@@ -219,7 +219,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getIsrs)
- return;
- }
-
-- kafka_metadata_collection_init(return_value, getThis(), intern->metadata_partition->isrs, intern->metadata_partition->isr_cnt, sizeof(*intern->metadata_partition->isrs), int32_ctor);
-+ kafka_metadata_collection_init(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern->metadata_partition->isrs, intern->metadata_partition->isr_cnt, sizeof(*intern->metadata_partition->isrs), int32_ctor);
- }
- /* }}} */
-
-@@ -232,7 +232,7 @@ static const zend_function_entry fe[] = {
- PHP_FE_END
- };
-
--void kafka_metadata_partition_minit()
-+void kafka_metadata_partition_minit(INIT_FUNC_ARGS)
- {
- zend_class_entry tmpce;
-
-@@ -255,7 +255,7 @@ void kafka_metadata_partition_ctor(zval *return_value, zval *zmetadata, const vo
- return;
- }
-
-- intern = get_custom_object_zval(object_intern, return_value);
-+ intern = Z_RDKAFKA_P(object_intern, return_value);
- if (!intern) {
- return;
- }
-diff --git a/metadata_partition.h b/metadata_partition.h
-index 9d9b4dc..8ce35b8 100644
---- a/metadata_partition.h
-+++ b/metadata_partition.h
-@@ -16,5 +16,5 @@
- +----------------------------------------------------------------------+
- */
-
--void kafka_metadata_partition_minit();
-+void kafka_metadata_partition_minit(INIT_FUNC_ARGS);
- void kafka_metadata_partition_ctor(zval *return_value, zval *zmetadata, const void *metadata_partition);
-diff --git a/metadata_topic.c b/metadata_topic.c
-index 9830beb..5aeeed7 100644
---- a/metadata_topic.c
-+++ b/metadata_topic.c
-@@ -36,19 +36,19 @@ typedef struct _object_intern {
- zend_object std;
- } object_intern;
-
--static HashTable *get_debug_info(zval *object, int *is_temp);
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
-
- static zend_class_entry * ce;
- static zend_object_handlers handlers;
-
--static void partitions_collection(zval *return_value, zval *parent, object_intern *intern) { /* {{{ */
-+static void partitions_collection(zval *return_value, Z_RDKAFKA_OBJ *parent, object_intern *intern) { /* {{{ */
- kafka_metadata_collection_init(return_value, parent, intern->metadata_topic->partitions, intern->metadata_topic->partition_cnt, sizeof(*intern->metadata_topic->partitions), kafka_metadata_partition_ctor);
- }
- /* }}} */
-
- static void free_object(zend_object *object) /* {{{ */
- {
-- object_intern *intern = get_custom_object(object_intern, object);
-+ object_intern *intern = php_kafka_from_obj(object_intern, object);
-
- if (intern->metadata_topic) {
- zval_dtor(&intern->zmetadata);
-@@ -76,7 +76,7 @@ static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
-
- static object_intern * get_object(zval *zmt)
- {
-- object_intern *omt = get_custom_object_zval(object_intern, zmt);
-+ object_intern *omt = Z_RDKAFKA_P(object_intern, zmt);
-
- if (!omt->metadata_topic) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\Metadata\\Topic::__construct() has not been called");
-@@ -86,7 +86,7 @@ static object_intern * get_object(zval *zmt)
- return omt;
- }
-
--static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
- {
- zval ary;
- object_intern *intern;
-@@ -96,7 +96,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-
- array_init(&ary);
-
-- intern = get_object(object);
-+ intern = rdkafka_get_debug_object(object_intern, object);
- if (!intern) {
- return Z_ARRVAL(ary);
- }
-@@ -179,7 +179,7 @@ PHP_METHOD(RdKafka__Metadata__Topic, getPartitions)
- return;
- }
-
-- partitions_collection(return_value, getThis(), intern);
-+ partitions_collection(return_value, Z_RDKAFKA_PROP_OBJ(getThis()), intern);
- }
- /* }}} */
-
-@@ -190,7 +190,7 @@ static const zend_function_entry fe[] = {
- PHP_FE_END
- };
-
--void kafka_metadata_topic_minit()
-+void kafka_metadata_topic_minit(INIT_FUNC_ARGS)
- {
- zend_class_entry tmpce;
-
-@@ -213,7 +213,7 @@ void kafka_metadata_topic_ctor(zval *return_value, zval *zmetadata, const void *
- return;
- }
-
-- intern = get_custom_object_zval(object_intern, return_value);
-+ intern = Z_RDKAFKA_P(object_intern, return_value);
- if (!intern) {
- return;
- }
-diff --git a/metadata_topic.h b/metadata_topic.h
-index 6c5522a..677203d 100644
---- a/metadata_topic.h
-+++ b/metadata_topic.h
-@@ -16,5 +16,5 @@
- +----------------------------------------------------------------------+
- */
-
--void kafka_metadata_topic_minit();
-+void kafka_metadata_topic_minit(INIT_FUNC_ARGS);
- void kafka_metadata_topic_ctor(zval *return_value, zval *zmetadata, const void *metadata_topic);
-diff --git a/php_rdkafka.h b/php_rdkafka.h
-index 77b40c8..19bef56 100644
---- a/php_rdkafka.h
-+++ b/php_rdkafka.h
-@@ -56,8 +56,4 @@ extern zend_class_entry * ce_kafka_exception;
- # define PHP_RDKAFKA_API
- #endif
-
--#ifdef ZTS
--#include "TSRM.h"
--#endif
--
- #endif /* PHP_RDKAFKA_H */
-diff --git a/php_rdkafka_priv.h b/php_rdkafka_priv.h
-index a2d44cf..922a88d 100644
---- a/php_rdkafka_priv.h
-+++ b/php_rdkafka_priv.h
-@@ -19,19 +19,28 @@
- #ifndef PHP_RDKAFKA_PRIV_H
- #define PHP_RDKAFKA_PRIV_H
-
--static inline zval * is_zval(zval * zv) {
-- return zv;
--}
-+#if PHP_MAJOR_VERSION >= 8
-
--#define get_custom_object_zval(type, zobject) \
-- ((type*)((char *)Z_OBJ_P(is_zval(zobject)) - XtOffsetOf(type, std)))
-+#define Z_RDKAFKA_OBJ zend_object
-
--static inline zend_object * is_zend_object(zend_object * object) {
-- return object;
--}
-+#define Z_RDKAFKA_PROP_OBJ(object) Z_OBJ_P(object)
-+
-+#define rdkafka_get_debug_object(type, object) php_kafka_from_obj(type, object)
-+
-+#else // PHP 7
-+
-+#define Z_RDKAFKA_OBJ zval
-
--#define get_custom_object(type, object) \
-- ((type*)((char *)is_zend_object(object) - XtOffsetOf(type, std)))
-+#define Z_RDKAFKA_PROP_OBJ(object) object
-+
-+#define rdkafka_get_debug_object(type, object) get_object(object)
-+
-+#endif
-+
-+#define Z_RDKAFKA_P(php_kafka_type, zobject) php_kafka_from_obj(php_kafka_type, Z_OBJ_P(zobject))
-+
-+#define php_kafka_from_obj(php_kafka_type, object) \
-+ ((php_kafka_type*)((char *)(object) - XtOffsetOf(php_kafka_type, std)))
-
- static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zval *retval, uint32_t param_count, zval params[])
- {
-@@ -56,12 +65,13 @@ static inline void rdkafka_call_function(zend_fcall_info *fci, zend_fcall_info_c
- }
- }
-
--static inline zval *rdkafka_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent)
-+static inline zval *rdkafka_read_property(zend_class_entry *scope, Z_RDKAFKA_OBJ *object, const char *name, size_t name_length, zend_bool silent)
- {
- zval rv;
- return zend_read_property(scope, object, name, name_length, silent, &rv);
- }
-
-+
- static inline char *rdkafka_hash_get_current_key_ex(HashTable *ht, HashPosition *pos)
- {
- zend_string* key;
-diff --git a/queue.c b/queue.c
-index 99ab609..182563a 100644
---- a/queue.c
-+++ b/queue.c
-@@ -37,7 +37,7 @@ static zend_object_handlers handlers;
-
- static void kafka_queue_free(zend_object *object) /* {{{ */
- {
-- kafka_queue_object *intern = get_custom_object(kafka_queue_object, object);
-+ kafka_queue_object *intern = php_kafka_from_obj(kafka_queue_object, object);
-
- if (intern->rkqu) {
- kafka_object *kafka_intern = get_kafka_object(&intern->zrk);
-@@ -68,7 +68,7 @@ static zend_object *kafka_queue_new(zend_class_entry *class_type) /* {{{ */
-
- kafka_queue_object * get_kafka_queue_object(zval *zrkqu)
- {
-- kafka_queue_object *orkqu = get_custom_object_zval(kafka_queue_object, zrkqu);
-+ kafka_queue_object *orkqu = Z_RDKAFKA_P(kafka_queue_object, zrkqu);
-
- if (!orkqu->rkqu) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\Queue::__construct() has not been called");
-@@ -127,7 +127,7 @@ static const zend_function_entry kafka_queue_fe[] = {
- PHP_FE_END
- };
-
--void kafka_queue_minit() { /* {{{ */
-+void kafka_queue_minit(INIT_FUNC_ARGS) { /* {{{ */
-
- zend_class_entry ce;
-
-diff --git a/queue.h b/queue.h
-index 79e8b3c..c3ecb78 100644
---- a/queue.h
-+++ b/queue.h
-@@ -22,7 +22,7 @@ typedef struct _kafka_queue_object {
- zend_object std;
- } kafka_queue_object;
-
--void kafka_queue_minit();
-+void kafka_queue_minit(INIT_FUNC_ARGS);
- kafka_queue_object * get_kafka_queue_object(zval *zrkqu);
-
- extern zend_class_entry * ce_kafka_queue;
-diff --git a/rdkafka.c b/rdkafka.c
-index 5d97b22..50cf5b3 100644
---- a/rdkafka.c
-+++ b/rdkafka.c
-@@ -76,7 +76,7 @@ static void stop_consuming(kafka_object * intern) {
-
- static void kafka_free(zend_object *object) /* {{{ */
- {
-- kafka_object *intern = get_custom_object(kafka_object, object);
-+ kafka_object *intern = php_kafka_from_obj(kafka_object, object);
-
- if (intern->rk) {
- if (intern->type == RD_KAFKA_CONSUMER) {
-@@ -122,7 +122,7 @@ static void kafka_init(zval *this_ptr, rd_kafka_type_t type, zval *zconf) /* {{{
- kafka_conf_object *conf_intern;
- rd_kafka_conf_t *conf = NULL;
-
-- intern = get_custom_object_zval(kafka_object, this_ptr);
-+ intern = Z_RDKAFKA_P(kafka_object, this_ptr);
- intern->type = type;
-
- if (zconf) {
-@@ -175,7 +175,7 @@ static zend_object *kafka_new(zend_class_entry *class_type) /* {{{ */
-
- kafka_object * get_kafka_object(zval *zrk)
- {
-- kafka_object *ork = get_custom_object_zval(kafka_object, zrk);
-+ kafka_object *ork = Z_RDKAFKA_P(kafka_object, zrk);
-
- if (!ork->rk) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\Kafka::__construct() has not been called");
-@@ -299,7 +299,7 @@ PHP_METHOD(RdKafka__Consumer, newQueue)
- return;
- }
-
-- queue_intern = get_custom_object_zval(kafka_queue_object, return_value);
-+ queue_intern = Z_RDKAFKA_P(kafka_queue_object, return_value);
- if (!queue_intern) {
- return;
- }
-@@ -310,6 +310,7 @@ PHP_METHOD(RdKafka__Consumer, newQueue)
- // the Queue object is destroyed before the Kafka object.
- // This avoids rd_kafka_destroy() hanging.
- queue_intern->zrk = *getThis();
-+
- Z_ADDREF_P(&queue_intern->zrk);
-
- zend_hash_index_add_ptr(&intern->queues, (zend_ulong)queue_intern, queue_intern);
-@@ -392,7 +393,7 @@ PHP_METHOD(RdKafka__Kafka, getMetadata)
- kafka_metadata_init(return_value, metadata);
- }
- /* }}} */
--
-+
- /* {{{ proto void RdKafka\Kafka::setLogLevel(int $level)
- Specifies the maximum logging level produced by internal kafka logging and debugging */
-
-@@ -475,13 +476,14 @@ PHP_METHOD(RdKafka__Kafka, newTopic)
- return;
- }
-
-- topic_intern = get_custom_object_zval(kafka_topic_object, return_value);
-+ topic_intern = Z_RDKAFKA_P(kafka_topic_object, return_value);
- if (!topic_intern) {
- return;
- }
-
- topic_intern->rkt = rkt;
- topic_intern->zrk = *getThis();
-+
- Z_ADDREF_P(&topic_intern->zrk);
-
- zend_hash_index_add_ptr(&intern->topics, (zend_ulong)topic_intern, topic_intern);
-@@ -673,7 +675,6 @@ PHP_METHOD(RdKafka__Kafka, offsetsForTimes)
- }
- /* }}} */
-
--
- /* {{{ proto void RdKafka::setLogger(mixed $logger)
- Sets the log callback */
-
-@@ -761,7 +762,6 @@ PHP_METHOD(RdKafka__Producer, __construct)
- /* }}} */
-
- #ifdef HAS_RD_KAFKA_TRANSACTIONS
--
- /* {{{ proto int RdKafka\Producer::initTransactions(int timeout_ms)
- Initializes transactions, needs to be done before producing and starting a transaction */
- ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_init_transactions, 0, 0, 1)
-@@ -886,7 +886,6 @@ PHP_METHOD(RdKafka__Producer, abortTransaction)
- zend_throw_exception_object(return_value);
- }
- /* }}} */
--
- #endif
-
- static const zend_function_entry kafka_producer_fe[] = {
-@@ -989,18 +988,18 @@ PHP_MINIT_FUNCTION(rdkafka)
- ce_kafka_producer = zend_register_internal_class_ex(&ce, ce_kafka);
-
- INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Exception", NULL);
-- ce_kafka_exception = zend_register_internal_class_ex(&ce, zend_exception_get_default());
-+ ce_kafka_exception = zend_register_internal_class_ex(&ce, zend_ce_exception);
-
-- kafka_conf_minit();
-+ kafka_conf_minit(INIT_FUNC_ARGS_PASSTHRU);
- #ifdef HAS_RD_KAFKA_TRANSACTIONS
- kafka_error_minit();
- #endif
-- kafka_kafka_consumer_minit();
-- kafka_message_minit();
-- kafka_metadata_minit();
-- kafka_metadata_topic_partition_minit();
-- kafka_queue_minit();
-- kafka_topic_minit();
-+ kafka_kafka_consumer_minit(INIT_FUNC_ARGS_PASSTHRU);
-+ kafka_message_minit(INIT_FUNC_ARGS_PASSTHRU);
-+ kafka_metadata_minit(INIT_FUNC_ARGS_PASSTHRU);
-+ kafka_metadata_topic_partition_minit(INIT_FUNC_ARGS_PASSTHRU);
-+ kafka_queue_minit(INIT_FUNC_ARGS_PASSTHRU);
-+ kafka_topic_minit(INIT_FUNC_ARGS_PASSTHRU);
-
- return SUCCESS;
- }
-diff --git a/tests/bug115.phpt b/tests/bug115.phpt
-index 5ea0af8..8c1620d 100644
---- a/tests/bug115.phpt
-+++ b/tests/bug115.phpt
-@@ -17,12 +17,6 @@ $conf->setErrorCb(function ($producer, $err, $errstr) {
- printf("%s: %s\n", rd_kafka_err2str($err), $errstr);
- exit;
- });
--$conf->setDrMsgCb(function ($producer, $msg) use (&$delivered) {
-- if ($msg->err) {
-- throw new Exception("Message delivery failed: " . $msg->errstr());
-- }
-- $delivered++;
--});
- $conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
-
- $topicName = sprintf("test_rdkafka_%s", uniqid());
-diff --git a/tests/bug74.phpt b/tests/bug74.phpt
-index 8cb23fd..04f4857 100644
---- a/tests/bug74.phpt
-+++ b/tests/bug74.phpt
-@@ -1,10 +1,14 @@
- --TEST--
- Bug 74
-+--SKIPIF--
-+<?php
-+require __DIR__ . '/integration-tests-check.php';
- --FILE--
- <?php
-+require __DIR__ . '/integration-tests-check.php';
-
- $conf = new RdKafka\Conf();
--$conf->set('metadata.broker.list', 'localhost:9092');
-+$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
-
- $consumer = new RdKafka\Consumer($conf);
- $topic = $consumer->newTopic("batman", null);
-diff --git a/tests/conf_setDefaultTopicConf.phpt b/tests/conf_setDefaultTopicConf.phpt
-index 6b48505..ad08f3b 100644
---- a/tests/conf_setDefaultTopicConf.phpt
-+++ b/tests/conf_setDefaultTopicConf.phpt
-@@ -2,7 +2,7 @@
- RdKafka\Conf::setDefaultTopicConf()
- --SKIPIF--
- <?php
--if (!method_exists('RdKafka\Conf', 'setDefaultTopicConf')) {
-+if (!method_exists('RdKafka\Conf', 'setDefaultTopicConf') || 7 < PHP_MAJOR_VERSION) {
- echo "skip";
- }
- ?>
-diff --git a/tests/message_headers.phpt b/tests/message_headers.phpt
-index 61436ae..a244089 100644
---- a/tests/message_headers.phpt
-+++ b/tests/message_headers.phpt
-@@ -15,13 +15,16 @@ $conf->setErrorCb(function ($producer, $err, $errstr) {
- printf("%s: %s\n", rd_kafka_err2str($err), $errstr);
- exit;
- });
-+$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
-+
-+$consumer = new RdKafka\Consumer($conf);
-+
- $conf->setDrMsgCb(function ($producer, $msg) use (&$delivered) {
- if ($msg->err) {
- throw new Exception("Message delivery failed: " . $msg->errstr());
- }
- $delivered++;
- });
--$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
-
- $producer = new RdKafka\Producer($conf);
-
-@@ -57,8 +60,6 @@ while ($producer->getOutQLen()) {
-
- printf("%d messages delivered\n", $delivered);
-
--$consumer = new RdKafka\Consumer($conf);
--
- $topic = $consumer->newTopic($topicName);
- $topic->consumeStart(0, RD_KAFKA_OFFSET_BEGINNING);
-
-diff --git a/tests/produce_consume.phpt b/tests/produce_consume.phpt
-index c10ed1e..9f87208 100644
---- a/tests/produce_consume.phpt
-+++ b/tests/produce_consume.phpt
-@@ -17,13 +17,17 @@ $conf->setErrorCb(function ($producer, $err, $errstr) {
- printf("%s: %s\n", rd_kafka_err2str($err), $errstr);
- exit;
- });
-+
-+$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
-+
-+$consumer = new RdKafka\Consumer($conf);
-+
- $conf->setDrMsgCb(function ($producer, $msg) use (&$delivered) {
- if ($msg->err) {
- throw new Exception("Message delivery failed: " . $msg->errstr());
- }
- $delivered++;
- });
--$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
-
- $producer = new RdKafka\Producer($conf);
-
-@@ -46,8 +50,6 @@ while ($producer->getOutQLen()) {
-
- printf("%d messages delivered\n", $delivered);
-
--$consumer = new RdKafka\Consumer($conf);
--
- $topic = $consumer->newTopic($topicName);
- $topic->consumeStart(0, RD_KAFKA_OFFSET_BEGINNING);
-
-diff --git a/tests/produce_consume_queue.phpt b/tests/produce_consume_queue.phpt
-index 9e3dda1..275daf7 100644
---- a/tests/produce_consume_queue.phpt
-+++ b/tests/produce_consume_queue.phpt
-@@ -10,8 +10,6 @@ require __DIR__ . '/integration-tests-check.php';
- $delivered = 0;
-
- $conf = new RdKafka\Conf();
--// Required to detect actual reaching of partition EOF for both topics
--$conf->set('enable.partition.eof', 'true');
- if (RD_KAFKA_VERSION >= 0x090000 && false !== getenv('TEST_KAFKA_BROKER_VERSION')) {
- $conf->set('broker.version.fallback', getenv('TEST_KAFKA_BROKER_VERSION'));
- }
-@@ -53,6 +51,19 @@ while ($producer->getOutQLen()) {
-
- printf("%d messages delivered\n", $delivered);
-
-+$conf = new RdKafka\Conf();
-+// Required to detect actual reaching of partition EOF for both topics
-+$conf->set('enable.partition.eof', 'true');
-+if (RD_KAFKA_VERSION >= 0x090000 && false !== getenv('TEST_KAFKA_BROKER_VERSION')) {
-+ $conf->set('broker.version.fallback', getenv('TEST_KAFKA_BROKER_VERSION'));
-+}
-+$conf->setErrorCb(function ($producer, $err, $errstr) {
-+ printf("%s: %s\n", rd_kafka_err2str($err), $errstr);
-+ exit;
-+});
-+
-+$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
-+
- $consumer = new RdKafka\Consumer($conf);
-
- $queue = $consumer->newQueue();
-diff --git a/topic.c b/topic.c
-index 78887a3..bc274d6 100644
---- a/topic.c
-+++ b/topic.c
-@@ -45,7 +45,7 @@ typedef struct _php_callback {
-
- static void kafka_topic_free(zend_object *object) /* {{{ */
- {
-- kafka_topic_object *intern = get_custom_object(kafka_topic_object, object);
-+ kafka_topic_object *intern = php_kafka_from_obj(kafka_topic_object, object);
-
- if (Z_TYPE(intern->zrk) != IS_UNDEF && intern->rkt) {
- kafka_object *kafka_intern = get_kafka_object(&intern->zrk);
-@@ -99,7 +99,7 @@ static void consume_callback(rd_kafka_message_t *msg, void *opaque)
-
- kafka_topic_object * get_kafka_topic_object(zval *zrkt)
- {
-- kafka_topic_object *orkt = get_custom_object_zval(kafka_topic_object, zrkt);
-+ kafka_topic_object *orkt = Z_RDKAFKA_P(kafka_topic_object, zrkt);
-
- if (!orkt->rkt) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\Topic::__construct() has not been called");
-@@ -665,7 +665,7 @@ static const zend_function_entry kafka_topic_fe[] = {
- PHP_FE_END
- };
-
--void kafka_topic_minit() { /* {{{ */
-+void kafka_topic_minit(INIT_FUNC_ARGS) { /* {{{ */
-
- zend_class_entry ce;
-
-diff --git a/topic.h b/topic.h
-index 51aa186..4e712e9 100644
---- a/topic.h
-+++ b/topic.h
-@@ -22,7 +22,7 @@ typedef struct _kafka_topic_object {
- zend_object std;
- } kafka_topic_object;
-
--void kafka_topic_minit();
-+void kafka_topic_minit(INIT_FUNC_ARGS);
- kafka_topic_object * get_kafka_topic_object(zval *zrkt);
-
- extern zend_class_entry * ce_kafka_consumer_topic;
-diff --git a/topic_partition.c b/topic_partition.c
-index ebbbfaf..9d1b1f7 100644
---- a/topic_partition.c
-+++ b/topic_partition.c
-@@ -32,7 +32,7 @@
-
- typedef kafka_topic_partition_intern object_intern;
-
--static HashTable *get_debug_info(zval *object, int *is_temp);
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp);
-
- zend_class_entry * ce_kafka_topic_partition;
-
-@@ -40,7 +40,7 @@ static zend_object_handlers handlers;
-
- static void free_object(zend_object *object) /* {{{ */
- {
-- object_intern *intern = get_custom_object(object_intern, object);
-+ object_intern *intern = php_kafka_from_obj(object_intern, object);
-
- if (intern->topic) {
- efree(intern->topic);
-@@ -68,7 +68,7 @@ static zend_object *create_object(zend_class_entry *class_type) /* {{{ */
-
- static object_intern * get_object(zval *z) /* {{{ */
- {
-- object_intern * intern = get_custom_object_zval(object_intern, z);
-+ object_intern *intern = Z_RDKAFKA_P(object_intern, z);
-
- if (!intern->topic) {
- zend_throw_exception_ex(NULL, 0, "RdKafka\\TopicPartition::__construct() has not been called");
-@@ -83,7 +83,7 @@ kafka_topic_partition_intern * get_topic_partition_object(zval *z) /* {{{ */
- return get_object(z);
- } /* }}} */
-
--static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-+static HashTable *get_debug_info(Z_RDKAFKA_OBJ *object, int *is_temp) /* {{{ */
- {
- zval ary;
- object_intern *intern;
-@@ -92,7 +92,8 @@ static HashTable *get_debug_info(zval *object, int *is_temp) /* {{{ */
-
- array_init(&ary);
-
-- intern = get_object(object);
-+ intern = rdkafka_get_debug_object(object_intern, object);
-+
- if (!intern) {
- return Z_ARRVAL(ary);
- }
-@@ -114,7 +115,7 @@ void kafka_topic_partition_init(zval *zobj, char * topic, int32_t partition, int
- {
- object_intern *intern;
-
-- intern = get_custom_object_zval(object_intern, zobj);
-+ intern = Z_RDKAFKA_P(object_intern, zobj);
- if (!intern) {
- return;
- }
-@@ -386,7 +387,7 @@ static const zend_function_entry fe[] = { /* {{{ */
- PHP_FE_END
- }; /* }}} */
-
--void kafka_metadata_topic_partition_minit() /* {{{ */
-+void kafka_metadata_topic_partition_minit(INIT_FUNC_ARGS) /* {{{ */
- {
- zend_class_entry tmpce;
+-void kafka_metadata_topic_partition_minit(TSRMLS_D);
++void kafka_metadata_topic_partition_minit(INIT_FUNC_ARGS);
-diff --git a/topic_partition.h b/topic_partition.h
-index 746b1a5..f2d405d 100644
---- a/topic_partition.h
-+++ b/topic_partition.h
-@@ -23,7 +23,7 @@ typedef struct _kafka_topic_partition_intern {
- zend_object std;
- } kafka_topic_partition_intern;
+-kafka_topic_partition_intern * get_topic_partition_object(zval *z TSRMLS_DC);
+-void kafka_topic_partition_init(zval *z, char *topic, int32_t partition, int64_t offset TSRMLS_DC);
++kafka_topic_partition_intern * get_topic_partition_object(zval *z);
++void kafka_topic_partition_init(zval *z, char *topic, int32_t partition, int64_t offset);
--void kafka_metadata_topic_partition_minit();
-+void kafka_metadata_topic_partition_minit(INIT_FUNC_ARGS);
+-void kafka_topic_partition_list_to_array(zval *return_value, rd_kafka_topic_partition_list_t *list TSRMLS_DC);
+-rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int argnum, HashTable *ary TSRMLS_DC);
++void kafka_topic_partition_list_to_array(zval *return_value, rd_kafka_topic_partition_list_t *list);
++rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int argnum, HashTable *ary);
- kafka_topic_partition_intern * get_topic_partition_object(zval *z);
- void kafka_topic_partition_init(zval *z, char *topic, int32_t partition, int64_t offset);
+ extern zend_class_entry * ce_kafka_topic_partition;