com php-src: Fixed bug #70532 (respect set_exception_handle r in phpdbg): NEWS Zend/zend.c Zend/zend_comp ile.h sapi/phpdbg/create-test.php
sapi/phpdbg/phpdbg_ prompt.c
| From: | Bob Weinand | Date: | Wed, 23 Sep 2015 15:53:29 +0000 |
| Subject: | com php-src: Fixed bug #70532 (respect set_exception_handle r in phpdbg): NEWS Zend/zend.c Zend/zend_comp ile.h sapi/phpdbg/create-test.php sapi/phpdbg/phpdbg_ prompt.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89140@lists.php.net to get a copy of this message | ||
Commit: 4a174ca7e602fb20d12b8b665eaf3ce5d4d46bd3
Author: Bob Weinand <bobwei9@hotmail.com> Wed, 23 Sep 2015 17:53:22 +0200
Parents: aba42e3dda6e3210cf26e667badd2eb7766dae4e
Branches: PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4a174ca7e602fb20d12b8b665eaf3ce5d4d46bd3
Log:
Fixed bug #70532 (respect set_exception_handler in phpdbg)
Bugs:
https://bugs.php.net/70532
Changed paths:
M NEWS
M Zend/zend.c
M Zend/zend_compile.h
M sapi/phpdbg/create-test.php
M sapi/phpdbg/phpdbg_prompt.c
Diff:
diff --git a/NEWS b/NEWS
index 3196061..31e7ad9 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,9 @@ PHP NEWS
. Require at least OpenSSL version 0.9.8. (Jakub Zelenka)
. Fixed bug #68312 (Lookup for openssl.cnf causes a message box). (Anatol)
+- Phpdbg:
+ . Fixed bug #70532 (phpdbg must respect set_exception_handler). (Bob)
+
- Session:
. Fixed bug #70529 (Session read causes "String is not zero-terminated" error).
(Yasuo)
diff --git a/Zend/zend.c b/Zend/zend.c
index 0a70ccc..2934f4a 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -1379,6 +1379,32 @@ ZEND_API ZEND_COLD void zend_output_debug_string(zend_bool trigger_break,
const
}
/* }}} */
+ZEND_API void zend_try_exception_handler() /* {{{ */
+{
+ if (EG(exception)) {
+ if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
+ zval orig_user_exception_handler;
+ zval params[1], retval2;
+ zend_object *old_exception;
+ old_exception = EG(exception);
+ EG(exception) = NULL;
+ ZVAL_OBJ(¶ms[0], old_exception);
+ ZVAL_COPY_VALUE(&orig_user_exception_handler, &EG(user_exception_handler));
+
+ if (call_user_function_ex(CG(function_table), NULL, &orig_user_exception_handler,
&retval2, 1, params, 1, NULL) == SUCCESS) {
+ zval_ptr_dtor(&retval2);
+ if (EG(exception)) {
+ OBJ_RELEASE(EG(exception));
+ EG(exception) = NULL;
+ }
+ OBJ_RELEASE(old_exception);
+ } else {
+ EG(exception) = old_exception;
+ }
+ }
+ }
+} /* }}} */
+
ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */
{
va_list files;
@@ -1401,30 +1427,9 @@ ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count,
...) /
if (op_array) {
zend_execute(op_array, retval);
zend_exception_restore();
+ zend_try_exception_handler();
if (EG(exception)) {
- if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
- zval orig_user_exception_handler;
- zval params[1], retval2;
- zend_object *old_exception;
- old_exception = EG(exception);
- EG(exception) = NULL;
- ZVAL_OBJ(¶ms[0], old_exception);
- ZVAL_COPY_VALUE(&orig_user_exception_handler, &EG(user_exception_handler));
-
- if (call_user_function_ex(CG(function_table), NULL, &orig_user_exception_handler,
&retval2, 1, params, 1, NULL) == SUCCESS) {
- zval_ptr_dtor(&retval2);
- if (EG(exception)) {
- OBJ_RELEASE(EG(exception));
- EG(exception) = NULL;
- }
- OBJ_RELEASE(old_exception);
- } else {
- EG(exception) = old_exception;
- zend_exception_error(EG(exception), E_ERROR);
- }
- } else {
- zend_exception_error(EG(exception), E_ERROR);
- }
+ zend_exception_error(EG(exception), E_ERROR);
}
destroy_op_array(op_array);
efree_size(op_array, sizeof(zend_op_array));
diff --git a/Zend/zend_compile..h b/Zend/zend_compile.h
index 06c7d02..ee4fbe5 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -725,6 +725,7 @@ ZEND_API void function_add_ref(zend_function *function);
ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type);
ZEND_API zend_op_array *compile_string(zval *source_string, char *filename);
ZEND_API zend_op_array *compile_filename(int type, zval *filename);
+ZEND_API void zend_try_exception_handler();
ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...);
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle);
ZEND_API void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size);
diff --git a/sapi/phpdbg/create-test.php b/sapi/phpdbg/create-test.php
index 6de10bd..5dc1ba4 100644
--- a/sapi/phpdbg/create-test.php
+++ b/sapi/phpdbg/create-test.php
@@ -98,11 +98,11 @@ stream_set_blocking(STDIN, true);
print "\n";
if (!isset($name)) {
- print "Specifiy the test description: ";
+ print "Specify the test description: ";
$desc = trim(fgets(STDIN));
}
while (!isset($testfile)) {
- print "Specifiy the test file name (leave empty to write to stderr): ";
+ print "Specify the test file name (leave empty to write to stderr): ";
$testfile = trim(fgets(STDIN));
if ($testfile != "" && file_exists($testfile)) {
print "That file already exists. Type y or yes to overwrite: ";
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
index cacfe93..0314d39 100644
--- a/sapi/phpdbg/phpdbg_prompt.c
+++ b/sapi/phpdbg/phpdbg_prompt.c
@@ -744,6 +744,8 @@ PHPDBG_COMMAND(run) /* {{{ */
}
if (restore) {
+ zend_exception_restore();
+ zend_try_exception_handler();
if (EG(exception)) {
phpdbg_handle_exception();
}