]> granicus.if.org Git - php/commitdiff
MFH: Fix #46241 (stacked error_handlers, error_handling in general)
authorEtienne Kneuss <colder@php.net>
Wed, 19 Nov 2008 02:00:53 +0000 (02:00 +0000)
committerEtienne Kneuss <colder@php.net>
Wed, 19 Nov 2008 02:00:53 +0000 (02:00 +0000)
25 files changed:
NEWS
Zend/tests/bug46196.phpt
Zend/tests/bug46241.phpt [new file with mode: 0644]
Zend/zend_execute_API.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/date/php_date.c
ext/dom/attr.c
ext/dom/cdatasection.c
ext/dom/comment.c
ext/dom/document.c
ext/dom/documentfragment.c
ext/dom/element.c
ext/dom/entityreference.c
ext/dom/processinginstruction.c
ext/dom/text.c
ext/dom/xpath.c
ext/mysqli/mysqli_driver.c
ext/simplexml/simplexml.c
ext/spl/spl_array.c
ext/spl/spl_directory.c
ext/spl/spl_iterators.c
ext/spl/spl_observer.c
ext/sqlite/sqlite.c
ext/sqlite3/sqlite3.c

diff --git a/NEWS b/NEWS
index d4f9c9260cceb6ded79eb57a957b55106c8cbb6c..c17d1d10496fabffab33f6389b5a944cdcf92c14 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,8 @@ PHP                                                                        NEWS
   endian systems). (Scott)
 - Fixed bug #46285 (lastInsertId() returns "0" when a deferenced PDOStatement is
   executed). (Johannes)
+- Fixed bug #46241 (stacked error handlers, error handling in genera). 
+  (Etienne)
 - Fixed bug #46238 (Segmentation fault on static call with empty string method).
   (Felipe)
 - Fixed bug #46205 (Closure - Memory leaks when ReflectionException is thrown).
index 9facaa73a78e2abe5fed6e032de7de95ad08720b..7526d802ab57aae5c72bf2c5a896adafca2fe275 100644 (file)
@@ -2,8 +2,6 @@
 Test restore_error_handler() function : bug #46196
 --CREDITS--
 Olivier Doucet
---XFAIL--
-This test will fail until bug #46196 is fixed
 --FILE--
 <?php
 /* Prototype  : void restore_error_handler(void)
diff --git a/Zend/tests/bug46241.phpt b/Zend/tests/bug46241.phpt
new file mode 100644 (file)
index 0000000..40ed7c8
--- /dev/null
@@ -0,0 +1,50 @@
+--TEST--
+Bug #46241 (error handler stacks)
+--FILE--
+<?php
+
+class ErrorHandling
+{
+
+    public function errorHandler1( $errno, $errstr )
+    {
+        echo "Caught on first level: '$errstr'\n";
+        return true;
+    }
+
+    public function errorHandler2( $errno, $errstr )
+    {
+        echo "Caught on second level: '$errstr'\n";
+        return true;
+    }
+}
+
+$err = new ErrorHandling();
+
+set_error_handler( array( $err, 'errorHandler1' ) );
+set_error_handler( array( $err, 'errorHandler2' ) );
+
+trigger_error( 'Foo', E_USER_WARNING );
+
+function errorHandler1( $errno, $errstr )
+{
+    echo "Caught on first level: '$errstr'\n";
+    return true;
+}
+
+function errorHandler2( $errno, $errstr )
+{   
+    echo "Caught on second level: '$errstr'\n";
+    return true;
+}
+
+set_error_handler( 'errorHandler1' );
+set_error_handler( 'errorHandler2' );
+
+trigger_error( 'Foo', E_USER_WARNING );
+?>
+==END==
+--EXPECT--
+Caught on second level: 'Foo'
+Caught on second level: 'Foo'
+==END==
index 50a8598df11c77ad322c46775188ae63a4641e43..222e3147dbcbe048166ac2f4e5c173fd9fa2f6d0 100644 (file)
@@ -943,14 +943,11 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
                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 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);
-               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)
@@ -971,10 +968,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
 
                /* Not sure what should be done here if it's a static method */
                if (fci->object_pp) {
-                       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);
-                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                } else {
                        zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
                }
