Skip to content

Commit

Permalink
fix(agent): revert to using zend_error_cb hook for error reporting (#…
Browse files Browse the repository at this point in the history
…851)

Remove unwanted error reporting by overwriting zend_error_cb instead of
using OAPI.
  • Loading branch information
ZNeumann authored Mar 15, 2024
1 parent c497191 commit c9c6fba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
17 changes: 5 additions & 12 deletions agent/php_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,6 @@ void nr_php_error_cb(int type,
const char* format,
va_list args) {
#endif /* PHP >= 8.1 */
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA /* PHP 8.0+ and OAPI */
(void)error_filename;
(void)error_lineno;
#endif
TSRMLS_FETCH();
char* stack_json = NULL;
const char* errclass = NULL;
Expand Down Expand Up @@ -654,20 +649,18 @@ void nr_php_error_cb(int type,
nr_free(msg);
nr_free(stack_json);
}
/*
* Call through to the actual error handler for PHP 7.4 and below.
* For PHP 8+ we have registered our error handler with the Observer
* API so there is no need to callback to the original.
*/
/*
* Call through to the actual error handler.
*/
#if ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO
if (0 != NR_PHP_PROCESS_GLOBALS(orig_error_cb)) {
#if ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO
NR_PHP_PROCESS_GLOBALS(orig_error_cb)
(type, error_filename, error_lineno, format, args);
}
#else
NR_PHP_PROCESS_GLOBALS(orig_error_cb)
(type, error_filename, error_lineno, message);
#endif /* PHP < 8.0 */
}
}

nr_status_t nr_php_error_record_exception(nrtxn_t* txn,
Expand Down
3 changes: 0 additions & 3 deletions agent/php_minit.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,6 @@ void nr_php_late_initialization(void) {
* our own error callback handler. Otherwise, we do.
*/

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

/*
* Install our signal handler, unless the user has set a special flag
Expand Down
1 change: 0 additions & 1 deletion agent/php_observer.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ void nr_php_observer_minit() {
* Register the Observer API handlers.
*/
zend_observer_fcall_register(nr_php_fcall_register_handlers);
zend_observer_error_register(nr_php_error_cb);

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

0 comments on commit c9c6fba

Please sign in to comment.