@@ -61,6 +61,8 @@ ZEND_TSRMLS_CACHE_DEFINE()
6161ZEND_API zend_utility_values zend_uv ;
6262ZEND_API zend_bool zend_dtrace_enabled ;
6363
64+ zend_llist zend_error_notify_callbacks ;
65+
6466/* version information */
6567static char * zend_version_info ;
6668static uint32_t zend_version_info_length ;
@@ -815,6 +817,7 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
815817
816818 zend_startup_strtod ();
817819 zend_startup_extensions_mechanism ();
820+ zend_startup_error_notify_callbacks ();
818821
819822 /* Set up utility functions and values */
820823 zend_error_cb = utility_functions -> error_function ;
@@ -846,6 +849,8 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
846849 zend_compile_file = dtrace_compile_file ;
847850 zend_execute_ex = dtrace_execute_ex ;
848851 zend_execute_internal = dtrace_execute_internal ;
852+
853+ zend_register_error_notify_callback (dtrace_error_notify_cb );
849854 } else {
850855 zend_compile_file = compile_file ;
851856 zend_execute_ex = execute_ex ;
@@ -1075,6 +1080,7 @@ void zend_shutdown(void) /* {{{ */
10751080 zend_hash_destroy (GLOBAL_AUTO_GLOBALS_TABLE );
10761081 free (GLOBAL_AUTO_GLOBALS_TABLE );
10771082
1083+ zend_shutdown_error_notify_callbacks ();
10781084 zend_shutdown_extensions ();
10791085 free (zend_version_info );
10801086
@@ -1311,11 +1317,7 @@ static ZEND_COLD void zend_error_impl(
13111317 }
13121318 }
13131319
1314- #ifdef HAVE_DTRACE
1315- if (DTRACE_ERROR_ENABLED ()) {
1316- DTRACE_ERROR (ZSTR_VAL (message ), (char * )error_filename , error_lineno );
1317- }
1318- #endif /* HAVE_DTRACE */
1320+ zend_error_notify_all_callbacks (type , error_filename , error_lineno , message );
13191321
13201322 /* if we don't have a user defined error handler */
13211323 if (Z_TYPE (EG (user_error_handler )) == IS_UNDEF
@@ -1771,3 +1773,29 @@ ZEND_API void zend_map_ptr_extend(size_t last)
17711773 CG (map_ptr_last ) = last ;
17721774 }
17731775}
1776+
1777+ void zend_startup_error_notify_callbacks ()
1778+ {
1779+ zend_llist_init (& zend_error_notify_callbacks , sizeof (zend_error_notify_cb ), NULL , 1 );
1780+ }
1781+
1782+ void zend_shutdown_error_notify_callbacks ()
1783+ {
1784+ zend_llist_destroy (& zend_error_notify_callbacks );
1785+ }
1786+
1787+ void zend_register_error_notify_callback (zend_error_notify_cb cb )
1788+ {
1789+ zend_llist_add_element (& zend_error_notify_callbacks , & cb );
1790+ }
1791+
1792+ void zend_error_notify_all_callbacks (int type , const char * error_filename , uint32_t error_lineno , zend_string * message )
1793+ {
1794+ zend_llist_element * element ;
1795+ zend_error_notify_cb callback ;
1796+
1797+ for (element = zend_error_notify_callbacks .head ; element ; element = element -> next ) {
1798+ callback = * (zend_error_notify_cb * ) (element -> data );
1799+ callback (type , error_filename , error_lineno , message );
1800+ }
1801+ }
0 commit comments