index 344a3a3ee8408131a5be500753e493fe8ff123ca..afb5d897f96b67df5b3472cb93eaa1334ae7847b 100644 (file)
@@ -2270,7 +2270,6 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
        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;
@@ -2285,14 +2284,12 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
                                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,10 +2337,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
 
                        /* 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");
                }
index 3896d46d94d9884bcd1a92ecf94307ef127358f3..5aed0ef12cdd1aca39092a51c350a6ac40c8093e 100644 (file)
@@ -294,7 +294,6 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
        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;
@@ -309,14 +308,12 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
                                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);
@@ -364,10 +361,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
 
                        /* 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");
                }
index c2e93d59a9aea5661835e639993519c44436a0ce..e69e0a409b3f09c515ac224b31ca02b1122a2671 100644 (file)
@@ -2420,12 +2420,13 @@ PHP_METHOD(DateTime, __construct)
        zval *timezone_object = NULL;
        char *time_str = NULL;
        int time_str_len = 0;
-       
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
        if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
                date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 1 TSRMLS_CC);
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -3094,8 +3095,9 @@ PHP_METHOD(DateTimeZone, __construct)
        int tz_len;
        timelib_tzinfo *tzi = NULL;
        php_timezone_obj *tzobj;
+       zend_error_handling error_handling;
        
-       zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
        if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &tz, &tz_len)) {
                if (SUCCESS == timezone_initialize(&tzi, tz TSRMLS_CC)) {
                        tzobj = zend_object_store_get_object(getThis() TSRMLS_CC);
@@ -3106,6 +3108,7 @@ PHP_METHOD(DateTimeZone, __construct)
                        ZVAL_NULL(getThis());
                }
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -3437,8 +3440,9 @@ PHP_METHOD(DateInterval, __construct)
        int   interval_string_length;
        php_interval_obj *diobj;
        timelib_rel_time *reltime;
+       zend_error_handling error_handling;
        
-       zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &interval_string, &interval_string_length) == SUCCESS) {
                if (date_interval_initialize(&reltime, interval_string, interval_string_length TSRMLS_CC) == SUCCESS) {
                        diobj = zend_object_store_get_object(getThis() TSRMLS_CC);
@@ -3448,6 +3452,7 @@ PHP_METHOD(DateInterval, __construct)
                        ZVAL_NULL(getThis());
                }
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -3590,12 +3595,14 @@ PHP_METHOD(DatePeriod, __construct)
        char *isostr = NULL;
        int   isostr_len = 0;
        timelib_time *clone;
+       zend_error_handling error_handling;
        
-       zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
        if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "OOl|l", &start, date_ce_date, &interval, date_ce_interval, &recurrences, &options) == FAILURE) {
                if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "OOO|l", &start, date_ce_date, &interval, date_ce_interval, &end, date_ce_date, &options) == FAILURE) {
                        if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &isostr, &isostr_len, &options) == FAILURE) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "This constructor accepts either (DateTime, DateInterval, int) OR (DateTime, DateInterval, DateTime) OR (string) as arguments.");
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return;
                        }
                }
@@ -3662,6 +3669,8 @@ PHP_METHOD(DatePeriod, __construct)
        dpobj->recurrences = recurrences + dpobj->include_start_date;
 
        dpobj->initialized = 1;
+
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
index 0b3c3f018edbd61669f8b67a7e62b700b2300327..6707c9be1b4fe0ab04e12576f57b2a4bf5e1c9f7 100644 (file)
@@ -66,6 +66,7 @@ PHP_METHOD(domattr, __construct)
 
        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s", &id, dom_attr_class_entry, &name, &name_len, &value, &value_len) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index c5ec09d97b9d727639752061448143a596d2f11c..7ba228d39f217f39d8b27bb72badf5ba398cfc0b 100644 (file)
@@ -59,6 +59,7 @@ PHP_METHOD(domcdatasection, __construct)
 
        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_cdatasection_class_entry, &value, &value_len) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index c0faf252b3e1d5a6a3b3f2e84b8d0bdd76963f75..03ac1ab0cf9beceb3e0e683e01a8e984479de002 100644 (file)
@@ -59,6 +59,7 @@ PHP_METHOD(domcomment, __construct)
 
        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|s", &id, dom_comment_class_entry, &value, &value_len) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index dfa98a541178f7fa6033e795c290a2b35d7db531..d16f1177fdfffd139187c31daea16de260bde57d 100644 (file)
@@ -1441,6 +1441,7 @@ PHP_METHOD(domdocument, __construct)
 
        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ss", &id, dom_document_class_entry, &version, &version_len, &encoding, &encoding_len) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index e81aba463886b804f790386b267b259aa60fd8bd..cd2adabf74510b6961ab5dd771bbd50325f87976 100644 (file)
@@ -60,6 +60,7 @@ PHP_METHOD(domdocumentfragment, __construct)
 
        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, dom_documentfragment_class_entry) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index 3685afb442e30ffbd3e2c6f90b753174fc2c9641..80522e9cb2d0b255d7d052b0813d53a2bbce27a4 100644 (file)
@@ -166,6 +166,7 @@ PHP_METHOD(domelement, __construct)
 
        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s!s", &id, dom_element_class_entry, &name, &name_len, &value, &value_len, &uri, &uri_len) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        zend_restore_error_handling(&error_handling TSRMLS_CC);
index cf1e9c7778b77420ebd4319fc520cd6e434f3218..592a2a2ddb4080762d9acab340b926fb17e80ee7 100644 (file)
@@ -58,6 +58,7 @@ PHP_METHOD(domentityreference, __construct)
 
        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_entityreference_class_entry, &name, &name_len) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index c3122def9e0e51af0cbb2a6314acc0883fbfd501..59d989aa49234edb72e5f58b013bba0c2890fa86 100644 (file)
@@ -60,6 +60,7 @@ PHP_METHOD(domprocessinginstruction, __construct)
 
        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s", &id, dom_processinginstruction_class_entry, &name, &name_len, &value, &value_len) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index 630bd8444a1c3f82f944128a1c4b0a446da7d84f..70d353996795ccdc9b6e8106cd22528a4ec18298 100644 (file)
@@ -74,6 +74,7 @@ PHP_METHOD(domtext, __construct)
 
        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|s", &id, dom_text_class_entry, &value, &value_len) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index cac8e6ba360fdfe95b2517c3fafa3fa152b28d51..beab4d70e9356e6e75d13c8a0d3d7b573cbcda0e 100644 (file)
@@ -277,6 +277,7 @@ PHP_METHOD(domxpath, __construct)
 
        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &id, dom_xpath_class_entry, &doc, dom_document_class_entry) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index bc803e1d202b8f4931df8d573377aafce706ce89..111aa9d4da94f65901bdefcdc7d744d43076b03b 100644 (file)
@@ -79,7 +79,7 @@ static int driver_report_write(mysqli_object *obj, zval *value TSRMLS_DC)
 {
        MyG(report_mode) = Z_LVAL_P(value);
        /*FIXME*/
