@@ -778,17 +778,15 @@ PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
778778/* {{{ php_suppress_errors */
779779PHPAPI void php_set_error_handling (error_handling_t error_handling , zend_class_entry * exception_class TSRMLS_DC )
780780{
781- PG (error_handling ) = error_handling ;
782- PG (exception_class ) = exception_class ;
783- if (PG (last_error_message )) {
784- free (PG (last_error_message ));
785- PG (last_error_message ) = NULL ;
786- }
787- if (PG (last_error_file )) {
788- free (PG (last_error_file ));
789- PG (last_error_file ) = NULL ;
781+ EG (error_handling ) = error_handling ;
782+ EG (exception_class ) = exception_class ;
783+
784+ if (error_handling == EH_NORMAL ) {
785+ EG (user_error_handler ) = EG (user_error_handler_old );
786+ } else {
787+ EG (user_error_handler_old ) = EG (user_error_handler );
788+ EG (user_error_handler ) = NULL ;
790789 }
791- PG (last_error_lineno ) = 0 ;
792790}
793791/* }}} */
794792
@@ -833,7 +831,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
833831 }
834832
835833 /* according to error handling mode, suppress error, throw exception or show it */
836- if (PG (error_handling ) != EH_NORMAL ) {
834+ if (EG (error_handling ) != EH_NORMAL ) {
837835 switch (type ) {
838836 case E_ERROR :
839837 case E_CORE_ERROR :
@@ -854,8 +852,8 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
854852 /* throw an exception if we are in EH_THROW mode
855853 * but DO NOT overwrite a pending exception
856854 */
857- if (PG (error_handling ) == EH_THROW && !EG (exception )) {
858- zend_throw_error_exception (PG (exception_class ), buffer , 0 , type TSRMLS_CC );
855+ if (EG (error_handling ) == EH_THROW && !EG (exception )) {
856+ zend_throw_error_exception (EG (exception_class ), buffer , 0 , type TSRMLS_CC );
859857 }
860858 efree (buffer );
861859 return ;
@@ -1729,7 +1727,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
17291727 PG (last_error_message ) = NULL ;
17301728 PG (last_error_file ) = NULL ;
17311729 PG (last_error_lineno ) = 0 ;
1732- PG (error_handling ) = EH_NORMAL ;
1730+ EG (error_handling ) = EH_NORMAL ;
1731+ EG (exception_class ) = NULL ;
17331732 PG (disable_functions ) = NULL ;
17341733 PG (disable_classes ) = NULL ;
17351734
0 commit comments