summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Eberlei <kontakt@beberlei.de>2020-09-14 14:05:54 +0200
committerBenjamin Eberlei <kontakt@beberlei.de>2020-09-14 19:29:14 +0200
commit1359a52d5bbab26004c6195d9d8b8fbc720fd701 (patch)
tree1be638afbcd1357516bd81b975f376ee0dcc009a
parent8f342ad4d2be23e898984900a8093be0f78e830a (diff)
downloadphp-git-1359a52d5bbab26004c6195d9d8b8fbc720fd701.tar.gz
Rename zend_error_notify APIs to zend_observer_error*
-rw-r--r--UPGRADING.INTERNALS10
-rw-r--r--Zend/zend.c34
-rw-r--r--Zend/zend.h9
-rw-r--r--Zend/zend_exceptions.c5
-rw-r--r--Zend/zend_observer.c18
-rw-r--r--Zend/zend_observer.h5
-rw-r--r--main/main.c2
7 files changed, 34 insertions, 49 deletions
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index 462850993a..249cd553ba 100644
--- a/UPGRADING.INTERNALS
+++ b/UPGRADING.INTERNALS
@@ -370,19 +370,19 @@ PHP 8.0 INTERNALS UPGRADE NOTES
u. Instead of overwriting zend_error_cb extensions with debugging, monitoring
use-cases catching Errors/Exceptions are strongly encouraged to use
- the new error notification API instead.
+ the new error observer API instead.
- Error notification callbacks are guaranteed to be called regardless of
+ Error observering callbacks are guaranteed to be called regardless of
the users error_reporting setting or userland error handler return values.
- Register notification callbacks during MINIT of an extension:
+ Register observer callbacks during MINIT of an extension:
- void my_error_notify_cb(int type,
+ void my_error_observer_cb(int type,
const char *error_filename,
uint32_t error_lineno,
zend_string *message) {
}
- zend_register_error_notify_callback(my_error_notify_cb);
+ zend_observer_error_register(my_error_observer_cb);
v. The following APIs have been removed from the Zend Engine:
- zend_ts_hash_init_ex(), drop the last argument and use zend_ts_hash_init() instead
diff --git a/Zend/zend.c b/Zend/zend.c
index 2a834eb6c4..4d781e6a10 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -62,8 +62,6 @@ ZEND_TSRMLS_CACHE_DEFINE()
ZEND_API zend_utility_values zend_uv;
ZEND_API zend_bool zend_dtrace_enabled;
-zend_llist zend_error_notify_callbacks;
-
/* version information */
static char *zend_version_info;
static uint32_t zend_version_info_length;
@@ -832,7 +830,6 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
zend_startup_strtod();
zend_startup_extensions_mechanism();
- zend_startup_error_notify_callbacks();
/* Set up utility functions and values */
zend_error_cb = utility_functions->error_function;
@@ -865,7 +862,7 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
zend_execute_ex = dtrace_execute_ex;
zend_execute_internal = dtrace_execute_internal;
- zend_register_error_notify_callback(dtrace_error_notify_cb);
+ zend_observer_error_register(dtrace_error_notify_cb);
} else {
zend_compile_file = compile_file;
zend_execute_ex = execute_ex;
@@ -1093,7 +1090,6 @@ void zend_shutdown(void) /* {{{ */
zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE);
free(GLOBAL_AUTO_GLOBALS_TABLE);
- zend_shutdown_error_notify_callbacks();
zend_shutdown_extensions();
free(zend_version_info);
@@ -1329,7 +1325,7 @@ static ZEND_COLD void zend_error_impl(
}
}
- zend_error_notify_all_callbacks(type, error_filename, error_lineno, message);
+ zend_observer_error_notify(type, error_filename, error_lineno, message);
/* if we don't have a user defined error handler */
if (Z_TYPE(EG(user_error_handler)) == IS_UNDEF
@@ -1792,29 +1788,3 @@ ZEND_API void zend_map_ptr_extend(size_t last)
CG(map_ptr_last) = last;
}
}
-
-void zend_startup_error_notify_callbacks(void)
-{
- zend_llist_init(&zend_error_notify_callbacks, sizeof(zend_error_notify_cb), NULL, 1);
-}
-
-void zend_shutdown_error_notify_callbacks(void)
-{
- zend_llist_destroy(&zend_error_notify_callbacks);
-}
-
-ZEND_API void zend_register_error_notify_callback(zend_error_notify_cb cb)
-{
- zend_llist_add_element(&zend_error_notify_callbacks, &cb);
-}
-
-void zend_error_notify_all_callbacks(int type, const char *error_filename, uint32_t error_lineno, zend_string *message)
-{
- zend_llist_element *element;
- zend_error_notify_cb callback;
-
- for (element = zend_error_notify_callbacks.head; element; element = element->next) {
- callback = *(zend_error_notify_cb *) (element->data);
- callback(type, error_filename, error_lineno, message);
- }
-}
diff --git a/Zend/zend.h b/Zend/zend.h
index 47b938e2cd..c10fadd0d0 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -350,15 +350,6 @@ ZEND_API void zend_save_error_handling(zend_error_handling *current);
ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current);
ZEND_API void zend_restore_error_handling(zend_error_handling *saved);
-typedef void (*zend_error_notify_cb)(int type, const char *error_filename, uint32_t error_lineno, zend_string *message);
-
-BEGIN_EXTERN_C()
-ZEND_API void zend_register_error_notify_callback(zend_error_notify_cb callback);
-void zend_startup_error_notify_callbacks(void);
-void zend_shutdown_error_notify_callbacks(void);
-void zend_error_notify_all_callbacks(int type, const char *error_filename, uint32_t error_lineno, zend_string *message);
-END_EXTERN_C()
-
#define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
#define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1)
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 7184f5bf68..1a0b7d581a 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -28,6 +28,7 @@
#include "zend_dtrace.h"
#include "zend_smart_str.h"
#include "zend_exceptions_arginfo.h"
+#include "zend_observer.h"
ZEND_API zend_class_entry *zend_ce_throwable;
ZEND_API zend_class_entry *zend_ce_exception;
@@ -900,7 +901,7 @@ static void zend_error_va(int type, const char *file, uint32_t lineno, const cha
va_list args;
va_start(args, format);
zend_string *message = zend_vstrpprintf(0, format, args);
- zend_error_notify_all_callbacks(type, file, lineno, message);
+ zend_observer_error_notify(type, file, lineno, message);
zend_error_cb(type, file, lineno, message);
zend_string_release(message);
va_end(args);
@@ -923,7 +924,7 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
zend_long line = zval_get_long(GET_PROPERTY_SILENT(&exception, ZEND_STR_LINE));
int type = (ce_exception == zend_ce_parse_error ? E_PARSE : E_COMPILE_ERROR) | E_DONT_BAIL;
- zend_error_notify_all_callbacks(type, ZSTR_VAL(file), line, message);
+ zend_observer_error_notify(type, ZSTR_VAL(file), line, message);
zend_error_cb(type, ZSTR_VAL(file), line, message);
zend_string_release_ex(file, 0);
diff --git a/Zend/zend_observer.c b/Zend/zend_observer.c
index 033551c6e9..b124de5cc3 100644
--- a/Zend/zend_observer.c
+++ b/Zend/zend_observer.c
@@ -24,6 +24,8 @@
#include "zend_vm.h"
zend_llist zend_observers_fcall_list;
+zend_llist zend_observer_error_callbacks;
+
int zend_observer_fcall_op_array_extension = -1;
ZEND_TLS zend_arena *fcall_handlers_arena = NULL;
@@ -58,6 +60,7 @@ ZEND_API void zend_observer_fcall_register(zend_observer_fcall_init init) {
// Called by engine before MINITs
ZEND_API void zend_observer_startup(void) {
zend_llist_init(&zend_observers_fcall_list, sizeof(zend_observer_fcall_init), NULL, 1);
+ zend_llist_init(&zend_observer_error_callbacks, sizeof(zend_observer_error_cb), NULL, 1);
}
ZEND_API void zend_observer_activate(void) {
@@ -74,6 +77,7 @@ ZEND_API void zend_observer_deactivate(void) {
ZEND_API void zend_observer_shutdown(void) {
zend_llist_destroy(&zend_observers_fcall_list);
+ zend_llist_destroy(&zend_observer_error_callbacks);
}
ZEND_API void zend_observer_fcall_install(zend_function *function) {
@@ -157,4 +161,18 @@ ZEND_API void zend_observe_fcall_end(
}
}
+ZEND_API void zend_observer_error_register(zend_observer_error_cb cb)
+{
+ zend_llist_add_element(&zend_observer_error_callbacks, &cb);
+}
+
+void zend_observer_error_notify(int type, const char *error_filename, uint32_t error_lineno, zend_string *message)
+{
+ zend_llist_element *element;
+ zend_observer_error_cb callback;
+ for (element = zend_observer_error_callbacks.head; element; element = element->next) {
+ callback = *(zend_observer_error_cb *) (element->data);
+ callback(type, error_filename, error_lineno, message);
+ }
+}
diff --git a/Zend/zend_observer.h b/Zend/zend_observer.h
index 9fb538ce3d..0603591c53 100644
--- a/Zend/zend_observer.h
+++ b/Zend/zend_observer.h
@@ -110,6 +110,11 @@ ZEND_API zend_always_inline void zend_observer_maybe_fcall_call_end(
}
}
+typedef void (*zend_observer_error_cb)(int type, const char *error_filename, uint32_t error_lineno, zend_string *message);
+
+ZEND_API void zend_observer_error_register(zend_observer_error_cb callback);
+void zend_observer_error_notify(int type, const char *error_filename, uint32_t error_lineno, zend_string *message);
+
END_EXTERN_C()
#endif /* ZEND_OBSERVER_H */
diff --git a/main/main.c b/main/main.c
index 890116e45c..5970cb4e18 100644
--- a/main/main.c
+++ b/main/main.c
@@ -2045,7 +2045,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
zend_update_current_locale();
#if ZEND_DEBUG
- zend_register_error_notify_callback(report_zend_debug_error_notify_cb);
+ zend_observer_error_register(report_zend_debug_error_notify_cb);
#endif
#if HAVE_TZSET