-       zend_replace_error_handling(MyG(report_mode) & MYSQLI_REPORT_STRICT ? EH_THROW : EH_NORMAL, NULL, NULL TSRMLS_CC);
+       /* zend_replace_error_handling(MyG(report_mode) & MYSQLI_REPORT_STRICT ? EH_THROW : EH_NORMAL, NULL, NULL TSRMLS_CC); */
        return SUCCESS;
 }
 /* }}} */
index da4c990798786fc9507a205dee7330510b41bb69..1819d56f5c58ee10654e1b3f8b2f9f1af943f64f 100644 (file)
@@ -2182,6 +2182,7 @@ SXE_METHOD(__construct)
 
        zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lbsb", &data, &data_len, &options, &is_url, &ns, &ns_len, &isprefix) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index 7e930fd74ffdc9b26aa6372a06c34cd403232ede..f1f2a82af77a5208d5a5aa9267a6a9ba74c1665b 100755 (executable)
@@ -1010,16 +1010,18 @@ SPL_METHOD(Array, __construct)
        zval **array;
        long ar_flags = 0;
        zend_class_entry *ce_get_iterator = spl_ce_Iterator;
+       zend_error_handling error_handling;
 
        if (ZEND_NUM_ARGS() == 0) {
                return; /* nothing to do */
        }
 
