diff --git a/agent/fw_wordpress.c b/agent/fw_wordpress.c index e74b1df5f..397327124 100644 --- a/agent/fw_wordpress.c +++ b/agent/fw_wordpress.c @@ -427,33 +427,34 @@ NR_PHP_WRAPPER(nr_wordpress_exec_handle_tag) { NR_UNUSED_SPECIALFN; (void)wraprec; - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_WORDPRESS); + if (nrlikely(0 != NRINI(wordpress_hooks))) { + NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_WORDPRESS); - tag = nr_php_arg_get(1, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); + tag = nr_php_arg_get(1, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - if (1 == nr_php_is_zval_non_empty_string(tag) - || (0 != NRINI(wordpress_hooks))) { - /* - * Our general approach here is to set the wordpress_tag global, then let - * the call_user_func_array instrumentation take care of actually timing - * the hooks by checking if it's set. - */ - char* old_tag = NRPRG(wordpress_tag); + if (1 == nr_php_is_zval_non_empty_string(tag)) { + /* + * Our general approach here is to set the wordpress_tag global, then let + * the call_user_func_array instrumentation take care of actually timing + * the hooks by checking if it's set. + */ + char* old_tag = NRPRG(wordpress_tag); - NRPRG(check_cufa) = true; + NRPRG(check_cufa) = true; - NRPRG(wordpress_tag) = nr_wordpress_clean_tag(tag); - NR_PHP_WRAPPER_CALL; - NRPRG(wordpress_tag) = old_tag; - if (NULL == NRPRG(wordpress_tag)) { + NRPRG(wordpress_tag) = nr_wordpress_clean_tag(tag); + NR_PHP_WRAPPER_CALL; + NRPRG(wordpress_tag) = old_tag; + if (NULL == NRPRG(wordpress_tag)) { + NRPRG(check_cufa) = false; + } + } else { NRPRG(check_cufa) = false; + NR_PHP_WRAPPER_CALL; } - } else { - NRPRG(check_cufa) = false; - NR_PHP_WRAPPER_CALL; - } - nr_php_arg_release(&tag); + nr_php_arg_release(&tag); + } } NR_PHP_WRAPPER_END @@ -553,17 +554,19 @@ void nr_wordpress_enable(TSRMLS_D) { nr_php_wrap_user_function(NR_PSTR("apply_filters"), nr_wordpress_apply_filters TSRMLS_CC); - nr_php_wrap_user_function(NR_PSTR("apply_filters_ref_array"), - nr_wordpress_exec_handle_tag TSRMLS_CC); + if (0 != NRINI(wordpress_hooks)) { + nr_php_wrap_user_function(NR_PSTR("apply_filters_ref_array"), + nr_wordpress_exec_handle_tag TSRMLS_CC); - nr_php_wrap_user_function(NR_PSTR("do_action"), - nr_wordpress_exec_handle_tag TSRMLS_CC); + nr_php_wrap_user_function(NR_PSTR("do_action"), + nr_wordpress_exec_handle_tag TSRMLS_CC); - nr_php_wrap_user_function(NR_PSTR("do_action_ref_array"), - nr_wordpress_exec_handle_tag TSRMLS_CC); + nr_php_wrap_user_function(NR_PSTR("do_action_ref_array"), + nr_wordpress_exec_handle_tag TSRMLS_CC); - nr_php_add_call_user_func_array_pre_callback( - nr_wordpress_call_user_func_array TSRMLS_CC); + nr_php_add_call_user_func_array_pre_callback( + nr_wordpress_call_user_func_array TSRMLS_CC); + } } void nr_wordpress_minit(void) { diff --git a/tests/integration/frameworks/wordpress/test_wordpress_transaction_name_hooks_off.php b/tests/integration/frameworks/wordpress/test_wordpress_transaction_name_hooks_off.php new file mode 100644 index 000000000..28b60e423 --- /dev/null +++ b/tests/integration/frameworks/wordpress/test_wordpress_transaction_name_hooks_off.php @@ -0,0 +1,51 @@ +