Skip to content

Commit c9c6fba

Browse files
authored
fix(agent): revert to using zend_error_cb hook for error reporting (#851)
Remove unwanted error reporting by overwriting zend_error_cb instead of using OAPI.
1 parent c497191 commit c9c6fba

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

agent/php_error.c

+5-12
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,6 @@ void nr_php_error_cb(int type,
595595
const char* format,
596596
va_list args) {
597597
#endif /* PHP >= 8.1 */
598-
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
599-
&& !defined OVERWRITE_ZEND_EXECUTE_DATA /* PHP 8.0+ and OAPI */
600-
(void)error_filename;
601-
(void)error_lineno;
602-
#endif
603598
TSRMLS_FETCH();
604599
char* stack_json = NULL;
605600
const char* errclass = NULL;
@@ -654,20 +649,18 @@ void nr_php_error_cb(int type,
654649
nr_free(msg);
655650
nr_free(stack_json);
656651
}
657-
/*
658-
* Call through to the actual error handler for PHP 7.4 and below.
659-
* For PHP 8+ we have registered our error handler with the Observer
660-
* API so there is no need to callback to the original.
661-
*/
662652
/*
663653
* Call through to the actual error handler.
664654
*/
665-
#if ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO
666655
if (0 != NR_PHP_PROCESS_GLOBALS(orig_error_cb)) {
656+
#if ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO
667657
NR_PHP_PROCESS_GLOBALS(orig_error_cb)
668658
(type, error_filename, error_lineno, format, args);
669-
}
659+
#else
660+
NR_PHP_PROCESS_GLOBALS(orig_error_cb)
661+
(type, error_filename, error_lineno, message);
670662
#endif /* PHP < 8.0 */
663+
}
671664
}
672665

673666
nr_status_t nr_php_error_record_exception(nrtxn_t* txn,

agent/php_minit.c

-3
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,6 @@ void nr_php_late_initialization(void) {
769769
* our own error callback handler. Otherwise, we do.
770770
*/
771771

772-
#if ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO \
773-
|| defined OVERWRITE_ZEND_EXECUTE_DATA /* < PHP8 */
774772
if (0 == zend_get_extension("Xdebug")) {
775773
NR_PHP_PROCESS_GLOBALS(orig_error_cb) = zend_error_cb;
776774
zend_error_cb = nr_php_error_cb;
@@ -779,7 +777,6 @@ void nr_php_late_initialization(void) {
779777
"the Xdebug extension prevents the New Relic agent from "
780778
"gathering errors. No errors will be recorded.");
781779
}
782-
#endif /* end of < PHP8 or not using OAPI*/
783780

784781
/*
785782
* Install our signal handler, unless the user has set a special flag

agent/php_observer.c

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ void nr_php_observer_minit() {
9494
* Register the Observer API handlers.
9595
*/
9696
zend_observer_fcall_register(nr_php_fcall_register_handlers);
97-
zend_observer_error_register(nr_php_error_cb);
9897

9998
/*
10099
* For Observer API with PHP 8+, we no longer need to ovewrwrite the zend

0 commit comments

Comments
 (0)