diff --git a/conf.c b/conf.c index 7a1cf4c3..26fd088b 100644 --- a/conf.c +++ b/conf.c @@ -734,15 +734,11 @@ PHP_METHOD(RdKafka_Conf, setLogCb) } /* }}} */ +#ifdef HAS_RD_KAFKA_OAUTHBEARER_TOKEN_REFRESH_CB /* {{{ proto void RdKafka\Conf::setOauthbearerTokenRefreshCb(mixed $callback) Set token refresh callback for OAUTHBEARER sasl */ PHP_METHOD(RdKafka_Conf, setOauthbearerTokenRefreshCb) { -#ifndef HAS_RD_KAFKA_OAUTHBEARER_TOKEN_REFRESH_CB - zend_throw_exception_ex(NULL, 0, "This version of rdkafka does not support the OAUTHBEARER sasl mechanism"); - return; -#endif - zend_fcall_info fci; zend_fcall_info_cache fcc; kafka_conf_object *conf; @@ -770,6 +766,7 @@ PHP_METHOD(RdKafka_Conf, setOauthbearerTokenRefreshCb) rd_kafka_conf_set_oauthbearer_token_refresh_cb(conf->u.conf, kafka_conf_set_oauthbearer_token_refresh_cb); } /* }}} */ +#endif /* {{{ proto RdKafka\TopicConf::__construct() */ PHP_METHOD(RdKafka_TopicConf, __construct) diff --git a/conf.stub.php b/conf.stub.php index ccd84ab1..7aa6a62d 100644 --- a/conf.stub.php +++ b/conf.stub.php @@ -45,8 +45,10 @@ public function setOffsetCommitCb(callable $callback): void {} /** @tentative-return-type */ public function setLogCb(callable $callback): void {} + #ifdef HAS_RD_KAFKA_OAUTHBEARER_TOKEN_REFRESH_CB /** @tentative-return-type */ public function setOauthbearerTokenRefreshCb(callable $callback): void {} + #endif } class TopicConf diff --git a/tests/conf_callbacks.phpt b/tests/conf_callbacks.phpt index 6c78358d..fd5e881e 100644 --- a/tests/conf_callbacks.phpt +++ b/tests/conf_callbacks.phpt @@ -23,12 +23,8 @@ $conf->setRebalanceCb(function () { }); $dump = $conf->dump(); var_dump(isset($dump["rebalance_cb"])); -echo "Setting oauth token bearer callback\n"; -try { - $conf->setOauthbearerTokenRefreshCb(function () {}); -} catch (\Exception $e) { - echo $e->getMessage()."\n"; -} +echo "Checking if oauthbearer cb exists\n"; +var_dump(method_exists($conf, 'setOauthbearerTokenRefreshCb')); --EXPECT-- Setting consume callback @@ -37,5 +33,5 @@ Setting offset_commit callback bool(true) Setting rebalance callback bool(true) -Setting oauth token bearer callback -This version of rdkafka does not support the OAUTHBEARER sasl mechanism +Checking if oauthbearer cb exists +bool(false)