Skip to content

fix(agent): revert to using zend_error_cb hook for error reporting #851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions agent/php_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,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 @@ -622,20 +617,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