-       zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
 
        intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
@@ -1031,6 +1033,8 @@ SPL_METHOD(Array, __construct)
 
        spl_array_set_array(object, intern, array, ar_flags, ZEND_NUM_ARGS() == 1 TSRMLS_CC);
 
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
+
 }
  /* }}} */
 
index a5cdacc817048374763f511fcef0ed9cb4d6f900..30daea7337aa4fd4d7b4f4469fec5527ab538084 100755 (executable)
@@ -373,6 +373,7 @@ static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_
 {
        spl_filesystem_object *intern;
        zval *arg1;
+       zend_error_handling error_handling;
 
        if (!file_path || !file_path_len) {
 #if defined(PHP_WIN32)
@@ -391,7 +392,7 @@ static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_
                return NULL;
        }
 
-       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
 
        ce = ce ? ce : source->info_class;
        return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC);
@@ -406,6 +407,7 @@ static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_
                spl_filesystem_info_set_filename(intern, file_path, file_path_len, use_copy TSRMLS_CC);
        }
        
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
        return intern;
 } /* }}} */
 
@@ -604,8 +606,9 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, int ctor_flag
        char *path;
        int parsed, len;
        long flags;
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
 
        if (ctor_flags & DIT_CTOR_FLAGS) {
                flags = SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO;
@@ -621,10 +624,12 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, int ctor_flag
                flags |= SPL_FILE_DIR_UNIXPATHS;
        }
        if (parsed == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        if (!len) {
                zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Directory name must not be empty.");
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
@@ -640,6 +645,7 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, int ctor_flag
 
        intern->u.dir.is_recursive = instanceof_function(intern->std.ce, spl_ce_RecursiveDirectoryIterator TSRMLS_CC) ? 1 : 0;
 
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -914,16 +920,20 @@ SPL_METHOD(SplFileInfo, __construct)
        spl_filesystem_object *intern;
        char *path;
        int len;
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &len) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
        intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        
        spl_filesystem_info_set_filename(intern, path, len, 1 TSRMLS_CC);
+
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
        
        /* intern->type = SPL_FS_INFO; already set */
 }
@@ -934,10 +944,12 @@ SPL_METHOD(SplFileInfo, __construct)
 SPL_METHOD(SplFileInfo, func_name) \
 { \
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
+       zend_error_handling error_handling; \
  \
-       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);\
+       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);\
        spl_filesystem_object_get_file_name(intern TSRMLS_CC); \
        php_stat(intern->file_name, intern->file_name_len, func_num, return_value TSRMLS_CC); \
+       zend_restore_error_handling(&error_handling TSRMLS_CC); \
 }
 /* }}} */
 
@@ -1023,8 +1035,9 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        int ret;
        char buff[MAXPATHLEN];
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
 
 #ifdef HAVE_SYMLINK
        ret = readlink(intern->file_name, buff, MAXPATHLEN-1);
@@ -1041,6 +1054,8 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
 
                RETVAL_STRINGL(buff, ret, 1);
        }
+
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -1052,8 +1067,9 @@ SPL_METHOD(SplFileInfo, getRealPath)
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        char buff[MAXPATHLEN];
        char *filename;
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
 
        if (intern->type == SPL_FS_DIR && !intern->file_name && intern->u.dir.entry.d_name[0]) {
                spl_filesystem_object_get_file_name(intern TSRMLS_CC);
@@ -1076,6 +1092,8 @@ SPL_METHOD(SplFileInfo, getRealPath)
        } else {
                RETVAL_FALSE;
        }
+
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 #endif
@@ -1096,12 +1114,15 @@ SPL_METHOD(SplFileInfo, setFileClass)
 {
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zend_class_entry *ce = spl_ce_SplFileObject;
+       zend_error_handling error_handling;
        
-       zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
                intern->file_class = ce;
        }
+
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -1111,12 +1132,15 @@ SPL_METHOD(SplFileInfo, setInfoClass)
 {
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zend_class_entry *ce = spl_ce_SplFileInfo;
+       zend_error_handling error_handling;
        
-       zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling  TSRMLS_CC);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
                intern->info_class = ce;
        }
