diff options
-rw-r--r-- | php-pecl-rdkafka4.spec | 14 | ||||
-rw-r--r-- | rdkafka-php8.patch | 7683 |
2 files changed, 7695 insertions, 2 deletions
diff --git a/php-pecl-rdkafka4.spec b/php-pecl-rdkafka4.spec index 5f7b6de..2845f50 100644 --- a/php-pecl-rdkafka4.spec +++ b/php-pecl-rdkafka4.spec @@ -21,14 +21,17 @@ Summary: Kafka client based on librdkafka Name: %{?sub_prefix}php-pecl-%{pecl_name}4 Version: 4.1.0 -Release: 1%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} +Release: 2%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} License: MIT URL: https://pecl.php.net/package/%{pecl_name} Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz +Patch0: %{pecl_name}-php8.patch + BuildRequires: %{?dtsprefix}gcc +BuildRequires: make BuildRequires: librdkafka1php-devel -BuildRequires: %{?scl_prefix}php-devel > 5.6 +BuildRequires: %{?scl_prefix}php-devel >= 5.6 BuildRequires: %{?scl_prefix}php-pear Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} @@ -84,6 +87,10 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd NTS +%if "%{php_version}" > "8.0" +%patch0 -p1 -b .up +%endif + # Sanity check, really often broken extver=$(sed -n '/#define PHP_RDKAFKA_VERSION/{s/.* "//;s/".*$//;p}' php_rdkafka.h) if test "x${extver}" != "x%{version}"; then @@ -198,6 +205,9 @@ cd ../ZTS %changelog +* Mon Dec 7 2020 Remi Collet <remi@remirepo.net> - 4.1.0-2 +- add upstream patches for PHP 8 + * Mon Dec 7 2020 Remi Collet <remi@remirepo.net> - 4.1.0-1 - update to 4.1.0 diff --git a/rdkafka-php8.patch b/rdkafka-php8.patch new file mode 100644 index 0000000..dcb7e0e --- /dev/null +++ b/rdkafka-php8.patch @@ -0,0 +1,7683 @@ +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 +--- a/conf.c ++++ b/conf.c +@@ -38,7 +38,7 @@ zend_class_entry * ce_kafka_topic_conf; + + static zend_object_handlers handlers; + +-static void kafka_conf_callback_dtor(kafka_conf_callback *cb TSRMLS_DC) /* {{{ */ ++static void kafka_conf_callback_dtor(kafka_conf_callback *cb) /* {{{ */ + { + 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) /* {{{ * + } + } /* }}} */ + +-void kafka_conf_callbacks_dtor(kafka_conf_callbacks *cbs TSRMLS_DC) /* {{{ */ ++void kafka_conf_callbacks_dtor(kafka_conf_callbacks *cbs) /* {{{ */ + { +- kafka_conf_callback_dtor(cbs->error TSRMLS_CC); ++ kafka_conf_callback_dtor(cbs->error); + cbs->error = NULL; +- kafka_conf_callback_dtor(cbs->rebalance TSRMLS_CC); ++ kafka_conf_callback_dtor(cbs->rebalance); + cbs->rebalance = NULL; +- kafka_conf_callback_dtor(cbs->dr_msg TSRMLS_CC); ++ kafka_conf_callback_dtor(cbs->dr_msg); + cbs->dr_msg = NULL; +- kafka_conf_callback_dtor(cbs->stats TSRMLS_CC); ++ kafka_conf_callback_dtor(cbs->stats); + cbs->stats = NULL; +- kafka_conf_callback_dtor(cbs->consume TSRMLS_CC); ++ kafka_conf_callback_dtor(cbs->consume); + cbs->consume = NULL; +- kafka_conf_callback_dtor(cbs->offset_commit TSRMLS_CC); ++ kafka_conf_callback_dtor(cbs->offset_commit); + cbs->offset_commit = NULL; +- kafka_conf_callback_dtor(cbs->log TSRMLS_CC); ++ kafka_conf_callback_dtor(cbs->log); + cbs->log = NULL; + } /* }}} */ + +-static void kafka_conf_callback_copy(kafka_conf_callback **to, kafka_conf_callback *from TSRMLS_DC) /* {{{ */ ++static void kafka_conf_callback_copy(kafka_conf_callback **to, kafka_conf_callback *from) /* {{{ */ + { + if (from) { + *to = emalloc(sizeof(**to)); +@@ -77,18 +77,18 @@ static void kafka_conf_callback_copy(kafka_conf_callback **to, kafka_conf_callba + } + } /* }}} */ + +-void kafka_conf_callbacks_copy(kafka_conf_callbacks *to, kafka_conf_callbacks *from TSRMLS_DC) /* {{{ */ ++void kafka_conf_callbacks_copy(kafka_conf_callbacks *to, kafka_conf_callbacks *from) /* {{{ */ + { +- kafka_conf_callback_copy(&to->error, from->error TSRMLS_CC); +- kafka_conf_callback_copy(&to->rebalance, from->rebalance TSRMLS_CC); +- kafka_conf_callback_copy(&to->dr_msg, from->dr_msg TSRMLS_CC); +- kafka_conf_callback_copy(&to->stats, from->stats TSRMLS_CC); +- kafka_conf_callback_copy(&to->consume, from->consume TSRMLS_CC); +- kafka_conf_callback_copy(&to->offset_commit, from->offset_commit TSRMLS_CC); +- kafka_conf_callback_copy(&to->log, from->log TSRMLS_CC); ++ kafka_conf_callback_copy(&to->error, from->error); ++ kafka_conf_callback_copy(&to->rebalance, from->rebalance); ++ kafka_conf_callback_copy(&to->dr_msg, from->dr_msg); ++ kafka_conf_callback_copy(&to->stats, from->stats); ++ kafka_conf_callback_copy(&to->consume, from->consume); ++ kafka_conf_callback_copy(&to->offset_commit, from->offset_commit); ++ kafka_conf_callback_copy(&to->log, from->log); + } /* }}} */ + +-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); + +@@ -97,7 +97,7 @@ static void kafka_conf_free(zend_object *object TSRMLS_DC) /* {{{ */ + if (intern->u.conf) { + rd_kafka_conf_destroy(intern->u.conf); + } +- kafka_conf_callbacks_dtor(&intern->cbs TSRMLS_CC); ++ kafka_conf_callbacks_dtor(&intern->cbs); + break; + case KAFKA_TOPIC_CONF: + if (intern->u.topic_conf) { +@@ -106,19 +106,19 @@ static void kafka_conf_free(zend_object *object TSRMLS_DC) /* {{{ */ + break; + } + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) /* {{{ */ + { + zend_object_value retval; + kafka_conf_object *intern; + + intern = alloc_object(intern, class_type); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ 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) + } + /* }}} */ + +-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); + + if (!oconf->type) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Conf::__construct() has not been called" TSRMLS_CC); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\Conf::__construct() has not been called"); + 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); + +- 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]); + + 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); + +- 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); + +- 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_ + err = rd_kafka_assign(rk, NULL); + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +@@ -253,9 +253,9 @@ static void kafka_conf_rebalance_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, rd_ + + 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); + +- 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]); + +- 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); + + +- rdkafka_call_function(&cbs->consume->fci, &cbs->consume->fcc, NULL, 2, args TSRMLS_CC); ++ rdkafka_call_function(&cbs->consume->fci, &cbs->consume->fcc, NULL, 2, args); + + 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, + + 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); + +- 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); + +- 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) + kafka_conf_object *intern; + zend_error_handling error_handling; + +- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC); ++ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling); + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { ++ zend_restore_error_handling(&error_handling); + return; + } + +@@ -368,7 +368,7 @@ PHP_METHOD(RdKafka__Conf, __construct) + intern->type = KAFKA_CONF; + intern->u.conf = rd_kafka_conf_new(); + +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ zend_restore_error_handling(&error_handling); + } + /* }}} */ + +@@ -385,11 +385,11 @@ PHP_METHOD(RdKafka__Conf, dump) + kafka_conf_object *intern; + size_t i; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- intern = get_kafka_conf_object(getThis() TSRMLS_CC); ++ intern = get_kafka_conf_object(getThis()); + if (!intern) { + return; + } +@@ -435,11 +435,11 @@ PHP_METHOD(RdKafka__Conf, set) + rd_kafka_conf_res_t ret = 0; + char errstr[512]; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &value, &value_len) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &value, &value_len) == FAILURE) { + return; + } + +- intern = get_kafka_conf_object(getThis() TSRMLS_CC); ++ intern = get_kafka_conf_object(getThis()); + if (!intern) { + return; + } +@@ -457,10 +457,10 @@ PHP_METHOD(RdKafka__Conf, set) + + switch (ret) { + case RD_KAFKA_CONF_UNKNOWN: +- zend_throw_exception(ce_kafka_exception, errstr, RD_KAFKA_CONF_UNKNOWN TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, errstr, RD_KAFKA_CONF_UNKNOWN); + return; + case RD_KAFKA_CONF_INVALID: +- zend_throw_exception(ce_kafka_exception, errstr, RD_KAFKA_CONF_INVALID TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, errstr, RD_KAFKA_CONF_INVALID); + return; + case RD_KAFKA_CONF_OK: + break; +@@ -481,16 +481,16 @@ PHP_METHOD(RdKafka__Conf, setDefaultTopicConf) + kafka_conf_object *topic_conf_intern; + rd_kafka_topic_conf_t *topic_conf; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &ztopic_conf, ce_kafka_topic_conf) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &ztopic_conf, ce_kafka_topic_conf) == FAILURE) { + return; + } + +- intern = get_kafka_conf_object(getThis() TSRMLS_CC); ++ intern = get_kafka_conf_object(getThis()); + if (!intern) { + return; + } + +- topic_conf_intern = get_kafka_conf_object(ztopic_conf TSRMLS_CC); ++ topic_conf_intern = get_kafka_conf_object(ztopic_conf); + if (!topic_conf_intern) { + return; + } +@@ -514,11 +514,11 @@ PHP_METHOD(RdKafka__Conf, setErrorCb) + zend_fcall_info_cache fcc; + kafka_conf_object *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fci, &fcc) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) { + return; + } + +- intern = get_kafka_conf_object(getThis() TSRMLS_CC); ++ intern = get_kafka_conf_object(getThis()); + if (!intern) { + return; + } +@@ -551,11 +551,11 @@ PHP_METHOD(RdKafka__Conf, setDrMsgCb) + zend_fcall_info_cache fcc; + kafka_conf_object *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fci, &fcc) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) { + return; + } + +- intern = get_kafka_conf_object(getThis() TSRMLS_CC); ++ intern = get_kafka_conf_object(getThis()); + if (!intern) { + return; + } +@@ -588,11 +588,11 @@ PHP_METHOD(RdKafka__Conf, setStatsCb) + zend_fcall_info_cache fcc; + kafka_conf_object *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fci, &fcc) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) { + return; + } + +- intern = get_kafka_conf_object(getThis() TSRMLS_CC); ++ intern = get_kafka_conf_object(getThis()); + if (!intern) { + return; + } +@@ -625,11 +625,11 @@ PHP_METHOD(RdKafka__Conf, setRebalanceCb) + zend_fcall_info_cache fcc; + kafka_conf_object *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fci, &fcc) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) { + return; + } + +- intern = get_kafka_conf_object(getThis() TSRMLS_CC); ++ intern = get_kafka_conf_object(getThis()); + if (!intern) { + return; + } +@@ -662,11 +662,11 @@ PHP_METHOD(RdKafka__Conf, setConsumeCb) + zend_fcall_info_cache fcc; + kafka_conf_object *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fci, &fcc) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) { + return; + } + +- intern = get_kafka_conf_object(getThis() TSRMLS_CC); ++ intern = get_kafka_conf_object(getThis()); + if (!intern) { + return; + } +@@ -699,11 +699,11 @@ PHP_METHOD(RdKafka__Conf, setOffsetCommitCb) + zend_fcall_info_cache fcc; + kafka_conf_object *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fci, &fcc) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) { + return; + } + +- intern = get_kafka_conf_object(getThis() TSRMLS_CC); ++ intern = get_kafka_conf_object(getThis()); + if (!intern) { + return; + } +@@ -737,11 +737,11 @@ PHP_METHOD(RdKafka__Conf, setLogCb) + kafka_conf_object *conf; + char errstr[512]; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fci, &fcc) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) { + return; + } + +- conf = get_kafka_conf_object(getThis() TSRMLS_CC); ++ conf = get_kafka_conf_object(getThis()); + if (!conf) { + return; + } +@@ -768,10 +768,10 @@ PHP_METHOD(RdKafka__TopicConf, __construct) + kafka_conf_object *intern; + zend_error_handling error_handling; + +- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC); ++ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling); + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { ++ zend_restore_error_handling(&error_handling); + return; + } + +@@ -779,7 +779,7 @@ PHP_METHOD(RdKafka__TopicConf, __construct) + intern->type = KAFKA_TOPIC_CONF; + intern->u.topic_conf = rd_kafka_topic_conf_new(); + +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ zend_restore_error_handling(&error_handling); + } + /* }}} */ + +@@ -795,11 +795,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); + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id) == FAILURE) { + return; + } + +- intern = get_kafka_conf_object(getThis() TSRMLS_CC); ++ intern = get_kafka_conf_object(getThis()); + if (!intern) { + return; + } +@@ -823,7 +823,7 @@ PHP_METHOD(RdKafka__TopicConf, setPartitioner) + break; + #endif + default: +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Invalid partitioner given" TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Invalid partitioner given"); + return; + } + +@@ -854,7 +854,7 @@ static const zend_function_entry kafka_conf_fe[] = { + PHP_FE_END + }; + +-void kafka_conf_minit(TSRMLS_D) ++void kafka_conf_minit() + { + zend_class_entry tmpce; + +@@ -863,10 +863,10 @@ void kafka_conf_minit(TSRMLS_D) + set_object_handler_offset(&handlers, 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); ++ ce_kafka_conf = zend_register_internal_class(&tmpce); + ce_kafka_conf->create_object = kafka_conf_new; + + INIT_NS_CLASS_ENTRY(tmpce, "RdKafka", "TopicConf", kafka_topic_conf_fe); +- ce_kafka_topic_conf = zend_register_internal_class(&tmpce TSRMLS_CC); ++ ce_kafka_topic_conf = zend_register_internal_class(&tmpce); + ce_kafka_topic_conf->create_object = kafka_conf_new; + } +diff --git a/conf.h b/conf.h +index 3ec6bcf..4bf13b2 100644 +--- a/conf.h ++++ b/conf.h +@@ -63,11 +63,11 @@ typedef struct _kafka_conf_object { + #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_callbacks_dtor(kafka_conf_callbacks *cbs TSRMLS_DC); +-void kafka_conf_callbacks_copy(kafka_conf_callbacks *to, kafka_conf_callbacks *from TSRMLS_DC); ++void kafka_conf_callbacks_dtor(kafka_conf_callbacks *cbs); ++void kafka_conf_callbacks_copy(kafka_conf_callbacks *to, kafka_conf_callbacks *from); + + 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 +--- a/fun.c ++++ b/fun.c +@@ -106,7 +106,7 @@ PHP_FUNCTION(rd_kafka_err2str) + zend_long err; + const char *errstr; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &err) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &err) == FAILURE) { + return; + } + +@@ -122,7 +122,7 @@ PHP_FUNCTION(rd_kafka_err2str) + * Returns `errno` */ + PHP_FUNCTION(rd_kafka_errno) + { +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +@@ -136,7 +136,7 @@ PHP_FUNCTION(rd_kafka_errno2err) + { + zend_long errnox; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &errnox) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &errnox) == FAILURE) { + return; + } + +@@ -164,7 +164,7 @@ PHP_FUNCTION(rd_kafka_offset_tail) + { + zend_long cnt; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &cnt) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &cnt) == FAILURE) { + return; + } + +diff --git a/kafka_consumer.c b/kafka_consumer.c +index 5ee209a..8b6c4c2 100644 +--- a/kafka_consumer.c ++++ b/kafka_consumer.c +@@ -46,11 +46,11 @@ typedef struct _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); + 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) /* {{{ */ + intern->rk = NULL; + } + +- kafka_conf_callbacks_dtor(&intern->cbs TSRMLS_CC); ++ kafka_conf_callbacks_dtor(&intern->cbs); + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) /* {{{ */ + { + zend_object_value retval; + object_intern *intern; + + intern = alloc_object(intern, class_type); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ 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_ + } + /* }}} */ + +-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); + + if (!oconsumer->rk) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\KafkaConsumer::__construct() has not been called"); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\KafkaConsumer::__construct() has not been called"); + return NULL; + } + +@@ -134,19 +134,19 @@ PHP_METHOD(RdKafka__KafkaConsumer, __construct) + kafka_conf_object *conf_intern; + rd_kafka_conf_t *conf = NULL; + +- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC); ++ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling); + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zconf, ce_kafka_conf) == FAILURE) { +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zconf, ce_kafka_conf) == FAILURE) { ++ zend_restore_error_handling(&error_handling); + return; + } + + intern = get_custom_object_zval(object_intern, getThis()); + +- conf_intern = get_kafka_conf_object(zconf TSRMLS_CC); ++ conf_intern = get_kafka_conf_object(zconf); + if (conf_intern) { + conf = rd_kafka_conf_dup(conf_intern->u.conf); +- kafka_conf_callbacks_copy(&intern->cbs, &conf_intern->cbs TSRMLS_CC); ++ kafka_conf_callbacks_copy(&intern->cbs, &conf_intern->cbs); + intern->cbs.zrk = *getThis(); + rd_kafka_conf_set_opaque(conf, &intern->cbs); + } +@@ -155,15 +155,15 @@ PHP_METHOD(RdKafka__KafkaConsumer, __construct) + if (conf) { + rd_kafka_conf_destroy(conf); + } +- zend_throw_exception(ce_kafka_exception, "\"group.id\" must be configured", 0 TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, "\"group.id\" must be configured", 0); + return; + } + + rk = rd_kafka_new(RD_KAFKA_CONSUMER, conf, errstr, sizeof(errstr)); + + if (rk == NULL) { +- zend_restore_error_handling(&error_handling TSRMLS_CC); +- zend_throw_exception(ce_kafka_exception, errstr, 0 TSRMLS_CC); ++ zend_restore_error_handling(&error_handling); ++ zend_throw_exception(ce_kafka_exception, errstr, 0); + return; + } + +@@ -175,7 +175,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, __construct) + + rd_kafka_poll_set_consumer(rk); + +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ zend_restore_error_handling(&error_handling); + } + /* }}} */ + +@@ -193,17 +193,17 @@ PHP_METHOD(RdKafka__KafkaConsumer, assign) + rd_kafka_resp_err_t err; + object_intern *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|h!", &htopars) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|h!", &htopars) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + + if (htopars) { +- topics = array_arg_to_kafka_topic_partition_list(1, htopars TSRMLS_CC); ++ topics = array_arg_to_kafka_topic_partition_list(1, htopars); + if (!topics) { + return; + } +@@ -218,7 +218,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, assign) + } + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + } +@@ -236,11 +236,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getAssignment) + rd_kafka_topic_partition_list_t *topics; + object_intern *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -248,11 +248,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getAssignment) + err = rd_kafka_assignment(intern->rk, &topics); + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +- kafka_topic_partition_list_to_array(return_value, topics TSRMLS_CC); ++ kafka_topic_partition_list_to_array(return_value, topics); + rd_kafka_topic_partition_list_destroy(topics); + } + /* }}} */ +@@ -273,11 +273,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, subscribe) + rd_kafka_resp_err_t err; + zeval *zv; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "h", &htopics) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "h", &htopics) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -296,7 +296,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, subscribe) + rd_kafka_topic_partition_list_destroy(topics); + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + } +@@ -315,11 +315,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, getSubscription) + object_intern *intern; + int i; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -327,7 +327,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, getSubscription) + err = rd_kafka_subscription(intern->rk, &topics); + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +@@ -352,11 +352,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, unsubscribe) + object_intern *intern; + rd_kafka_resp_err_t err; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -364,7 +364,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, unsubscribe) + err = rd_kafka_unsubscribe(intern->rk); + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + } +@@ -383,11 +383,11 @@ PHP_METHOD(RdKafka__KafkaConsumer, consume) + zend_long timeout_ms; + rd_kafka_message_t *rkmessage, rkmessage_tmp = {0}; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timeout_ms) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -399,7 +399,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, consume) + rkmessage = &rkmessage_tmp; + } + +- kafka_message_new(return_value, rkmessage TSRMLS_CC); ++ kafka_message_new(return_value, rkmessage); + + if (rkmessage != &rkmessage_tmp) { + rd_kafka_message_destroy(rkmessage); +@@ -414,44 +414,44 @@ static void consumer_commit(int async, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ + rd_kafka_topic_partition_list_t *offsets = NULL; + rd_kafka_resp_err_t err; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z!", &zarg) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z!", &zarg) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + + if (zarg) { +- if (Z_TYPE_P(zarg) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zarg), ce_kafka_message TSRMLS_CC)) { ++ if (Z_TYPE_P(zarg) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zarg), ce_kafka_message)) { + zval *zerr; + zval *ztopic; + zval *zpartition; + zval *zoffset; + 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); + 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); + return; + } + +- ztopic = rdkafka_read_property(NULL, zarg, ZEND_STRL("topic_name"), 0 TSRMLS_CC); ++ ztopic = rdkafka_read_property(NULL, 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); + return; + } + +- zpartition = rdkafka_read_property(NULL, zarg, ZEND_STRL("partition"), 0 TSRMLS_CC); ++ zpartition = rdkafka_read_property(NULL, 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); + return; + } + +- zoffset = rdkafka_read_property(NULL, zarg, ZEND_STRL("offset"), 0 TSRMLS_CC); ++ zoffset = rdkafka_read_property(NULL, 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) /* {{{ */ + + } else if (Z_TYPE_P(zarg) == IS_ARRAY) { + HashTable *ary = Z_ARRVAL_P(zarg); +- offsets = array_arg_to_kafka_topic_partition_list(1, ary TSRMLS_CC); ++ offsets = array_arg_to_kafka_topic_partition_list(1, ary); + if (!offsets) { + return; + } + } else if (Z_TYPE_P(zarg) != IS_NULL) { + php_error(E_ERROR, + "RdKafka\\KafkaConsumer::%s() expects parameter %d to be %s, %s given", +- get_active_function_name(TSRMLS_C), ++ get_active_function_name(), + 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) /* {{{ */ + } + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + } +@@ -527,7 +527,7 @@ PHP_METHOD(RdKafka__KafkaConsumer, close) + { + object_intern *intern; + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -555,17 +555,17 @@ PHP_METHOD(RdKafka__KafkaConsumer, getMetadata) + const rd_kafka_metadata_t *metadata; + kafka_topic_object *only_orkt = NULL; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "bO!l", &all_topics, &only_zrkt, ce_kafka_topic, &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "bO!l", &all_topics, &only_zrkt, ce_kafka_topic, &timeout_ms) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + + if (only_zrkt) { +- only_orkt = get_kafka_topic_object(only_zrkt TSRMLS_CC); ++ only_orkt = get_kafka_topic_object(only_zrkt); + if (!only_orkt) { + return; + } +@@ -574,11 +574,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) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +- kafka_metadata_init(return_value, metadata TSRMLS_CC); ++ kafka_metadata_init(return_value, metadata); + } + /* }}} */ + +@@ -601,17 +601,17 @@ PHP_METHOD(RdKafka__KafkaConsumer, newTopic) + rd_kafka_topic_conf_t *conf = NULL; + kafka_conf_object *conf_intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|O!", &topic, &topic_len, &zconf, ce_kafka_topic_conf) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|O!", &topic, &topic_len, &zconf, ce_kafka_topic_conf) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + + if (zconf) { +- conf_intern = get_kafka_conf_object(zconf TSRMLS_CC); ++ conf_intern = get_kafka_conf_object(zconf); + if (conf_intern) { + conf = rd_kafka_topic_conf_dup(conf_intern->u.topic_conf); + } +@@ -652,16 +652,16 @@ PHP_METHOD(RdKafka__KafkaConsumer, getCommittedOffsets) + rd_kafka_resp_err_t err; + rd_kafka_topic_partition_list_t *topics; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "hl", &htopars, &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "hl", &htopars, &timeout_ms) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + +- topics = array_arg_to_kafka_topic_partition_list(1, htopars TSRMLS_CC); ++ topics = array_arg_to_kafka_topic_partition_list(1, htopars); + if (!topics) { + return; + } +@@ -670,10 +670,10 @@ PHP_METHOD(RdKafka__KafkaConsumer, getCommittedOffsets) + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { + rd_kafka_topic_partition_list_destroy(topics); +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } +- kafka_topic_partition_list_to_array(return_value, topics TSRMLS_CC); ++ kafka_topic_partition_list_to_array(return_value, topics); + rd_kafka_topic_partition_list_destroy(topics); + } + /* }}} */ +@@ -694,16 +694,16 @@ PHP_METHOD(RdKafka__KafkaConsumer, getOffsetPositions) + rd_kafka_resp_err_t err; + rd_kafka_topic_partition_list_t *topics; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "h", &htopars) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "h", &htopars) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + +- topics = array_arg_to_kafka_topic_partition_list(1, htopars TSRMLS_CC); ++ topics = array_arg_to_kafka_topic_partition_list(1, htopars); + if (!topics) { + return; + } +@@ -712,10 +712,10 @@ PHP_METHOD(RdKafka__KafkaConsumer, getOffsetPositions) + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { + rd_kafka_topic_partition_list_destroy(topics); +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } +- kafka_topic_partition_list_to_array(return_value, topics TSRMLS_CC); ++ kafka_topic_partition_list_to_array(return_value, topics); + rd_kafka_topic_partition_list_destroy(topics); + } + /* }}} */ +@@ -734,16 +734,16 @@ PHP_METHOD(RdKafka__KafkaConsumer, offsetsForTimes) + zend_long timeout_ms; + rd_kafka_resp_err_t err; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "hl", &htopars, &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "hl", &htopars, &timeout_ms) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + +- topicPartitions = array_arg_to_kafka_topic_partition_list(1, htopars TSRMLS_CC); ++ topicPartitions = array_arg_to_kafka_topic_partition_list(1, htopars); + if (!topicPartitions) { + return; + } +@@ -752,10 +752,10 @@ PHP_METHOD(RdKafka__KafkaConsumer, offsetsForTimes) + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { + rd_kafka_topic_partition_list_destroy(topicPartitions); +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } +- kafka_topic_partition_list_to_array(return_value, topicPartitions TSRMLS_CC); ++ kafka_topic_partition_list_to_array(return_value, topicPartitions); + rd_kafka_topic_partition_list_destroy(topicPartitions); + } + /* }}} */ +@@ -781,14 +781,14 @@ PHP_METHOD(RdKafka__KafkaConsumer, queryWatermarkOffsets) + zval *lowResult, *highResult; + rd_kafka_resp_err_t err; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "slzzl", &topic, &topic_length, &partition, &lowResult, &highResult, &timeout) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "slzzl", &topic, &topic_length, &partition, &lowResult, &highResult, &timeout) == FAILURE) { + return; + } + + ZEVAL_DEREF(lowResult); + ZEVAL_DEREF(highResult); + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -796,7 +796,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) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +@@ -825,19 +825,19 @@ static const zend_function_entry fe[] = { /* {{{ */ + PHP_FE_END + }; /* }}} */ + +-void kafka_kafka_consumer_minit(TSRMLS_D) /* {{{ */ ++void kafka_kafka_consumer_minit() /* {{{ */ + { + zend_class_entry tmpce; + + INIT_NS_CLASS_ENTRY(tmpce, "RdKafka", "KafkaConsumer", fe); +- ce = zend_register_internal_class(&tmpce TSRMLS_CC); ++ ce = zend_register_internal_class(&tmpce); + 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)); + +- 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); +- zend_declare_property_null(ce, ZEND_STRL("dr_msg_cb"), ZEND_ACC_PRIVATE TSRMLS_CC); ++ zend_declare_property_null(ce, ZEND_STRL("error_cb"), ZEND_ACC_PRIVATE); ++ zend_declare_property_null(ce, ZEND_STRL("rebalance_cb"), ZEND_ACC_PRIVATE); ++ 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 +--- a/kafka_consumer.h ++++ b/kafka_consumer.h +@@ -16,4 +16,4 @@ + +----------------------------------------------------------------------+ + */ + +-void kafka_kafka_consumer_minit(TSRMLS_D); ++void kafka_kafka_consumer_minit(); +diff --git a/kafka_error_exception.c b/kafka_error_exception.c +index ee1f8b5..ea3bdba 100644 +--- a/kafka_error_exception.c ++++ b/kafka_error_exception.c +@@ -30,16 +30,16 @@ + + zend_class_entry * ce_kafka_error; + +-void create_kafka_error(zval *return_value, const rd_kafka_error_t *error TSRMLS_DC) /* {{{ */ ++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) TSRMLS_CC); +- zend_update_property_long(ce_kafka_error, return_value, ZEND_STRL("code"), rd_kafka_error_code(error) TSRMLS_CC); +- zend_update_property_string(ce_kafka_error, return_value, ZEND_STRL("error_string"), rd_kafka_error_string(error) TSRMLS_CC); +- 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)); + + Z_ADDREF_P(return_value); + } +@@ -62,16 +62,16 @@ PHP_METHOD(RdKafka__KafkaErrorException, __construct) + zend_bool isFatal = 0, isRetriable = 0, transactionRequiresAbort = 0; + zend_long code = 0; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|sbbb", &message, &message_length, &code, &error_string, &error_string_length, &isFatal, &isRetriable, &transactionRequiresAbort) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|sbbb", &message, &message_length, &code, &error_string, &error_string_length, &isFatal, &isRetriable, &transactionRequiresAbort) == FAILURE) { + return; + } + +- zend_update_property_string(ce_kafka_error, getThis(), ZEND_STRL("message"), message TSRMLS_CC); +- zend_update_property_long(ce_kafka_error, getThis(), ZEND_STRL("code"), code TSRMLS_CC); +- zend_update_property_string(ce_kafka_error, getThis(), ZEND_STRL("error_string"), error_string TSRMLS_CC); +- 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); + } + /* }}} */ + +@@ -85,11 +85,11 @@ PHP_METHOD(RdKafka__KafkaErrorException, getErrorString) + { + zval *res; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- 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); + + if (!res || Z_TYPE_P(res) != IS_STRING) { + return; +@@ -115,11 +115,11 @@ PHP_METHOD(RdKafka__KafkaErrorException, isFatal) + { + zval *res; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- 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); + + #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) + { + zval *res; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- 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); + + #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) + { + zval *res; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- 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); + + #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[] = { /* {{{ */ + PHP_FE_END + }; /* }}} */ + +-void kafka_error_minit(TSRMLS_D) /* {{{ */ ++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 TSRMLS_CC); ++ ce_kafka_error = rdkafka_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); +- zend_declare_property_bool(ce_kafka_error, ZEND_STRL("isRetriable"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); +- zend_declare_property_bool(ce_kafka_error, ZEND_STRL("transactionRequiresAbort"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); ++ 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); ++ 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); + } /* }}} */ +diff --git a/kafka_error_exception.h b/kafka_error_exception.h +index 71ad2f3..12068a6 100644 +--- a/kafka_error_exception.h ++++ b/kafka_error_exception.h +@@ -20,6 +20,6 @@ + #include "zeval.h" + #include "librdkafka/rdkafka.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); ++void kafka_error_minit(); ++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 +--- a/message.c ++++ b/message.c +@@ -32,7 +32,7 @@ + + zend_class_entry * ce_kafka_message; + +-void kafka_message_new(zval *return_value, const rd_kafka_message_t *message TSRMLS_DC) ++void kafka_message_new(zval *return_value, const rd_kafka_message_t *message) + { + object_init_ex(return_value, ce_kafka_message); + +@@ -51,21 +51,21 @@ void kafka_message_new(zval *return_value, const rd_kafka_message_t *message TSR + uint i; + #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); + + 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_long(NULL, return_value, ZEND_STRL("partition"), message->partition TSRMLS_CC); ++ zend_update_property_long(NULL, 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); + } + 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_long(NULL, return_value, ZEND_STRL("offset"), message->offset TSRMLS_CC); ++ zend_update_property_long(NULL, 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 + } + rdkafka_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); + zval_ptr_dtor(&headers_array); + } + } + #endif + } + +-void kafka_message_list_to_array(zval *return_value, rd_kafka_message_t **messages, long size TSRMLS_DC) /* {{{ */ ++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 + for (i = 0; i < size; i++) { + msg = messages[i]; + 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)); + } + } /* }}} */ +@@ -115,11 +115,11 @@ PHP_METHOD(RdKafka__Message, errstr) + zval *zpayload; + const char *errstr; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- zerr = rdkafka_read_property(NULL, getThis(), ZEND_STRL("err"), 0 TSRMLS_CC); ++ zerr = rdkafka_read_property(NULL, 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); + } + +- zpayload = rdkafka_read_property(NULL, getThis(), ZEND_STRL("payload"), 0 TSRMLS_CC); ++ zpayload = rdkafka_read_property(NULL, getThis(), ZEND_STRL("payload"), 0); + + if (zpayload && Z_TYPE_P(zpayload) == IS_STRING) { + RETURN_ZVAL(zpayload, 1, 0); +@@ -144,21 +144,21 @@ static const zend_function_entry kafka_message_fe[] = { + PHP_FE_END + }; + +-void kafka_message_minit(TSRMLS_D) { /* {{{ */ ++void kafka_message_minit() { /* {{{ */ + zend_class_entry ce; + + INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Message", kafka_message_fe); +- ce_kafka_message = zend_register_internal_class(&ce TSRMLS_CC); +- +- zend_declare_property_null(ce_kafka_message, ZEND_STRL("err"), ZEND_ACC_PUBLIC TSRMLS_CC); +- zend_declare_property_null(ce_kafka_message, ZEND_STRL("topic_name"), ZEND_ACC_PUBLIC TSRMLS_CC); +- zend_declare_property_null(ce_kafka_message, ZEND_STRL("timestamp"), ZEND_ACC_PUBLIC TSRMLS_CC); +- zend_declare_property_null(ce_kafka_message, ZEND_STRL("partition"), ZEND_ACC_PUBLIC TSRMLS_CC); +- zend_declare_property_null(ce_kafka_message, ZEND_STRL("payload"), ZEND_ACC_PUBLIC TSRMLS_CC); +- zend_declare_property_null(ce_kafka_message, ZEND_STRL("len"), ZEND_ACC_PUBLIC TSRMLS_CC); +- zend_declare_property_null(ce_kafka_message, ZEND_STRL("key"), ZEND_ACC_PUBLIC TSRMLS_CC); +- zend_declare_property_null(ce_kafka_message, ZEND_STRL("offset"), ZEND_ACC_PUBLIC TSRMLS_CC); ++ ce_kafka_message = zend_register_internal_class(&ce); ++ ++ zend_declare_property_null(ce_kafka_message, ZEND_STRL("err"), ZEND_ACC_PUBLIC); ++ zend_declare_property_null(ce_kafka_message, ZEND_STRL("topic_name"), ZEND_ACC_PUBLIC); ++ zend_declare_property_null(ce_kafka_message, ZEND_STRL("timestamp"), ZEND_ACC_PUBLIC); ++ zend_declare_property_null(ce_kafka_message, ZEND_STRL("partition"), ZEND_ACC_PUBLIC); ++ zend_declare_property_null(ce_kafka_message, ZEND_STRL("payload"), ZEND_ACC_PUBLIC); ++ zend_declare_property_null(ce_kafka_message, ZEND_STRL("len"), ZEND_ACC_PUBLIC); ++ zend_declare_property_null(ce_kafka_message, ZEND_STRL("key"), ZEND_ACC_PUBLIC); ++ zend_declare_property_null(ce_kafka_message, ZEND_STRL("offset"), ZEND_ACC_PUBLIC); + #ifdef HAVE_RD_KAFKA_MESSAGE_HEADERS +- zend_declare_property_null(ce_kafka_message, ZEND_STRL("headers"), ZEND_ACC_PUBLIC TSRMLS_CC); ++ zend_declare_property_null(ce_kafka_message, ZEND_STRL("headers"), ZEND_ACC_PUBLIC); + #endif + } /* }}} */ +diff --git a/message.h b/message.h +index 28d75fb..5db24ce 100644 +--- a/message.h ++++ b/message.h +@@ -16,8 +16,8 @@ + +----------------------------------------------------------------------+ + */ + +-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_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 +--- a/metadata.c ++++ b/metadata.c +@@ -41,22 +41,22 @@ typedef struct _object_intern { + #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 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) { /* {{{ */ ++ 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) { /* {{{ */ ++ 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 TSRMLS_DC) /* {{{ */ ++static void kafka_metadata_free(zend_object *object) /* {{{ */ + { + object_intern *intern = get_custom_object(object_intern, object); + +@@ -64,19 +64,19 @@ static void kafka_metadata_free(zend_object *object TSRMLS_DC) /* {{{ */ + rd_kafka_metadata_destroy(intern->metadata); + } + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) /* {{{ */ + { + zend_object_value retval; + object_intern *intern; + + intern = alloc_object(intern, class_type); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ 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_ + } + /* }}} */ + +-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); + + if (!ometadata->metadata) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Metadata::__construct() has not been called"); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\Metadata::__construct() has not been called"); + return NULL; + } + + return ometadata; + } + +-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ ++static HashTable *get_debug_info(zval *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) /* {{{ */ + + array_init(&ary); + +- intern = get_object(object TSRMLS_CC); ++ intern = get_object(object); + if (!intern) { + return Z_ARRVAL(ary); + } + + 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)); + + 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_long(&ary, "orig_broker_id", intern->metadata->orig_broker_id); +@@ -143,7 +143,7 @@ PHP_METHOD(RdKafka__Metadata, getOrigBrokerId) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -166,7 +166,7 @@ PHP_METHOD(RdKafka__Metadata, getOrigBrokerName) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -189,12 +189,12 @@ PHP_METHOD(RdKafka__Metadata, getBrokers) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + +- brokers_collection(return_value, getThis(), intern TSRMLS_CC); ++ brokers_collection(return_value, getThis(), intern); + } + /* }}} */ + +@@ -212,12 +212,12 @@ PHP_METHOD(RdKafka__Metadata, getTopics) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + +- topics_collection(return_value, getThis(), intern TSRMLS_CC); ++ topics_collection(return_value, getThis(), intern); + } + /* }}} */ + +@@ -229,12 +229,12 @@ static const zend_function_entry kafka_metadata_fe[] = { + PHP_FE_END + }; + +-void kafka_metadata_minit(TSRMLS_D) ++void kafka_metadata_minit() + { + zend_class_entry tmpce; + + INIT_NS_CLASS_ENTRY(tmpce, "RdKafka", "Metadata", kafka_metadata_fe); +- ce = zend_register_internal_class(&tmpce TSRMLS_CC); ++ ce = zend_register_internal_class(&tmpce); + 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)); + +- 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(); + } + +-void kafka_metadata_init(zval *return_value, const rd_kafka_metadata_t *metadata TSRMLS_DC) ++void kafka_metadata_init(zval *return_value, const rd_kafka_metadata_t *metadata) + { + object_intern *intern; + +diff --git a/metadata.h b/metadata.h +index 074816f..b68592b 100644 +--- a/metadata.h ++++ b/metadata.h +@@ -16,5 +16,5 @@ + +----------------------------------------------------------------------+ + */ + +-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_init(zval *return_value, const rd_kafka_metadata_t *metadata); +diff --git a/metadata_broker.c b/metadata_broker.c +index 89655a5..540b278 100644 +--- a/metadata_broker.c ++++ b/metadata_broker.c +@@ -40,12 +40,12 @@ typedef struct _object_intern { + #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 zend_class_entry * ce; + static zend_object_handlers handlers; + +-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); + +@@ -53,19 +53,19 @@ static void free_object(zend_object *object TSRMLS_DC) /* {{{ */ + zval_dtor(&intern->zmetadata); + } + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) /* {{{ */ + { + zend_object_value retval; + object_intern *intern; + + intern = alloc_object(intern, class_type); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ zend_object_std_init(&intern->std, class_type); + object_properties_init(&intern->std, class_type); + + +@@ -76,19 +76,19 @@ static zend_object_value create_object(zend_class_entry *class_type TSRMLS_DC) / + } + /* }}} */ + +-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); + + if (!omt->metadata_broker) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Metadata\\Broker::__construct() has not been called"); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\Metadata\\Broker::__construct() has not been called"); + return NULL; + } + + return omt; + } + +-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ ++static HashTable *get_debug_info(zval *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) /* {{{ */ + + array_init(&ary); + +- intern = get_object(object TSRMLS_CC); ++ intern = get_object(object); + if (!intern) { + return Z_ARRVAL(ary); + } +@@ -124,7 +124,7 @@ PHP_METHOD(RdKafka__Metadata__Broker, getId) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -147,7 +147,7 @@ PHP_METHOD(RdKafka__Metadata__Broker, getHost) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -170,7 +170,7 @@ PHP_METHOD(RdKafka__Metadata__Broker, getPort) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -186,12 +186,12 @@ static const zend_function_entry fe[] = { + PHP_FE_END + }; + +-void kafka_metadata_broker_minit(TSRMLS_D) ++void kafka_metadata_broker_minit() + { + zend_class_entry tmpce; + + INIT_NS_CLASS_ENTRY(tmpce, "RdKafka", "Metadata\\Broker", fe); +- ce = zend_register_internal_class(&tmpce TSRMLS_CC); ++ ce = zend_register_internal_class(&tmpce); + 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)); + } + +-void kafka_metadata_broker_ctor(zval *return_value, zval *zmetadata, const void *data TSRMLS_DC) ++void kafka_metadata_broker_ctor(zval *return_value, zval *zmetadata, const void *data) + { + rd_kafka_metadata_broker_t *metadata_broker = (rd_kafka_metadata_broker_t*)data; + object_intern *intern; +diff --git a/metadata_broker.h b/metadata_broker.h +index 0cf4e4b..c860495 100644 +--- a/metadata_broker.h ++++ b/metadata_broker.h +@@ -16,5 +16,5 @@ + +----------------------------------------------------------------------+ + */ + +-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_ctor(zval *return_value, zval *zmetadata, const void *metadata_broker); +diff --git a/metadata_collection.c b/metadata_collection.c +index 62867bc..8b19083 100644 +--- a/metadata_collection.c ++++ b/metadata_collection.c +@@ -45,12 +45,12 @@ typedef struct _object_intern { + #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 zend_class_entry *ce; + static zend_object_handlers handlers; + +-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); + +@@ -58,19 +58,19 @@ static void free_object(zend_object *object TSRMLS_DC) /* {{{ */ + zval_dtor(&intern->zmetadata); + } + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) /* {{{ */ + { + zend_object_value retval; + object_intern *intern; + + intern = alloc_object(intern, class_type); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ 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) / + } + /* }}} */ + +-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); + + if (!omti->items) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Metadata\\Collection::__construct() has not been called" TSRMLS_CC); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\Metadata\\Collection::__construct() has not been called"); + return NULL; + } + + return omti; + } + +-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ ++static HashTable *get_debug_info(zval *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) /* {{{ */ + + array_init(&ary); + +- intern = get_object(object TSRMLS_CC); ++ intern = get_object(object); + if (!intern) { + return Z_ARRVAL(ary); + } + + 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 TSRMLS_CC); ++ intern->ctor(P_ZEVAL(item), &intern->zmetadata, (char *)intern->items + i * intern->item_size); + add_next_index_zval(&ary, P_ZEVAL(item)); + } + +@@ -132,7 +132,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, count) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -155,7 +155,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, rewind) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -178,17 +178,17 @@ PHP_METHOD(RdKafka__Metadata__Collection, current) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + + if (intern->position >= intern->item_cnt) { +- zend_throw_exception(ce_kafka_exception, "Called current() on invalid iterator", 0 TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, "Called current() on invalid iterator", 0); + return; + } + +- intern->ctor(return_value, &intern->zmetadata, (char *)intern->items + intern->position * intern->item_size TSRMLS_CC); ++ intern->ctor(return_value, &intern->zmetadata, (char *)intern->items + intern->position * intern->item_size); + } + /* }}} */ + +@@ -206,13 +206,13 @@ PHP_METHOD(RdKafka__Metadata__Collection, key) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + + if (intern->position >= intern->item_cnt) { +- zend_throw_exception(ce_kafka_exception, "Called key() on invalid iterator", 0 TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, "Called key() on invalid iterator", 0); + return; + } + +@@ -234,7 +234,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, next) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -257,7 +257,7 @@ PHP_METHOD(RdKafka__Metadata__Collection, valid) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -276,14 +276,14 @@ static const zend_function_entry fe[] = { + PHP_FE_END + }; + +-void kafka_metadata_collection_minit(TSRMLS_D) ++void kafka_metadata_collection_minit() + { + zend_class_entry tmpce; + + INIT_NS_CLASS_ENTRY(tmpce, "RdKafka\\Metadata", "Collection", fe); +- ce = zend_register_internal_class(&tmpce TSRMLS_CC); ++ ce = zend_register_internal_class(&tmpce); + ce->create_object = create_object; +- zend_class_implements(ce TSRMLS_CC, 2, spl_ce_Countable, spl_ce_Iterator); ++ zend_class_implements(ce, 2, spl_ce_Countable, spl_ce_Iterator); + + 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)); + } + +-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) + { + object_intern *intern; + +diff --git a/metadata_collection.h b/metadata_collection.h +index 55539bb..13c6123 100644 +--- a/metadata_collection.h ++++ b/metadata_collection.h +@@ -16,7 +16,7 @@ + +----------------------------------------------------------------------+ + */ + +-typedef void (*kafka_metadata_collection_ctor_t)(zval *renurn_value, zval *zmetadata, const void *object TSRMLS_DC); ++typedef void (*kafka_metadata_collection_ctor_t)(zval *renurn_value, zval *zmetadata, const void *object); + +-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); +diff --git a/metadata_partition.c b/metadata_partition.c +index 17f5f3a..70b7430 100644 +--- a/metadata_partition.c ++++ b/metadata_partition.c +@@ -40,12 +40,12 @@ typedef struct _object_intern { + #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 zend_class_entry * ce; + static zend_object_handlers handlers; + +-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); + +@@ -53,19 +53,19 @@ static void free_object(zend_object *object TSRMLS_DC) /* {{{ */ + zval_dtor(&intern->zmetadata); + } + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) /* {{{ */ + { + zend_object_value retval; + object_intern *intern; + + intern = alloc_object(intern, class_type); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ 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) / + } + /* }}} */ + +-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); + + if (!omt->metadata_partition) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Metadata\\Partition::__construct() has not been called"); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\Metadata\\Partition::__construct() has not been called"); + return NULL; + } + + return omt; + } + +-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ ++static HashTable *get_debug_info(zval *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) /* {{{ */ + + array_init(&ary); + +- intern = get_object(object TSRMLS_CC); ++ intern = get_object(object); + if (!intern) { + return Z_ARRVAL(ary); + } +@@ -125,7 +125,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getId) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -148,7 +148,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getErr) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -171,7 +171,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getLeader) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -180,7 +180,7 @@ PHP_METHOD(RdKafka__Metadata__Partition, getLeader) + } + /* }}} */ + +-void int32_ctor(zval *return_value, zval *zmetadata, const void *data TSRMLS_DC) { ++void int32_ctor(zval *return_value, zval *zmetadata, const void *data) { + ZVAL_LONG(return_value, *(int32_t*)data); + } + +@@ -198,12 +198,12 @@ PHP_METHOD(RdKafka__Metadata__Partition, getReplicas) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + +- 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); + } + /* }}} */ + +@@ -221,12 +221,12 @@ PHP_METHOD(RdKafka__Metadata__Partition, getIsrs) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + +- 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); + } + /* }}} */ + +@@ -239,12 +239,12 @@ static const zend_function_entry fe[] = { + PHP_FE_END + }; + +-void kafka_metadata_partition_minit(TSRMLS_D) ++void kafka_metadata_partition_minit() + { + zend_class_entry tmpce; + + INIT_NS_CLASS_ENTRY(tmpce, "RdKafka", "Metadata\\Partition", fe); +- ce = zend_register_internal_class(&tmpce TSRMLS_CC); ++ ce = zend_register_internal_class(&tmpce); + 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)); + } + +-void kafka_metadata_partition_ctor(zval *return_value, zval *zmetadata, const void *data TSRMLS_DC) ++void kafka_metadata_partition_ctor(zval *return_value, zval *zmetadata, const void *data) + { + rd_kafka_metadata_partition_t *metadata_partition = (rd_kafka_metadata_partition_t*)data; + object_intern *intern; +diff --git a/metadata_partition.h b/metadata_partition.h +index a3da72c..9d9b4dc 100644 +--- a/metadata_partition.h ++++ b/metadata_partition.h +@@ -16,5 +16,5 @@ + +----------------------------------------------------------------------+ + */ + +-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_ctor(zval *return_value, zval *zmetadata, const void *metadata_partition); +diff --git a/metadata_topic.c b/metadata_topic.c +index 6784316..8a54757 100644 +--- a/metadata_topic.c ++++ b/metadata_topic.c +@@ -42,17 +42,17 @@ typedef struct _object_intern { + #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 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) { /* {{{ */ ++ 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 TSRMLS_DC) /* {{{ */ ++static void free_object(zend_object *object) /* {{{ */ + { + object_intern *intern = get_custom_object(object_intern, object); + +@@ -60,19 +60,19 @@ static void free_object(zend_object *object TSRMLS_DC) /* {{{ */ + zval_dtor(&intern->zmetadata); + } + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) /* {{{ */ + { + zend_object_value retval; + object_intern *intern; + + intern = alloc_object(intern, class_type); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ 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) / + } + /* }}} */ + +-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); + + if (!omt->metadata_topic) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Metadata\\Topic::__construct() has not been called"); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\Metadata\\Topic::__construct() has not been called"); + return NULL; + } + + return omt; + } + +-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ ++static HashTable *get_debug_info(zval *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) /* {{{ */ + + array_init(&ary); + +- intern = get_object(object TSRMLS_CC); ++ intern = get_object(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); +- 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_long(&ary, "err", intern->metadata_topic->err); +@@ -135,7 +135,7 @@ PHP_METHOD(RdKafka__Metadata__Topic, getTopic) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -158,7 +158,7 @@ PHP_METHOD(RdKafka__Metadata__Topic, getErr) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -182,12 +182,12 @@ PHP_METHOD(RdKafka__Metadata__Topic, getPartitions) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } + +- partitions_collection(return_value, getThis(), intern TSRMLS_CC); ++ partitions_collection(return_value, getThis(), intern); + } + /* }}} */ + +@@ -198,12 +198,12 @@ static const zend_function_entry fe[] = { + PHP_FE_END + }; + +-void kafka_metadata_topic_minit(TSRMLS_D) ++void kafka_metadata_topic_minit() + { + zend_class_entry tmpce; + + INIT_NS_CLASS_ENTRY(tmpce, "RdKafka\\Metadata", "Topic", fe); +- ce = zend_register_internal_class(&tmpce TSRMLS_CC); ++ ce = zend_register_internal_class(&tmpce); + 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)); + } + +-void kafka_metadata_topic_ctor(zval *return_value, zval *zmetadata, const void *data TSRMLS_DC) ++void kafka_metadata_topic_ctor(zval *return_value, zval *zmetadata, const void *data) + { + rd_kafka_metadata_topic_t *metadata_topic = (rd_kafka_metadata_topic_t*)data; + object_intern *intern; +diff --git a/metadata_topic.h b/metadata_topic.h +index 128fec0..6c5522a 100644 +--- a/metadata_topic.h ++++ b/metadata_topic.h +@@ -16,5 +16,5 @@ + +----------------------------------------------------------------------+ + */ + +-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_ctor(zval *return_value, zval *zmetadata, const void *metadata_topic); +diff --git a/php_rdkafka_priv.h b/php_rdkafka_priv.h +index 434e0e9..d00a8eb 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) { + + #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 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; + } + +-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 + fci->params = params; + fci->param_count = param_count; + +- zend_call_function(fci, fci_cache TSRMLS_CC); ++ zend_call_function(fci, fci_cache); + + if (local_retval) { + zval_ptr_dtor(retval); + } + } + +-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) + { + 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; + + #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) \ +- ((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; + } + +-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 */ + } + +-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; + +- 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); + } + +-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 + +-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 +--- a/queue.c ++++ b/queue.c +@@ -35,30 +35,30 @@ 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); + + 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)); + if (kafka_intern) { + zend_hash_index_del(&kafka_intern->queues, (zend_ulong)intern); + } + } + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) /* {{{ */ + { + zend_object_value retval; + kafka_queue_object *intern; + + intern = alloc_object(intern, class_type); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ 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) + } + /* }}} */ + +-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); + + if (!orkqu->rkqu) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Queue::__construct() has not been called" TSRMLS_CC); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\Queue::__construct() has not been called"); + return NULL; + } + +@@ -94,11 +94,11 @@ PHP_METHOD(RdKafka__Queue, consume) + rd_kafka_message_t *message; + rd_kafka_resp_err_t err; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timeout_ms) == FAILURE) { + return; + } + +- intern = get_kafka_queue_object(getThis() TSRMLS_CC); ++ intern = get_kafka_queue_object(getThis()); + if (!intern) { + return; + } +@@ -110,11 +110,11 @@ PHP_METHOD(RdKafka__Queue, consume) + if (err == RD_KAFKA_RESP_ERR__TIMED_OUT) { + return; + } +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +- kafka_message_new(return_value, message TSRMLS_CC); ++ kafka_message_new(return_value, message); + + rd_kafka_message_destroy(message); + } +@@ -129,7 +129,7 @@ static const zend_function_entry kafka_queue_fe[] = { + PHP_FE_END + }; + +-void kafka_queue_minit(TSRMLS_D) { /* {{{ */ ++void kafka_queue_minit() { /* {{{ */ + + zend_class_entry ce; + +@@ -138,6 +138,6 @@ void kafka_queue_minit(TSRMLS_D) { /* {{{ */ + set_object_handler_offset(&handlers, 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); ++ ce_kafka_queue = zend_register_internal_class(&ce); + ce_kafka_queue->create_object = kafka_queue_new; + } /* }}} */ +diff --git a/queue.h b/queue.h +index 8d8ab66..532621c 100644 +--- a/queue.h ++++ b/queue.h +@@ -27,7 +27,7 @@ typedef struct _kafka_queue_object { + #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(); ++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 +--- a/rdkafka.c ++++ b/rdkafka.c +@@ -70,17 +70,17 @@ static void stop_consuming_toppar_pp(toppar ** tp) { + rd_kafka_consume_stop((*tp)->rkt, (*tp)->partition); + } + +-static void stop_consuming(kafka_object * intern TSRMLS_DC) { +- zend_hash_apply(&intern->consuming, (apply_func_t)stop_consuming_toppar_pp TSRMLS_CC); ++static void stop_consuming(kafka_object * intern) { ++ zend_hash_apply(&intern->consuming, (apply_func_t)stop_consuming_toppar_pp); + } + +-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); + + if (intern->rk) { + if (intern->type == RD_KAFKA_CONSUMER) { +- stop_consuming(intern TSRMLS_CC); ++ stop_consuming(intern); + zend_hash_destroy(&intern->consuming); + zend_hash_destroy(&intern->queues); + } +@@ -90,9 +90,9 @@ static void kafka_free(zend_object *object TSRMLS_DC) /* {{{ */ + intern->rk = NULL; + } + +- kafka_conf_callbacks_dtor(&intern->cbs TSRMLS_CC); ++ kafka_conf_callbacks_dtor(&intern->cbs); + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) { + zval_ptr_dtor(&intern->zrk); + } + +-static void kafka_init(zval *this_ptr, rd_kafka_type_t type, zval *zconf TSRMLS_DC) /* {{{ */ ++static void kafka_init(zval *this_ptr, rd_kafka_type_t type, zval *zconf) /* {{{ */ + { + 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_ + intern->type = type; + + if (zconf) { +- conf_intern = get_kafka_conf_object(zconf TSRMLS_CC); ++ conf_intern = get_kafka_conf_object(zconf); + if (conf_intern) { + conf = rd_kafka_conf_dup(conf_intern->u.conf); +- kafka_conf_callbacks_copy(&intern->cbs, &conf_intern->cbs TSRMLS_CC); ++ kafka_conf_callbacks_copy(&intern->cbs, &conf_intern->cbs); + 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_ + rk = rd_kafka_new(type, conf, errstr, sizeof(errstr)); + + if (rk == NULL) { +- zend_throw_exception(ce_kafka_exception, errstr, 0 TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, errstr, 0); + return; + } + +@@ -159,13 +159,13 @@ 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) /* {{{ */ + { + zend_object_value retval; + kafka_object *intern; + + intern = alloc_object(intern, class_type); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ 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) /* {{ + } + /* }}} */ + +-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); + + if (!ork->rk) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Kafka::__construct() has not been called" TSRMLS_CC); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\Kafka::__construct() has not been called"); + return NULL; + } + +@@ -241,7 +241,7 @@ int is_consuming_toppar(kafka_object * intern, rd_kafka_topic_t * rkt, int32_t p + /* {{{ private constructor */ + PHP_METHOD(RdKafka, __construct) + { +- zend_throw_exception(NULL, "Private constructor", 0 TSRMLS_CC); ++ zend_throw_exception(NULL, "Private constructor", 0); + return; + } + /* }}} */ +@@ -257,16 +257,16 @@ PHP_METHOD(RdKafka__Consumer, __construct) + zval *zconf = NULL; + zend_error_handling error_handling; + +- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC); ++ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling); + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|O!", &zconf, ce_kafka_conf) == FAILURE) { +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &zconf, ce_kafka_conf) == FAILURE) { ++ zend_restore_error_handling(&error_handling); + return; + } + +- kafka_init(getThis(), RD_KAFKA_CONSUMER, zconf TSRMLS_CC); ++ kafka_init(getThis(), RD_KAFKA_CONSUMER, zconf); + +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ zend_restore_error_handling(&error_handling); + } + /* }}} */ + +@@ -282,11 +282,11 @@ PHP_METHOD(RdKafka__Consumer, newQueue) + kafka_object *intern; + kafka_queue_object *queue_intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -341,11 +341,11 @@ PHP_METHOD(RdKafka__Kafka, addBrokers) + arglen_t broker_list_len; + kafka_object *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &broker_list, &broker_list_len) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &broker_list, &broker_list_len) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -372,17 +372,17 @@ PHP_METHOD(RdKafka__Kafka, getMetadata) + const rd_kafka_metadata_t *metadata; + kafka_topic_object *only_orkt = NULL; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "bO!l", &all_topics, &only_zrkt, ce_kafka_topic, &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "bO!l", &all_topics, &only_zrkt, ce_kafka_topic, &timeout_ms) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } + + if (only_zrkt) { +- only_orkt = get_kafka_topic_object(only_zrkt TSRMLS_CC); ++ only_orkt = get_kafka_topic_object(only_zrkt); + if (!only_orkt) { + return; + } +@@ -391,11 +391,11 @@ 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) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +- kafka_metadata_init(return_value, metadata TSRMLS_CC); ++ kafka_metadata_init(return_value, metadata); + } + /* }}} */ + +@@ -411,11 +411,11 @@ PHP_METHOD(RdKafka__Kafka, setLogLevel) + kafka_object *intern; + zend_long level; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &level) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &level) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -444,17 +444,17 @@ PHP_METHOD(RdKafka__Kafka, newTopic) + rd_kafka_topic_conf_t *conf = NULL; + kafka_conf_object *conf_intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|O!", &topic, &topic_len, &zconf, ce_kafka_topic_conf) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|O!", &topic, &topic_len, &zconf, ce_kafka_topic_conf) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } + + if (zconf) { +- conf_intern = get_kafka_conf_object(zconf TSRMLS_CC); ++ conf_intern = get_kafka_conf_object(zconf); + if (conf_intern) { + conf = rd_kafka_topic_conf_dup(conf_intern->u.topic_conf); + } +@@ -508,11 +508,11 @@ PHP_METHOD(RdKafka__Kafka, getOutQLen) + { + kafka_object *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -533,11 +533,11 @@ PHP_METHOD(RdKafka__Kafka, poll) + kafka_object *intern; + zend_long timeout; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &timeout) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timeout) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -558,11 +558,11 @@ PHP_METHOD(RdKafka__Kafka, flush) + kafka_object *intern; + zend_long timeout; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &timeout) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timeout) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -584,11 +584,11 @@ PHP_METHOD(RdKafka__Kafka, purge) + kafka_object *intern; + zend_long purge_flags; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &purge_flags) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &purge_flags) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -619,14 +619,14 @@ PHP_METHOD(RdKafka__Kafka, queryWatermarkOffsets) + zval *lowResult, *highResult; + rd_kafka_resp_err_t err; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "slzzl", &topic, &topic_length, &partition, &lowResult, &highResult, &timeout) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "slzzl", &topic, &topic_length, &partition, &lowResult, &highResult, &timeout) == FAILURE) { + return; + } + + ZEVAL_DEREF(lowResult); + ZEVAL_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) + err = rd_kafka_query_watermark_offsets(intern->rk, topic, partition, &low, &high, timeout); + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +@@ -657,16 +657,16 @@ PHP_METHOD(RdKafka__Kafka, offsetsForTimes) + zend_long timeout_ms; + rd_kafka_resp_err_t err; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "hl", &htopars, &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "hl", &htopars, &timeout_ms) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } + +- topicPartitions = array_arg_to_kafka_topic_partition_list(1, htopars TSRMLS_CC); ++ topicPartitions = array_arg_to_kafka_topic_partition_list(1, htopars); + if (!topicPartitions) { + return; + } +@@ -675,10 +675,10 @@ PHP_METHOD(RdKafka__Kafka, offsetsForTimes) + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { + rd_kafka_topic_partition_list_destroy(topicPartitions); +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } +- kafka_topic_partition_list_to_array(return_value, topicPartitions TSRMLS_CC); ++ kafka_topic_partition_list_to_array(return_value, topicPartitions); + rd_kafka_topic_partition_list_destroy(topicPartitions); + } + /* }}} */ +@@ -697,11 +697,11 @@ PHP_METHOD(RdKafka__Kafka, setLogger) + zend_long id; + void (*logger) (const rd_kafka_t * rk, int level, const char *fac, const char *buf); + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -719,7 +719,7 @@ PHP_METHOD(RdKafka__Kafka, setLogger) + logger = kafka_log_syslog_print; + break; + default: +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Invalid logger" TSRMLS_CC); ++ zend_throw_exception_ex(NULL, 0, "Invalid logger"); + return; + } + +@@ -757,16 +757,16 @@ PHP_METHOD(RdKafka__Producer, __construct) + zval *zconf = NULL; + zend_error_handling error_handling; + +- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC); ++ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling); + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|O!", &zconf, ce_kafka_conf) == FAILURE) { +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &zconf, ce_kafka_conf) == FAILURE) { ++ zend_restore_error_handling(&error_handling); + return; + } + +- kafka_init(getThis(), RD_KAFKA_PRODUCER, zconf TSRMLS_CC); ++ kafka_init(getThis(), RD_KAFKA_PRODUCER, zconf); + +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ zend_restore_error_handling(&error_handling); + } + /* }}} */ + +@@ -784,11 +784,11 @@ PHP_METHOD(RdKafka__Producer, initTransactions) + zend_long timeout_ms; + const rd_kafka_error_t *error; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timeout_ms) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -799,8 +799,8 @@ PHP_METHOD(RdKafka__Producer, initTransactions) + return; + } + +- create_kafka_error(return_value, error TSRMLS_CC); +- zend_throw_exception_object(return_value TSRMLS_CC); ++ create_kafka_error(return_value, error); ++ zend_throw_exception_object(return_value); + } + /* }}} */ + +@@ -815,7 +815,7 @@ PHP_METHOD(RdKafka__Producer, beginTransaction) + kafka_object *intern; + const rd_kafka_error_t *error; + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -826,8 +826,8 @@ PHP_METHOD(RdKafka__Producer, beginTransaction) + return; + } + +- create_kafka_error(return_value, error TSRMLS_CC); +- zend_throw_exception_object(return_value TSRMLS_CC); ++ create_kafka_error(return_value, error); ++ zend_throw_exception_object(return_value); + } + /* }}} */ + +@@ -844,11 +844,11 @@ PHP_METHOD(RdKafka__Producer, commitTransaction) + zend_long timeout_ms; + const rd_kafka_error_t *error; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timeout_ms) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -859,8 +859,8 @@ PHP_METHOD(RdKafka__Producer, commitTransaction) + return; + } + +- create_kafka_error(return_value, error TSRMLS_CC); +- zend_throw_exception_object(return_value TSRMLS_CC); ++ create_kafka_error(return_value, error); ++ zend_throw_exception_object(return_value); + } + /* }}} */ + +@@ -877,11 +877,11 @@ PHP_METHOD(RdKafka__Producer, abortTransaction) + zend_long timeout_ms; + const rd_kafka_error_t *error; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timeout_ms) == FAILURE) { + return; + } + +- intern = get_kafka_object(getThis() TSRMLS_CC); ++ intern = get_kafka_object(getThis()); + if (!intern) { + return; + } +@@ -892,8 +892,8 @@ PHP_METHOD(RdKafka__Producer, abortTransaction) + return; + } + +- create_kafka_error(return_value, error TSRMLS_CC); +- zend_throw_exception_object(return_value TSRMLS_CC); ++ create_kafka_error(return_value, error); ++ zend_throw_exception_object(return_value); + } + /* }}} */ + +@@ -939,7 +939,7 @@ void register_err_constants(INIT_FUNC_ARGS) /* {{{ */ + 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)); + + INIT_CLASS_ENTRY(ce, "RdKafka", kafka_fe); +- ce_kafka = zend_register_internal_class(&ce TSRMLS_CC); ++ ce_kafka = zend_register_internal_class(&ce); + ce_kafka->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; + ce_kafka->create_object = kafka_new; + +- zend_declare_property_null(ce_kafka, ZEND_STRL("error_cb"), ZEND_ACC_PRIVATE TSRMLS_CC); +- zend_declare_property_null(ce_kafka, ZEND_STRL("dr_cb"), ZEND_ACC_PRIVATE TSRMLS_CC); ++ zend_declare_property_null(ce_kafka, ZEND_STRL("error_cb"), ZEND_ACC_PRIVATE); ++ 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 TSRMLS_CC); ++ ce_kafka_consumer = rdkafka_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); + + 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()); + +- kafka_conf_minit(TSRMLS_C); ++ kafka_conf_minit(); + #ifdef HAS_RD_KAFKA_TRANSACTIONS +- kafka_error_minit(TSRMLS_C); ++ kafka_error_minit(); + #endif +- kafka_kafka_consumer_minit(TSRMLS_C); +- kafka_message_minit(TSRMLS_C); +- kafka_metadata_minit(TSRMLS_C); +- 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(); + + return SUCCESS; + } +diff --git a/tests/conf_setDefaultTopicConf8.phpt b/tests/conf_setDefaultTopicConf8.phpt +new file mode 100644 +index 0000000..e5fdfe1 +--- /dev/null ++++ b/tests/conf_setDefaultTopicConf8.phpt +@@ -0,0 +1,38 @@ ++--TEST-- ++RdKafka\Conf::setDefaultTopicConf() ++--SKIPIF-- ++<?php ++if (!method_exists('RdKafka\Conf', 'setDefaultTopicConf') || 8 > PHP_MAJOR_VERSION) { ++ echo "skip"; ++} ++?> ++--FILE-- ++<?php ++ ++$conf = new RdKafka\Conf(); ++ ++echo "Setting valid topic conf\n"; ++$conf->setDefaultTopicConf(new RdKafka\TopicConf()); ++ ++echo "Setting invalid topic conf\n"; ++try { ++ $conf->setDefaultTopicConf($conf); ++} catch(TypeError $error) { ++ echo $error->getMessage() . PHP_EOL; ++ echo $error->getFile() . PHP_EOL; ++ echo $error->getLine() . PHP_EOL; ++ echo $error->getCode(); ++} ++ ++--EXPECTF-- ++Setting valid topic conf ++ ++Deprecated: Method RdKafka\Conf::setDefaultTopicConf() is deprecated in %s%econf_setDefaultTopicConf8.php on line 6 ++Setting invalid topic conf ++ ++Deprecated: Method RdKafka\Conf::setDefaultTopicConf() is deprecated in %s%econf_setDefaultTopicConf8.php on line 10 ++RdKafka\Conf::setDefaultTopicConf(): Argument #1 ($topic_conf) must be of type RdKafka\TopicConf, RdKafka\Conf given ++%s%econf_setDefaultTopicConf8.php ++10 ++0 ++ +diff --git a/topic.c b/topic.c +index 63ae06a..389ae4a 100644 +--- a/topic.c ++++ b/topic.c +@@ -43,30 +43,30 @@ 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); + + 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 (kafka_intern) { + zend_hash_index_del(&kafka_intern->topics, (zend_ulong)intern); + } + } + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) /* {{{ */ + { + zend_object_value retval; + kafka_topic_object *intern; + + intern = alloc_object(intern, class_type); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ 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) + + MAKE_STD_ZEVAL(args[0]); + +- kafka_message_new(P_ZEVAL(args[0]), msg TSRMLS_CC); ++ kafka_message_new(P_ZEVAL(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); + + zval_ptr_dtor(&args[0]); + } + +-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); + + if (!orkt->rkt) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\Topic::__construct() has not been called" TSRMLS_CC); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\Topic::__construct() has not been called"); + return NULL; + } + +@@ -128,16 +128,16 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeCallback) + long result; + kafka_topic_object *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llf", &partition, &timeout_ms, &cb.fci, &cb.fcc) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "llf", &partition, &timeout_ms, &cb.fci, &cb.fcc) == FAILURE) { + return; + } + + if (partition < 0 || partition > 0x7FFFFFFF) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Out of range value '%ld' for $partition", partition TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Out of range value '%ld' for $partition", partition); + return; + } + +- intern = get_kafka_topic_object(getThis() TSRMLS_CC); ++ intern = get_kafka_topic_object(getThis()); + if (!intern) { + return; + } +@@ -172,26 +172,26 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeQueueStart) + rd_kafka_resp_err_t err; + kafka_object *kafka_intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llO", &partition, &offset, &zrkqu, ce_kafka_queue) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "llO", &partition, &offset, &zrkqu, ce_kafka_queue) == FAILURE) { + return; + } + + if (partition != RD_KAFKA_PARTITION_UA && (partition < 0 || partition > 0x7FFFFFFF)) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Out of range value '%ld' for $partition", partition TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Out of range value '%ld' for $partition", partition); + return; + } + +- intern = get_kafka_topic_object(getThis() TSRMLS_CC); ++ intern = get_kafka_topic_object(getThis()); + if (!intern) { + return; + } + +- queue_intern = get_kafka_queue_object(zrkqu TSRMLS_CC); ++ queue_intern = get_kafka_queue_object(zrkqu); + if (!queue_intern) { + return; + } + +- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk) TSRMLS_CC); ++ kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk)); + if (!kafka_intern) { + return; + } +@@ -199,7 +199,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeQueueStart) + if (is_consuming_toppar(kafka_intern, intern->rkt, partition)) { + zend_throw_exception_ex( + ce_kafka_exception, +- 0 TSRMLS_CC, ++ 0, + "%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) + + if (ret == -1) { + err = rd_kafka_last_error(); +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +@@ -236,21 +236,21 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStart) + rd_kafka_resp_err_t err; + kafka_object *kafka_intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &partition, &offset) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &partition, &offset) == FAILURE) { + return; + } + + if (partition != RD_KAFKA_PARTITION_UA && (partition < 0 || partition > 0x7FFFFFFF)) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Out of range value '%ld' for $partition", partition TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Out of range value '%ld' for $partition", partition); + return; + } + +- intern = get_kafka_topic_object(getThis() TSRMLS_CC); ++ intern = get_kafka_topic_object(getThis()); + if (!intern) { + return; + } + +- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk) TSRMLS_CC); ++ kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk)); + if (!kafka_intern) { + return; + } +@@ -258,7 +258,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStart) + if (is_consuming_toppar(kafka_intern, intern->rkt, partition)) { + zend_throw_exception_ex( + ce_kafka_exception, +- 0 TSRMLS_CC, ++ 0, + "%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) + + if (ret == -1) { + err = rd_kafka_last_error(); +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +@@ -293,21 +293,21 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStop) + rd_kafka_resp_err_t err; + kafka_object *kafka_intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &partition) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &partition) == FAILURE) { + return; + } + + if (partition != RD_KAFKA_PARTITION_UA && (partition < 0 || partition > 0x7FFFFFFF)) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Out of range value '%ld' for $partition", partition TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Out of range value '%ld' for $partition", partition); + return; + } + +- intern = get_kafka_topic_object(getThis() TSRMLS_CC); ++ intern = get_kafka_topic_object(getThis()); + if (!intern) { + return; + } + +- kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk) TSRMLS_CC); ++ kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk)); + if (!kafka_intern) { + return; + } +@@ -316,7 +316,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeStop) + + if (ret == -1) { + err = rd_kafka_last_error(); +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +@@ -340,16 +340,16 @@ PHP_METHOD(RdKafka__ConsumerTopic, consume) + rd_kafka_message_t *message; + rd_kafka_resp_err_t err; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &partition, &timeout_ms) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &partition, &timeout_ms) == FAILURE) { + return; + } + + if (partition != RD_KAFKA_PARTITION_UA && (partition < 0 || partition > 0x7FFFFFFF)) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Out of range value '%ld' for $partition", partition TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Out of range value '%ld' for $partition", partition); + return; + } + +- intern = get_kafka_topic_object(getThis() TSRMLS_CC); ++ intern = get_kafka_topic_object(getThis()); + if (!intern) { + return; + } +@@ -361,11 +361,11 @@ PHP_METHOD(RdKafka__ConsumerTopic, consume) + if (err == RD_KAFKA_RESP_ERR__TIMED_OUT) { + return; + } +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + +- kafka_message_new(return_value, message TSRMLS_CC); ++ kafka_message_new(return_value, message); + + rd_kafka_message_destroy(message); + } +@@ -388,21 +388,21 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeBatch) + rd_kafka_message_t **rkmessages; + rd_kafka_resp_err_t err; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &partition, &timeout_ms, &batch_size) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &partition, &timeout_ms, &batch_size) == FAILURE) { + return; + } + + if (0 >= batch_size) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Out of range value '%ld' for batch_size", batch_size TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Out of range value '%ld' for batch_size", batch_size); + return; + } + + if (partition != RD_KAFKA_PARTITION_UA && (partition < 0 || partition > 0x7FFFFFFF)) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Out of range value '%ld' for $partition", partition TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Out of range value '%ld' for $partition", partition); + return; + } + +- intern = get_kafka_topic_object(getThis() TSRMLS_CC); ++ intern = get_kafka_topic_object(getThis()); + if (!intern) { + return; + } +@@ -414,12 +414,12 @@ PHP_METHOD(RdKafka__ConsumerTopic, consumeBatch) + if (result == -1) { + free(rkmessages); + err = rd_kafka_last_error(); +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + + if (result >= 0) { +- kafka_message_list_to_array(return_value, rkmessages, result TSRMLS_CC); ++ kafka_message_list_to_array(return_value, rkmessages, result); + for (i = 0; i < result; ++i) { + rd_kafka_message_destroy(rkmessages[i]); + } +@@ -443,16 +443,16 @@ PHP_METHOD(RdKafka__ConsumerTopic, offsetStore) + zend_long offset; + rd_kafka_resp_err_t err; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &partition, &offset) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &partition, &offset) == FAILURE) { + return; + } + + if (partition < 0 || partition > 0x7FFFFFFF) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Out of range value '%ld' for $partition", partition TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Out of range value '%ld' for $partition", partition); + return; + } + +- intern = get_kafka_topic_object(getThis() TSRMLS_CC); ++ intern = get_kafka_topic_object(getThis()); + if (!intern) { + return; + } +@@ -460,7 +460,7 @@ PHP_METHOD(RdKafka__ConsumerTopic, offsetStore) + err = rd_kafka_offset_store(intern->rkt, partition, offset); + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + } +@@ -509,27 +509,27 @@ PHP_METHOD(RdKafka__ProducerTopic, produce) + rd_kafka_resp_err_t err; + kafka_topic_object *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|s!s!", &partition, &msgflags, &payload, &payload_len, &key, &key_len) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|s!s!", &partition, &msgflags, &payload, &payload_len, &key, &key_len) == FAILURE) { + return; + } + + if (partition != RD_KAFKA_PARTITION_UA && (partition < 0 || partition > 0x7FFFFFFF)) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Out of range value '%ld' for $partition", partition TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Out of range value '%ld' for $partition", partition); + return; + } + + if (msgflags != 0 && msgflags != RD_KAFKA_MSG_F_BLOCK) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Invalid value '%ld' for $msgflags", msgflags TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Invalid value '%ld' for $msgflags", msgflags); + return; + } + +- intern = get_kafka_topic_object(getThis() TSRMLS_CC); ++ intern = get_kafka_topic_object(getThis()); + + ret = rd_kafka_produce(intern->rkt, partition, msgflags | RD_KAFKA_MSG_F_COPY, payload, payload_len, key, key_len, NULL); + + if (ret == -1) { + err = rd_kafka_last_error(); +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + } +@@ -567,17 +567,17 @@ PHP_METHOD(RdKafka__ProducerTopic, producev) + zend_long timestamp_ms = 0; + zend_bool timestamp_ms_is_null = 0; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|s!s!h!l!", &partition, &msgflags, &payload, &payload_len, &key, &key_len, &headersParam, ×tamp_ms, ×tamp_ms_is_null) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|s!s!h!l!", &partition, &msgflags, &payload, &payload_len, &key, &key_len, &headersParam, ×tamp_ms, ×tamp_ms_is_null) == FAILURE) { + return; + } + + if (partition != RD_KAFKA_PARTITION_UA && (partition < 0 || partition > 0x7FFFFFFF)) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Out of range value '%ld' for $partition", partition TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Out of range value '%ld' for $partition", partition); + return; + } + + if (msgflags != 0 && msgflags != RD_KAFKA_MSG_F_BLOCK) { +- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Invalid value '%ld' for $msgflags", msgflags TSRMLS_CC); ++ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Invalid value '%ld' for $msgflags", msgflags); + return; + } + +@@ -585,7 +585,7 @@ PHP_METHOD(RdKafka__ProducerTopic, producev) + timestamp_ms = 0; + } + +- intern = get_kafka_topic_object(getThis() TSRMLS_CC); ++ intern = get_kafka_topic_object(getThis()); + + 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) + 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)); + if (!kafka_intern) { + return; + } +@@ -625,7 +625,7 @@ PHP_METHOD(RdKafka__ProducerTopic, producev) + + if (err != RD_KAFKA_RESP_ERR_NO_ERROR) { + rd_kafka_headers_destroy(headers); +- zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err TSRMLS_CC); ++ zend_throw_exception(ce_kafka_exception, rd_kafka_err2str(err), err); + return; + } + } +@@ -654,7 +654,7 @@ PHP_METHOD(RdKafka__Topic, getName) + return; + } + +- intern = get_kafka_topic_object(getThis() TSRMLS_CC); ++ intern = get_kafka_topic_object(getThis()); + if (!intern) { + return; + } +@@ -668,7 +668,7 @@ static const zend_function_entry kafka_topic_fe[] = { + PHP_FE_END + }; + +-void kafka_topic_minit(TSRMLS_D) { /* {{{ */ ++void kafka_topic_minit() { /* {{{ */ + + 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)); + + INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Topic", kafka_topic_fe); +- ce_kafka_topic = zend_register_internal_class(&ce TSRMLS_CC); ++ ce_kafka_topic = zend_register_internal_class(&ce); + ce_kafka_topic->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; + 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 TSRMLS_CC); ++ ce_kafka_consumer_topic = rdkafka_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); + + 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); + } /* }}} */ +diff --git a/topic.h b/topic.h +index 07f49ae..78beec3 100644 +--- a/topic.h ++++ b/topic.h +@@ -29,8 +29,8 @@ typedef struct _kafka_topic_object { + #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(); ++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 +--- a/topic_partition.c ++++ b/topic_partition.c +@@ -33,13 +33,13 @@ + + 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); + + zend_class_entry * ce_kafka_topic_partition; + + static zend_object_handlers handlers; + +-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); + +@@ -47,19 +47,19 @@ static void free_object(zend_object *object TSRMLS_DC) /* {{{ */ + efree(intern->topic); + } + +- zend_object_std_dtor(&intern->std TSRMLS_CC); ++ 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) /* {{{ */ + { + zend_object_value retval; + object_intern *intern; + + intern = ecalloc(1, sizeof(*intern)); +- zend_object_std_init(&intern->std, class_type TSRMLS_CC); ++ 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) / + } + /* }}} */ + +-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); + + if (!intern->topic) { +- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "RdKafka\\TopicPartition::__construct() has not been called"); ++ zend_throw_exception_ex(NULL, 0, "RdKafka\\TopicPartition::__construct() has not been called"); + return NULL; + } + + return intern; + } /* }}} */ + +-kafka_topic_partition_intern * get_topic_partition_object(zval *z TSRMLS_DC) /* {{{ */ ++kafka_topic_partition_intern * get_topic_partition_object(zval *z) /* {{{ */ + { +- return get_object(z TSRMLS_CC); ++ return get_object(z); + } /* }}} */ + +-static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ ++static HashTable *get_debug_info(zval *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) /* {{{ */ + + array_init(&ary); + +- intern = get_object(object TSRMLS_CC); ++ intern = get_object(object); + if (!intern) { + return Z_ARRVAL(ary); + } +@@ -113,7 +113,7 @@ static HashTable *get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ + } + /* }}} */ + +-void kafka_topic_partition_init(zval *zobj, char * topic, int32_t partition, int64_t offset TSRMLS_DC) /* {{{ */ ++void kafka_topic_partition_init(zval *zobj, char * topic, int32_t partition, int64_t offset) /* {{{ */ + { + object_intern *intern; + +@@ -131,7 +131,7 @@ void kafka_topic_partition_init(zval *zobj, char * topic, int32_t partition, int + intern->offset = offset; + } /* }}} */ + +-void kafka_topic_partition_list_to_array(zval *return_value, rd_kafka_topic_partition_list_t *list TSRMLS_DC) /* {{{ */ ++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 + 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 TSRMLS_CC); ++ kafka_topic_partition_init(P_ZEVAL(ztopar), topar->topic, topar->partition, topar->offset); + add_next_index_zval(return_value, P_ZEVAL(ztopar)); + } + } /* }}} */ + +-rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int argnum, HashTable *ary TSRMLS_DC) { /* {{{ */ ++rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int argnum, HashTable *ary) { /* {{{ */ + + 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 + 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)) { + const char *space; +- const char *class_name = get_active_class_name(&space TSRMLS_CC); ++ const char *class_name = get_active_class_name(&space); + rd_kafka_topic_partition_list_destroy(list); + php_error(E_ERROR, + "Argument %d passed to %s%s%s() must be an array of RdKafka\\TopicPartition, at least one element is a(n) %s", + argnum, + class_name, space, +- get_active_function_name(TSRMLS_C), ++ get_active_function_name(), + zend_zval_type_name(ZEVAL(zv))); + return NULL; + } + +- topar_intern = get_topic_partition_object(ZEVAL(zv) TSRMLS_CC); ++ topar_intern = get_topic_partition_object(ZEVAL(zv)); + if (!topar_intern) { + rd_kafka_topic_partition_list_destroy(list); + return NULL; +@@ -206,16 +206,16 @@ PHP_METHOD(RdKafka__TopicPartition, __construct) + zend_long offset = 0; + zend_error_handling error_handling; + +- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC); ++ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling); + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|l", &topic, &topic_len, &partition, &offset) == FAILURE) { +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|l", &topic, &topic_len, &partition, &offset) == FAILURE) { ++ zend_restore_error_handling(&error_handling); + return; + } + +- kafka_topic_partition_init(getThis(), topic, partition, offset TSRMLS_CC); ++ kafka_topic_partition_init(getThis(), topic, partition, offset); + +- zend_restore_error_handling(&error_handling TSRMLS_CC); ++ zend_restore_error_handling(&error_handling); + } + /* }}} */ + +@@ -233,7 +233,7 @@ PHP_METHOD(RdKafka__TopicPartition, getTopic) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -259,11 +259,11 @@ PHP_METHOD(RdKafka__TopicPartition, setTopic) + arglen_t topic_len; + object_intern *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &topic, &topic_len) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &topic, &topic_len) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -292,7 +292,7 @@ PHP_METHOD(RdKafka__TopicPartition, getPartition) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -313,11 +313,11 @@ PHP_METHOD(RdKafka__TopicPartition, setPartition) + zend_long partition; + object_intern *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &partition) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &partition) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -342,7 +342,7 @@ PHP_METHOD(RdKafka__TopicPartition, getOffset) + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -363,11 +363,11 @@ PHP_METHOD(RdKafka__TopicPartition, setOffset) + zend_long offset; + object_intern *intern; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &offset) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { + return; + } + +- intern = get_object(getThis() TSRMLS_CC); ++ intern = get_object(getThis()); + if (!intern) { + return; + } +@@ -389,12 +389,12 @@ static const zend_function_entry fe[] = { /* {{{ */ + PHP_FE_END + }; /* }}} */ + +-void kafka_metadata_topic_partition_minit(TSRMLS_D) /* {{{ */ ++void kafka_metadata_topic_partition_minit() /* {{{ */ + { + zend_class_entry tmpce; + + INIT_NS_CLASS_ENTRY(tmpce, "RdKafka", "TopicPartition", fe); +- ce_kafka_topic_partition = zend_register_internal_class(&tmpce TSRMLS_CC); ++ ce_kafka_topic_partition = zend_register_internal_class(&tmpce); + 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] = ¶ms[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)); ++ handlers.free_obj = free_object; ++ handlers.offset = XtOffsetOf(object_intern, std); + } /* }}} */ +diff --git a/topic_partition.h b/topic_partition.h +index a7aab8b..746b1a5 100644 +--- a/topic_partition.h ++++ b/topic_partition.h +@@ -17,15 +17,10 @@ + */ + + typedef struct _kafka_topic_partition_intern { +-#if PHP_MAJOR_VERSION < 7 +- zend_object std; +-#endif + char *topic; + int32_t partition; + int64_t offset; +-#if PHP_MAJOR_VERSION >= 7 + zend_object std; +-#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; + +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; + +-void kafka_metadata_topic_partition_minit(); ++void kafka_metadata_topic_partition_minit(INIT_FUNC_ARGS); + + 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); |