From ead28c21a438e64e0da8dc8dc53a1926246e73df Mon Sep 17 00:00:00 2001 From: Amber Sistla Date: Fri, 31 Jan 2025 13:17:39 -0700 Subject: [PATCH] fix(agent): Only set to 'default' in case of valid but empty string --- agent/lib_php_amqplib.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/agent/lib_php_amqplib.c b/agent/lib_php_amqplib.c index cf008d541..a8e968c2d 100644 --- a/agent/lib_php_amqplib.c +++ b/agent/lib_php_amqplib.c @@ -197,9 +197,13 @@ NR_PHP_WRAPPER(nr_rabbitmq_basic_publish) { message_params.destination_name = ENSURE_PERSISTENCE(Z_STRVAL_P(amqp_exchange)); } else { - /* For producer, this is exchange name. Exchange name is Default in case of - * empty string. */ - message_params.destination_name = ENSURE_PERSISTENCE("Default"); + /* + * For producer, this is exchange name. Exchange name is Default in case of + * empty string. + */ + if (nr_php_is_zval_valid_string(amqp_exchange)) { + message_params.destination_name = ENSURE_PERSISTENCE("Default"); + } } amqp_routing_key = nr_php_get_user_func_arg(3, NR_EXECUTE_ORIG_ARGS); @@ -327,12 +331,18 @@ NR_PHP_WRAPPER(nr_rabbitmq_basic_get) { */ amqp_exchange = nr_php_get_zval_object_property(*retval_ptr, "exchange"); if (nr_php_is_zval_non_empty_string(amqp_exchange)) { - /* Used with consumer only; his is exchange name. Exchange name is + /* Used with consumer only; this is exchange name. Exchange name is * Default in case of empty string. */ message_params.messaging_destination_publish_name = Z_STRVAL_P(amqp_exchange); } else { - message_params.messaging_destination_publish_name = "Default"; + /* + * For consumer, this is exchange name. Exchange name is Default in case + * of empty string. + */ + if (nr_php_is_zval_valid_string(amqp_exchange)) { + message_params.messaging_destination_publish_name = "Default"; + } } amqp_routing_key @@ -373,7 +383,6 @@ NR_PHP_WRAPPER(nr_rabbitmq_basic_get) { UNDO_PERSISTENCE(message_params.destination_name); } NR_PHP_WRAPPER_END - void nr_php_amqplib_enable() { /* * Set the UNKNOWN package first, so it doesn't overwrite what we find with