+
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -1126,12 +1150,15 @@ SPL_METHOD(SplFileInfo, getFileInfo)
 {
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zend_class_entry *ce = intern->info_class;
+       zend_error_handling error_handling;
        
-       zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
                spl_filesystem_object_create_type(ht, intern, SPL_FS_INFO, ce, return_value TSRMLS_CC);
        }
+
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -1141,8 +1168,9 @@ SPL_METHOD(SplFileInfo, getPathInfo)
 {
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zend_class_entry *ce = intern->info_class;
+       zend_error_handling error_handling;
        
-       zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
                int path_len;
@@ -1151,6 +1179,8 @@ SPL_METHOD(SplFileInfo, getPathInfo)
                        spl_filesystem_object_create_info(intern, path, path_len, 1, ce, return_value TSRMLS_CC);
                }
        }
+
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -1940,8 +1970,9 @@ SPL_METHOD(SplFileObject, __construct)
        char *p1, *p2;
        char *tmp_path;
        int   tmp_path_len;
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
 
        intern->u.file.open_mode = "r";
        intern->u.file.open_mode_len = 1;
@@ -1950,6 +1981,7 @@ SPL_METHOD(SplFileObject, __construct)
                        &intern->file_name, &intern->file_name_len,
                        &intern->u.file.open_mode, &intern->u.file.open_mode_len, 
                        &use_include_path, &intern->u.file.zcontext) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        
@@ -1979,6 +2011,8 @@ SPL_METHOD(SplFileObject, __construct)
                intern->_path = estrndup(intern->u.file.stream->orig_path, intern->_path_len);
        }
 
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
+
 } /* }}} */
 
 /* {{{ proto void SplTempFileObject::__construct([int max_memory])
@@ -1988,10 +2022,12 @@ SPL_METHOD(SplTempFileObject, __construct)
        long max_memory = PHP_STREAM_MAX_MEM;
        char tmp_fname[48];
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &max_memory) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
@@ -2013,6 +2049,7 @@ SPL_METHOD(SplTempFileObject, __construct)
                intern->_path_len = 0;
                intern->_path = estrndup("", 0);
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 } /* }}} */
 
 /* {{{ proto void SplFileObject::rewind()
index 19aeffbbec00a359b6afdd0129830f37cffe63c5..24aaad1e391b37ba16494a2b3ed688a069e8ed53 100755 (executable)
@@ -424,8 +424,9 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
        zend_class_entry          *ce_iterator;
        long                       mode, flags;
        int                        inc_refcount = 1;
+       zend_error_handling        error_handling;
 
-       zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
 
        switch(rit_type) {
                case RIT_RecursiveTreeIterator: {
@@ -481,6 +482,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
                        zval_ptr_dtor(&iterator);
                }
                zend_throw_exception(spl_ce_InvalidArgumentException, "An instance of RecursiveIterator or IteratorAggregate creating it is required", 0 TSRMLS_CC);
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
@@ -530,6 +532,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
        intern->iterators[0].ce = ce_iterator;
        intern->iterators[0].state = RS_START;
 
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 
 /* {{{ proto void RecursiveIteratorIterator::__construct(RecursiveIterator|IteratorAggregate it [, int mode = RIT_LEAVES_ONLY [, int flags = 0]]) throws InvalidArgumentException
@@ -1237,6 +1240,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
        spl_dual_it_object   *intern;
        zend_class_entry     *ce = NULL;
        int                   inc_refcount = 1;
+       zend_error_handling   error_handling;
 
        intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        
@@ -1245,7 +1249,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                return NULL;
        }
 
-       zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
 
        intern->dit_type = dit_type;
        switch (dit_type) {
@@ -1253,14 +1257,17 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                        intern->u.limit.offset = 0; /* start at beginning */
                        intern->u.limit.count = -1; /* get all */
                        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|ll", &zobject, ce_inner, &intern->u.limit.offset, &intern->u.limit.count) == FAILURE) {
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
                        if (intern->u.limit.offset < 0) {
                                zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be > 0", 0 TSRMLS_CC);
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
                        if (intern->u.limit.count < 0 && intern->u.limit.count != -1) {
                                zend_throw_exception(spl_ce_OutOfRangeException, "Parameter count must either be -1 or a value greater than or equal 0", 0 TSRMLS_CC);
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
                        break;
@@ -1269,10 +1276,12 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                case DIT_RecursiveCachingIterator: {
                        long flags = CIT_CALL_TOSTRING;
                        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|l", &zobject, ce_inner, &flags) == FAILURE) {
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
                        if (spl_cit_check_flags(flags) != SUCCESS) {
                                zend_throw_exception(spl_ce_InvalidArgumentException, "Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_CURRENT", 0 TSRMLS_CC);
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
                        intern->u.caching.flags |= flags & CIT_PUBLIC;
@@ -1286,6 +1295,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                        int class_name_len = 0;
 
                        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|s", &zobject, ce_inner, &class_name, &class_name_len) == FAILURE) {
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
                        ce = Z_OBJCE_P(zobject);
@@ -1296,6 +1306,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                                        || !(*pce_cast)->get_iterator
                                        ) {
                                                zend_throw_exception(spl_ce_LogicException, "Class to downcast to not found or not base class or does not implement Traversable", 0 TSRMLS_CC);
+                                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                                return NULL;
                                        }
                                        ce = *pce_cast;
@@ -1306,10 +1317,12 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                                                if (retval) {
                                                        zval_ptr_dtor(&retval);
                                                }
+                                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                                return NULL;
                                        }
                                        if (!retval || Z_TYPE_P(retval) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(retval), zend_ce_traversable TSRMLS_CC)) {
                                                zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "%s::getIterator() must return an object that implememnts Traversable", ce->name);
+                                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                                return NULL;
                                        }
                                        zobject = retval;
