cvs: ZendEngine2(PHP_5_3) / zend.h zend_API.c zend_execute_API.c zend_vm_def.h zend_vm_execute.h php-src/main main.c php.h

From: Date: Fri, 08 Aug 2008 17:47:52 +0000
Subject: cvs: ZendEngine2(PHP_5_3) / zend.h zend_API.c zend_execute_API.c zend_vm_def.h zend_vm_execute.h php-src/main main.c php.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-7007@lists.php.net to get a copy of this message
helly Fri Aug 8 17:47:52 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/main main.c php.h /ZendEngine2 zend.h zend_API.c zend_execute_API.c zend_vm_def.h zend_vm_execute.h Log: - MFH error handling, now with save, replace, restore

http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.640.2.23.2.57.2.27&r2=1.640.2.23.2.57.2.28&diff_format=u Index: php-src/main/main.c diff -u php-src/main/main.c:1.640.2.23.2.57.2.27 php-src/main/main.c:1.640.2.23.2.57.2.28 --- php-src/main/main.c:1.640.2.23.2.57.2.27 Fri Jul 25 13:46:56 2008 +++ php-src/main/main.c Fri Aug 8 17:47:24 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.640.2.23.2.57.2.27 2008/07/25 13:46:56 felipe Exp $ */ +/* $Id: main.c,v 1.640.2.23.2.57.2.28 2008/08/08 17:47:24 helly Exp $ */ /* {{{ includes */ @@ -777,21 +777,6 @@ } /* }}} */ -/* {{{ php_suppress_errors */ -PHPAPI void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC) -{ - EG(error_handling) = error_handling; - EG(exception_class) = exception_class; - - if (error_handling == EH_NORMAL) { - EG(user_error_handler) = EG(user_error_handler_old); - } else { - EG(user_error_handler_old) = EG(user_error_handler); - EG(user_error_handler) = NULL; - } -} -/* }}} */ - /* {{{ php_error_cb extended error handling function */ static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) http://cvs.php.net/viewvc.cgi/php-src/main/php.h?r1=1.221.2.4.2.8.2.7&r2=1.221.2.4.2.8.2.8&diff_format=u Index: php-src/main/php.h diff -u php-src/main/php.h:1.221.2.4.2.8.2.7 php-src/main/php.h:1.221.2.4.2.8.2.8 --- php-src/main/php.h:1.221.2.4.2.8.2.7 Fri Aug 8 14:15:05 2008 +++ php-src/main/php.h Fri Aug 8 17:47:24 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h,v 1.221.2.4.2.8.2.7 2008/08/08 14:15:05 helly Exp $ */ +/* $Id: php.h,v 1.221.2.4.2.8.2.8 2008/08/08 17:47:24 helly Exp $ */ #ifndef PHP_H #define PHP_H @@ -287,7 +287,10 @@ #define error_handling_t zend_error_handling_t BEGIN_EXTERN_C() -PHPAPI void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC); +static inline ZEND_ATTRIBUTE_DEPRECATED void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC) +{ + zend_replace_error_handling(error_handling, exception_class, NULL TSRMLS_CC); +} static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling() {} PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC) PHP_ATTRIBUTE_FORMAT(printf, 4, 0); http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.h?r1=1.293.2.11.2.9.2.24&r2=1.293.2.11.2.9.2.25&diff_format=u Index: ZendEngine2/zend.h diff -u ZendEngine2/zend.h:1.293.2.11.2.9.2.24 ZendEngine2/zend.h:1.293.2.11.2.9.2.25 --- ZendEngine2/zend.h:1.293.2.11.2.9.2.24 Mon Jul 14 09:48:58 2008 +++ ZendEngine2/zend.h Fri Aug 8 17:47:26 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.293.2.11.2.9.2.24 2008/07/14 09:48:58 dmitry Exp $ */ +/* $Id: zend.h,v 1.293.2.11.2.9.2.25 2008/08/08 17:47:26 helly Exp $ */ #ifndef ZEND_H #define ZEND_H @@ -749,6 +749,15 @@ EH_THROW } zend_error_handling_t; +typedef struct { + zend_error_handling_t handling; + zend_class_entry *exception; +} zend_error_handling; + +ZEND_API void zend_save_error_handling(zend_error_handling *current TSRMLS_DC); +ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC); +ZEND_API void zend_restore_error_handling(const zend_error_handling *saved TSRMLS_DC); + #endif /* ZEND_H */ /* http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.296.2.27.2.34.2.47&r2=1.296.2.27.2.34.2.48&diff_format=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.296.2.27.2.34.2.47 ZendEngine2/zend_API.c:1.296.2.27.2.34.2.48 --- ZendEngine2/zend_API.c:1.296.2.27.2.34.2.47 Thu Aug 7 12:04:13 2008 +++ ZendEngine2/zend_API.c Fri Aug 8 17:47:28 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.296.2.27.2.34.2.47 2008/08/07 12:04:13 dmitry Exp $ */ +/* $Id: zend_API.c,v 1.296.2.27.2.34.2.48 2008/08/08 17:47:28 helly Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -3463,6 +3463,37 @@ } /* }}} */ +ZEND_API void zend_save_error_handling(zend_error_handling *current TSRMLS_DC) /* {{{ */ +{ + current->handling = EG(error_handling); + current->exception = EG(exception_class); +} +/* }}} */ + +ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC) /* {{{ */ +{ + if (current) { + zend_save_error_handling(current TSRMLS_CC); + } + EG(error_handling) = error_handling; + EG(exception_class) = error_handling == EH_THROW ? exception_class : NULL; + + if (error_handling == EH_NORMAL) { + EG(user_error_handler) = EG(user_error_handler_old); + } else { + EG(user_error_handler_old) = EG(user_error_handler); + EG(user_error_handler) = NULL; + } +} +/* }}} */ + +ZEND_API void zend_restore_error_handling(const zend_error_handling *saved TSRMLS_DC) /* {{{ */ +{ + EG(error_handling) = saved->handling; + EG(exception_class) = saved->handling == EH_THROW ? saved->exception : NULL; +} +/* }}} */ + /* * Local variables: * tab-width: 4 http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.331.2.20.2.24.2.51&r2=1.331.2.20.2.24.2.52&diff_format=u Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.51 ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.52 --- ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.51 Fri Aug 8 13:21:52 2008 +++ ZendEngine2/zend_execute_API.c Fri Aug 8 17:47:29 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.51 2008/08/08 13:21:52 helly Exp $ */ +/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.52 2008/08/08 17:47:29 helly Exp $ */ #include <stdio.h> #include <signal.h> @@ -890,16 +890,14 @@ EG(opline_ptr) = original_opline_ptr; } else if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { int call_via_handler = (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; - zend_error_handling_t error_handling = EG(error_handling); - zend_class_entry *exception_class = EG(exception_class); - + zend_error_handling error_handling; + zend_save_error_handling(&error_handling TSRMLS_CC); ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr); if (EX(function_state).function->common.scope) { EG(scope) = EX(function_state).function->common.scope; } ((zend_internal_function *) EX(function_state).function)->handler(fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, (fci->object_pp?*fci->object_pp:NULL), 1 TSRMLS_CC); - EG(error_handling) = error_handling; - EG(exception_class) = exception_class; + zend_restore_error_handling(&error_handling TSRMLS_CC); /* We shouldn't fix bad extensions here, because it can break proper ones (Bug #34045) if (!EX(function_state).function->common.return_reference) @@ -920,11 +918,10 @@ /* Not sure what should be done here if it's a static method */ if (fci->object_pp) { - zend_error_handling_t error_handling = EG(error_handling); - zend_class_entry *exception_class = EG(exception_class); + zend_error_handling error_handling; + zend_save_error_handling(&error_handling TSRMLS_CC); Z_OBJ_HT_PP(fci->object_pp)->call_method(EX(function_state).function->common.function_name, fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, *fci->object_pp, 1 TSRMLS_CC); - EG(error_handling) = error_handling; - EG(exception_class) = exception_class; + zend_restore_error_handling(&error_handling TSRMLS_CC); } else { zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.59.2.29.2.48.2.65&r2=1.59.2.29.2.48.2.66&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.65 ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.66 --- ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.65 Sat Jul 26 15:30:25 2008 +++ ZendEngine2/zend_vm_def.h Fri Aug 8 17:47:30 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.59.2.29.2.48.2.65 2008/07/26 15:30:25 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.59.2.29.2.48.2.66 2008/08/08 17:47:30 helly Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -2273,6 +2273,7 @@ EX(function_state).arguments = zend_vm_stack_push_args(opline->extended_value TSRMLS_CC); if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { + zend_error_handling error_handling; ALLOC_INIT_ZVAL(EX_T(opline->result.u.var).var.ptr); EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; EX_T(opline->result.u.var).var.fcall_returned_reference = EX(function_state).function->common.return_reference; @@ -2287,12 +2288,14 @@ arg_count--; } } + zend_save_error_handling(&error_handling TSRMLS_CC); if (!zend_execute_internal) { /* saves one function call if zend_execute_internal is not used */ ((zend_internal_function *) EX(function_state).function)->handler(opline->extended_value, EX_T(opline->result.u.var).var.ptr, EX(function_state).function->common.return_reference?&EX_T(opline->result.u.var).var.ptr:NULL, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); } else { zend_execute_internal(EXECUTE_DATA, RETURN_VALUE_USED(opline) TSRMLS_CC); } + zend_restore_error_handling(&error_handling TSRMLS_CC); if (!RETURN_VALUE_USED(opline)) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); @@ -2340,7 +2343,10 @@ /* Not sure what should be done here if it's a static method */ if (EX(object)) { + zend_error_handling error_handling; + zend_save_error_handling(&error_handling TSRMLS_CC); Z_OBJ_HT_P(EX(object))->call_method(EX(function_state).function->common.function_name, opline->extended_value, EX_T(opline->result.u.var).var.ptr, &EX_T(opline->result.u.var).var.ptr, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); + zend_restore_error_handling(&error_handling TSRMLS_CC); } else { zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.62.2.30.2.49.2.65&r2=1.62.2.30.2.49.2.66&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.65 ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.66 --- ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.65 Sat Jul 26 15:30:25 2008 +++ ZendEngine2/zend_vm_execute.h Fri Aug 8 17:47:31 2008 @@ -294,6 +294,7 @@ EX(function_state).arguments = zend_vm_stack_push_args(opline->extended_value TSRMLS_CC); if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { + zend_error_handling error_handling; ALLOC_INIT_ZVAL(EX_T(opline->result.u.var).var.ptr); EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; EX_T(opline->result.u.var).var.fcall_returned_reference = EX(function_state).function->common.return_reference; @@ -308,12 +309,14 @@ arg_count--; } } + zend_save_error_handling(&error_handling TSRMLS_CC); if (!zend_execute_internal) { /* saves one function call if zend_execute_internal is not used */ ((zend_internal_function *) EX(function_state).function)->handler(opline->extended_value, EX_T(opline->result.u.var).var.ptr, EX(function_state).function->common.return_reference?&EX_T(opline->result.u.var).var.ptr:NULL, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); } else { zend_execute_internal(execute_data, RETURN_VALUE_USED(opline) TSRMLS_CC); } + zend_restore_error_handling(&error_handling TSRMLS_CC); if (!RETURN_VALUE_USED(opline)) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); @@ -361,7 +364,10 @@ /* Not sure what should be done here if it's a static method */ if (EX(object)) { + zend_error_handling error_handling; + zend_save_error_handling(&error_handling TSRMLS_CC); Z_OBJ_HT_P(EX(object))->call_method(EX(function_state).function->common.function_name, opline->extended_value, EX_T(opline->result.u.var).var.ptr, &EX_T(opline->result.u.var).var.ptr, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); + zend_restore_error_handling(&error_handling TSRMLS_CC); } else { zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); }
« previous php.zend-engine.cvs (#7007) next »