@@ -254,21 +254,21 @@ static void nr_php_wrap_zend_function(zend_function* func,
254
254
}
255
255
}
256
256
257
- static zend_function * nr_php_wrap_user_function_internal (nruserfn_t * wraprec TSRMLS_DC ) {
257
+ static void nr_php_wrap_user_function_internal (nruserfn_t * wraprec TSRMLS_DC ) {
258
258
zend_function * orig_func = 0 ;
259
259
260
260
if (0 == NR_PHP_PROCESS_GLOBALS (done_instrumentation )) {
261
- return NULL ;
261
+ return ;
262
262
}
263
263
264
264
if (wraprec -> is_wrapped ) {
265
- return NULL ;
265
+ return ;
266
266
}
267
267
268
268
#if ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO \
269
269
&& defined OVERWRITE_ZEND_EXECUTE_DATA /* PHP8+ */
270
270
if (nrunlikely (-1 == NR_PHP_PROCESS_GLOBALS (zend_offset ))) {
271
- return NULL ;
271
+ return ;
272
272
}
273
273
#endif
274
274
if (0 == wraprec -> classname ) {
@@ -282,8 +282,9 @@ static zend_function* nr_php_wrap_user_function_internal(nruserfn_t* wraprec TSR
282
282
283
283
if (NULL == orig_func ) {
284
284
/* It could be in a file not yet loaded, no reason to log anything. */
285
- return NULL ;
285
+ return ;
286
286
}
287
+ wraprec -> func = orig_func ;
287
288
288
289
if (ZEND_USER_FUNCTION != orig_func -> type ) {
289
290
nrl_verbosedebug (NRL_INSTRUMENT , "%s%s%s is not a user function" ,
@@ -295,10 +296,9 @@ static zend_function* nr_php_wrap_user_function_internal(nruserfn_t* wraprec TSR
295
296
* logs with this message.
296
297
*/
297
298
wraprec -> is_disabled = 1 ;
298
- return NULL ;
299
+ return ;
299
300
}
300
301
nr_php_wrap_zend_function (orig_func , wraprec TSRMLS_CC );
301
- return orig_func ;
302
302
}
303
303
304
304
static nruserfn_t * nr_php_user_wraprec_create (void ) {
@@ -429,6 +429,10 @@ nruserfn_t* nr_php_add_custom_tracer_callable(zend_function* func TSRMLS_DC) {
429
429
nrl_verbosedebug (NRL_INSTRUMENT , "reusing custom wrapper for callable '%s'" ,
430
430
name );
431
431
nr_free (name );
432
+ #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
433
+ nr_php_observer_remove_begin_handler (func , wraprec );
434
+ nr_php_observer_remove_end_handler (func , wraprec );
435
+ #endif
432
436
return wraprec ;
433
437
}
434
438
@@ -442,6 +446,10 @@ nruserfn_t* nr_php_add_custom_tracer_callable(zend_function* func TSRMLS_DC) {
442
446
#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
443
447
nr_php_add_custom_tracer_common (wraprec );
444
448
#endif
449
+ #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
450
+ nr_php_observer_remove_begin_handler (func , NULL );
451
+ nr_php_observer_remove_end_handler (func , NULL );
452
+ #endif
445
453
446
454
return wraprec ;
447
455
}
@@ -450,9 +458,6 @@ nruserfn_t* nr_php_add_custom_tracer_named(const char* namestr,
450
458
size_t namestrlen ) {
451
459
nruserfn_t * wraprec ;
452
460
nruserfn_t * p ;
453
- #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
454
- zend_function * orig_func ;
455
- #endif
456
461
457
462
wraprec = nr_php_user_wraprec_create_named (namestr , namestrlen );
458
463
if (0 == wraprec ) {
@@ -472,6 +477,10 @@ nruserfn_t* nr_php_add_custom_tracer_named(const char* namestr,
472
477
473
478
nr_php_user_wraprec_destroy (& wraprec );
474
479
nr_php_wrap_user_function_internal (p TSRMLS_CC );
480
+ #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
481
+ nr_php_observer_remove_begin_handler (p -> func , wraprec );
482
+ nr_php_observer_remove_end_handler (p -> func , wraprec );
483
+ #endif
475
484
return p ; /* return the wraprec we are duplicating */
476
485
}
477
486
p = p -> next ;
@@ -482,18 +491,15 @@ nruserfn_t* nr_php_add_custom_tracer_named(const char* namestr,
482
491
NRP_PHP (wraprec -> classname ),
483
492
(0 == wraprec -> classname ) ? "" : "::" , NRP_PHP (wraprec -> funcname ));
484
493
485
- #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
486
- orig_func = nr_php_wrap_user_function_internal (wraprec TSRMLS_CC );
487
- #else
488
494
nr_php_wrap_user_function_internal (wraprec TSRMLS_CC );
489
- #endif
490
495
/* non-transient wraprecs are added to both the hashmap and linked list.
491
496
* At request shutdown, the hashmap will free transients, but leave
492
497
* non-transients to be freed when the linked list is disposed of which is at
493
498
* module shutdown */
494
499
nr_php_add_custom_tracer_common (wraprec );
495
500
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
496
- nr_php_observer_overwrite_handlers (orig_func , wraprec );
501
+ nr_php_observer_remove_begin_handler (wraprec -> func , NULL );
502
+ nr_php_observer_remove_end_handler (wraprec -> func , NULL );
497
503
#endif
498
504
499
505
return wraprec ; /* return the new wraprec */
@@ -579,6 +585,10 @@ void nr_php_add_transaction_naming_function(const char* namestr,
579
585
580
586
if (NULL != wraprec ) {
581
587
wraprec -> is_names_wt_simple = 1 ;
588
+ #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
589
+ nr_php_observer_add_begin_handler (wraprec -> func , wraprec );
590
+ nr_php_observer_add_end_handler (wraprec -> func , wraprec );
591
+ #endif
582
592
}
583
593
}
584
594
@@ -588,6 +598,10 @@ void nr_php_add_custom_tracer(const char* namestr, int namestrlen TSRMLS_DC) {
588
598
if (NULL != wraprec ) {
589
599
wraprec -> create_metric = 1 ;
590
600
wraprec -> is_user_added = 1 ;
601
+ #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
602
+ nr_php_observer_add_begin_handler (wraprec -> func , wraprec );
603
+ nr_php_observer_add_end_handler (wraprec -> func , wraprec );
604
+ #endif
591
605
}
592
606
}
593
607
@@ -596,6 +610,10 @@ void nr_php_add_exception_function(zend_function* func TSRMLS_DC) {
596
610
597
611
if (wraprec ) {
598
612
wraprec -> is_exception_handler = 1 ;
613
+ #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
614
+ nr_php_observer_add_begin_handler (func , wraprec );
615
+ nr_php_observer_add_end_handler (func , wraprec );
616
+ #endif
599
617
}
600
618
}
601
619
@@ -651,6 +669,10 @@ void nr_php_user_function_add_declared_callback(const char* namestr,
651
669
if (wraprec -> is_wrapped && callback ) {
652
670
(callback )(TSRMLS_C );
653
671
}
672
+ #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
673
+ nr_php_observer_add_begin_handler (wraprec -> func , wraprec );
674
+ nr_php_observer_add_end_handler (wraprec -> func , wraprec );
675
+ #endif
654
676
}
655
677
}
656
678
0 commit comments