Skip to content

Commit ead28c2

Browse files
authored
fix(agent): Only set to 'default' in case of valid but empty string
1 parent 2335634 commit ead28c2

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

agent/lib_php_amqplib.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,13 @@ NR_PHP_WRAPPER(nr_rabbitmq_basic_publish) {
197197
message_params.destination_name
198198
= ENSURE_PERSISTENCE(Z_STRVAL_P(amqp_exchange));
199199
} else {
200-
/* For producer, this is exchange name. Exchange name is Default in case of
201-
* empty string. */
202-
message_params.destination_name = ENSURE_PERSISTENCE("Default");
200+
/*
201+
* For producer, this is exchange name. Exchange name is Default in case of
202+
* empty string.
203+
*/
204+
if (nr_php_is_zval_valid_string(amqp_exchange)) {
205+
message_params.destination_name = ENSURE_PERSISTENCE("Default");
206+
}
203207
}
204208

205209
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) {
327331
*/
328332
amqp_exchange = nr_php_get_zval_object_property(*retval_ptr, "exchange");
329333
if (nr_php_is_zval_non_empty_string(amqp_exchange)) {
330-
/* Used with consumer only; his is exchange name. Exchange name is
334+
/* Used with consumer only; this is exchange name. Exchange name is
331335
* Default in case of empty string. */
332336
message_params.messaging_destination_publish_name
333337
= Z_STRVAL_P(amqp_exchange);
334338
} else {
335-
message_params.messaging_destination_publish_name = "Default";
339+
/*
340+
* For consumer, this is exchange name. Exchange name is Default in case
341+
* of empty string.
342+
*/
343+
if (nr_php_is_zval_valid_string(amqp_exchange)) {
344+
message_params.messaging_destination_publish_name = "Default";
345+
}
336346
}
337347

338348
amqp_routing_key
@@ -373,7 +383,6 @@ NR_PHP_WRAPPER(nr_rabbitmq_basic_get) {
373383
UNDO_PERSISTENCE(message_params.destination_name);
374384
}
375385
NR_PHP_WRAPPER_END
376-
377386
void nr_php_amqplib_enable() {
378387
/*
379388
* Set the UNKNOWN package first, so it doesn't overwrite what we find with

0 commit comments

Comments
 (0)