@@ -1323,6 +1336,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                        spl_instantiate(spl_ce_ArrayIterator, &intern->u.append.zarrayit, 1 TSRMLS_CC);
                        zend_call_method_with_0_params(&intern->u.append.zarrayit, spl_ce_ArrayIterator, &spl_ce_ArrayIterator->constructor, "__construct", NULL);
                        intern->u.append.iterator = spl_ce_ArrayIterator->get_iterator(spl_ce_ArrayIterator, intern->u.append.zarrayit, 0 TSRMLS_CC);
+                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                        return intern;
 #if HAVE_PCRE || HAVE_BUNDLED_PCRE
                case DIT_RegexIterator:
@@ -1335,10 +1349,12 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                        intern->u.regex.flags = 0;
                        intern->u.regex.preg_flags = 0;
                        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|lll", &zobject, ce_inner, &regex, &regex_len, &mode, &intern->u.regex.flags, &intern->u.regex.preg_flags) == FAILURE) {
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
                        if (mode < 0 || mode >= REGIT_MODE_MAX) {
                                zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Illegal mode %ld", mode);
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
                        intern->u.regex.mode = mode;
@@ -1346,6 +1362,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                        intern->u.regex.pce = pcre_get_compiled_regex_cache(regex, regex_len TSRMLS_CC);
                        if (intern->u.regex.pce == NULL) {
                                /* pcre_get_compiled_regex_cache has already sent error */
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
                        intern->u.regex.pce->refcount++;
@@ -1354,12 +1371,13 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
 #endif
                default:
                        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zobject, ce_inner) == FAILURE) {
+                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
                        break;
        }
 
