Skip to content

Commit b991173

Browse files
authored
fix topic deconstruct for high level (#333)
* fix topic deconstruct for high level
1 parent 3d3f0c5 commit b991173

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

kafka_consumer.c

-6
Original file line numberDiff line numberDiff line change
@@ -633,12 +633,6 @@ PHP_METHOD(RdKafka__KafkaConsumer, newTopic)
633633
}
634634

635635
topic_intern->rkt = rkt;
636-
#if PHP_MAJOR_VERSION >= 7
637-
topic_intern->zrk = *getThis();
638-
#else
639-
topic_intern->zrk = getThis();
640-
#endif
641-
Z_ADDREF_P(P_ZEVAL(topic_intern->zrk));
642636
}
643637
/* }}} */
644638

tests/bug330.phpt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
TopicPartition destruct for high level consumer
3+
--FILE--
4+
<?php
5+
use RdKafka\Conf;
6+
use RdKafka\KafkaConsumer;
7+
8+
$conf = new Conf();
9+
$conf->set('group.id','test');
10+
$consumer = new KafkaConsumer($conf);
11+
$topic = $consumer->newTopic('test');
12+
unset($topic);
13+
var_dump(isset($topic));
14+
--EXPECT--
15+
bool(false)

topic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static void kafka_topic_free(zend_object *object TSRMLS_DC) /* {{{ */
4747
{
4848
kafka_topic_object *intern = get_custom_object(kafka_topic_object, object);
4949

50-
if (intern->rkt) {
50+
if (ZE_ISDEF(intern->zrk)) {
5151
kafka_object *kafka_intern = get_kafka_object(P_ZEVAL(intern->zrk) TSRMLS_CC);
5252
if (kafka_intern) {
5353
zend_hash_index_del(&kafka_intern->topics, (zend_ulong)intern);

0 commit comments

Comments
 (0)