-       zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC);
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 
        if (inc_refcount) {
                Z_ADDREF_P(zobject);
index a875be2ed9b769b29ee9321fa788ae6f28ac1ef2..e2f97889ed9117cd0792563f968ec45c86708105 100755 (executable)
@@ -630,15 +630,18 @@ SPL_METHOD(MultipleIterator, __construct)
 {
        spl_SplObjectStorage   *intern;
        long                    flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC;
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
        intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
        intern->flags = flags;
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
index 8625fb11a908c479bfbc03eb6ac4eb493e0bc55e..ad612e4da701acf331a411b4fc2411bce6492bb5 100644 (file)
@@ -1620,10 +1620,12 @@ PHP_FUNCTION(sqlite_open)
        int filename_len;
        zval *errmsg = NULL;
        zval *object = getThis();
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(object ? EH_THROW : EH_NORMAL, sqlite_ce_exception, NULL TSRMLS_CC);
+       zend_replace_error_handling(object ? EH_THROW : EH_NORMAL, sqlite_ce_exception, &error_handling TSRMLS_CC);
        if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/",
                                &filename, &filename_len, &mode, &errmsg)) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        if (errmsg) {
@@ -1634,6 +1636,7 @@ PHP_FUNCTION(sqlite_open)
        if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
                /* resolve the fully-qualified path name to use as the hash key */
                if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
+                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                        if (object) {
                                RETURN_NULL();
                        } else {
@@ -1644,6 +1647,7 @@ PHP_FUNCTION(sqlite_open)
                if ((PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) ||
                                php_check_open_basedir(fullpath TSRMLS_CC)) {
                        efree(fullpath);
+                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                        if (object) {
                                RETURN_NULL();
                        } else {
@@ -1657,6 +1661,7 @@ PHP_FUNCTION(sqlite_open)
        if (fullpath) {
                efree(fullpath);
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -1668,10 +1673,12 @@ PHP_FUNCTION(sqlite_factory)
        char *filename, *fullpath = NULL;
        int filename_len;
        zval *errmsg = NULL;
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(EH_THROW, sqlite_ce_exception, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, sqlite_ce_exception, &error_handling TSRMLS_CC);
        if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/",
                                &filename, &filename_len, &mode, &errmsg)) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                RETURN_NULL();
        }
        if (errmsg) {
@@ -1682,12 +1689,14 @@ PHP_FUNCTION(sqlite_factory)
        if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
                /* resolve the fully-qualified path name to use as the hash key */
                if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
+                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                        RETURN_NULL();
                }
 
                if ((PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) ||
                                php_check_open_basedir(fullpath TSRMLS_CC)) {
                        efree(fullpath);
+                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                        RETURN_NULL();
                }
        }
@@ -1696,6 +1705,7 @@ PHP_FUNCTION(sqlite_factory)
        if (fullpath) {
                efree(fullpath);
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -2356,6 +2366,7 @@ PHP_FUNCTION(sqlite_fetch_object)
        zend_replace_error_handling(object ? EH_THROW : EH_NORMAL, sqlite_ce_exception, &error_handling TSRMLS_CC);
        if (object) {
                if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|szb", &class_name, &class_name_len, &ctor_params, &decode_binary)) {
+                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                        return;
                }
                RES_FROM_OBJECT(res, object);
@@ -2366,6 +2377,7 @@ PHP_FUNCTION(sqlite_fetch_object)
                }
        } else {
                if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|szb", &zres, &class_name, &class_name_len, &ctor_params, &decode_binary)) {
+                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                        return;
                }
                ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
@@ -2378,12 +2390,14 @@ PHP_FUNCTION(sqlite_fetch_object)
 
        if (!ce) {
                zend_throw_exception_ex(sqlite_ce_exception, 0 TSRMLS_CC, "Could not find class '%s'", class_name);
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
        if (res->curr_row < res->nrows) {
                php_sqlite_fetch_array(res, PHPSQLITE_ASSOC, decode_binary, 1, &dataset TSRMLS_CC);
        } else {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                RETURN_FALSE;
        }
 
index 8f36786811f449872f85d0fe17856ed04effd142..1506cef5a8496311cd51d8b28cf6cc891c4eef90 100644 (file)
@@ -1179,11 +1179,13 @@ PHP_METHOD(sqlite3stmt, __construct)
        zval *db_zval;
        char *sql;
        int sql_len, errcode;
+       zend_error_handling error_handling;
 
        stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC);
-       zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &db_zval, php_sqlite3_sc_entry, &sql, &sql_len) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
@@ -1191,6 +1193,8 @@ PHP_METHOD(sqlite3stmt, __construct)
 
        SQLITE3_CHECK_INITIALIZED(db_obj->initialised, SQLite3)
 
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
+
        if (!sql_len) {
                RETURN_FALSE;
        }
@@ -1377,11 +1381,14 @@ PHP_METHOD(sqlite3result, __construct)
        php_sqlite3_result *result_obj;
        zval *object = getThis();
        result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC);
+       zend_error_handling error_handling;
 
-       zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
 
        php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLite3Result cannot be directly instantiated");
 
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
+
 }
 /* }}} */