]> granicus.if.org Git - php/commitdiff
Fix #46241 (stacked error_handlers, error_handling in general)
authorEtienne Kneuss <colder@php.net>
Wed, 19 Nov 2008 01:59:07 +0000 (01:59 +0000)
committerEtienne Kneuss <colder@php.net>
Wed, 19 Nov 2008 01:59:07 +0000 (01:59 +0000)
24 files changed:
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

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 be755030e6e844e3083b0883bc378df97217fa2f..cc99b837ecf9c0c2eb03600beaf15d6d2029d021 100644 (file)
@@ -956,14 +956,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)
@@ -984,10 +981,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 1af730b51c841053b3520b64ffb0e845ecb689c9..b06a1afb715f1457044d9386fb3594782c8743f9 100644 (file)
@@ -2342,7 +2342,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;
@@ -2357,14 +2356,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_T(opline->result.u.var).var.ptr, 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);
@@ -2412,10 +2409,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 1c4cb5663ecd5d9415a29887a557bedacd53b398..32332b19e87a0d63ebd6bf518fdb2c3d87de18a1 100644 (file)
@@ -302,7 +302,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;
@@ -317,14 +316,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_T(opline->result.u.var).var.ptr, 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);
@@ -372,10 +369,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 3bba04d726e14f7f61e6a1ab196f04cfc0685526..cd708e7185c403d797b403824e36c463bf15a592 100644 (file)
@@ -2557,11 +2557,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);
 }
 /* }}} */
 
@@ -3259,8 +3261,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);
@@ -3271,6 +3274,7 @@ PHP_METHOD(DateTimeZone, __construct)
                        ZVAL_NULL(getThis());
                }
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -3610,8 +3614,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);
@@ -3621,6 +3626,7 @@ PHP_METHOD(DateInterval, __construct)
                        ZVAL_NULL(getThis());
                }
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -3763,12 +3769,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;
                        }
                }
@@ -3835,6 +3843,7 @@ PHP_METHOD(DatePeriod, __construct)
        dpobj->recurrences = recurrences + dpobj->include_start_date;
 
        dpobj->initialized = 1;
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
index b299182948d471bed47dee69aec26acb7ffe5aa7..287a20ef140b1dd44e3ed3763c6998643d3e2f4a 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, UG(utf8_conv), &value, &value_len, UG(utf8_conv)) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        zend_restore_error_handling(&error_handling TSRMLS_CC);
index fd81aff88be002725e7afaba025585671194df37..c9c78d5671e10cb10412a954507b95a197df7f06 100644 (file)
@@ -58,6 +58,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, UG(utf8_conv)) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        zend_restore_error_handling(&error_handling TSRMLS_CC);
index e84c9d218ca9df35c11ae65d407edee245624b02..f5722bda76d434aebf0ab10f026bcd0d0455bd9e 100644 (file)
@@ -58,6 +58,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, UG(utf8_conv)) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        zend_restore_error_handling(&error_handling TSRMLS_CC);
index 478738ac2a2a71be4fffaae5a4cf0e792f4851ff..65cead5be775853f5b82823995fea2cf65b19932 100644 (file)
@@ -1443,6 +1443,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|s&s&", &id, dom_document_class_entry, &version, &version_len, UG(utf8_conv), &encoding, &encoding_len, UG(utf8_conv)) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        zend_restore_error_handling(&error_handling TSRMLS_CC);
index a4bdb27a6b299772103636968fb0d928599c9fc0..725ded565200bc7aa22febf79c0f6357351b8fa9 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 c4371d2858f7d040a569d3001a96c007cba86d11..572a987962ed65f7f2695de3eb2a162d3c1b64a7 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, UG(utf8_conv), &value, &value_len, UG(utf8_conv), &uri, &uri_len, UG(utf8_conv)) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        zend_restore_error_handling(&error_handling TSRMLS_CC);
index d12e00cdf49ad78e4ef707c89e9a7b91ad113def..edd9e4b66783c5448481d8b21f1c3b8aa92b472b 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, UG(utf8_conv)) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        zend_restore_error_handling(&error_handling TSRMLS_CC);
index 231954a2cc7ca43583222e84c9028362c71d4c49..a7911430c41d16abb41ff85a5d4c7ad4def1cc00 100644 (file)
@@ -59,6 +59,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, UG(utf8_conv), &value, &value_len, UG(utf8_conv)) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        zend_restore_error_handling(&error_handling TSRMLS_CC);
index 84708b318cefd06304f82b2aebf388cded1679ef..f29cbc50c17c88df579d8ce6ff18293b29c22604 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, UG(utf8_conv)) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        zend_restore_error_handling(&error_handling TSRMLS_CC);
index ea507439adad42bb96b77b8e12cd96eba419e347..f80e21e52deeaa70b4612efa69ff14f18d3a6b43 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 cc24e202e0b9e08bc59b66db06c07fc8c27fa33d..49b1a90de27dfc92f131741784457bb0438407e4 100644 (file)
@@ -83,7 +83,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 b411a2650c98ea611c3917a5bd58f024720f908d..bf06cdcf7ea5424b7a4f4d2eff342ace71590c4b 100644 (file)
@@ -2238,6 +2238,7 @@ SXE_METHOD(__construct)
 
        zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|lbs&b", &data, &data_len, &data_type, &options, &is_url, &ns, &ns_len, UG(utf8_conv), &isprefix) == FAILURE) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
 
index 1e1ad10eaaeec89ce62c6b1824310e3886345df5..9c889c921d39edad5d05731c5770289ae45ed260 100755 (executable)
@@ -1017,16 +1017,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;
        }
 
@@ -1037,6 +1039,7 @@ SPL_METHOD(Array, __construct)
        ar_flags &= ~SPL_ARRAY_INT_MASK;
 
        spl_array_set_array(object, intern, array, ar_flags, ZEND_NUM_ARGS() == 1 TSRMLS_CC);
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
index bba8e4b6cce77a57c76f9916e4de351b42508eab..1c3770d0333e0827f659951d39852872dd715cc4 100755 (executable)
@@ -425,6 +425,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.v || !file_path_len) {
 #if defined(PHP_WIN32)
@@ -444,7 +445,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);
@@ -459,6 +460,7 @@ static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_
                spl_filesystem_info_set_filename(intern, file_type, file_path, file_path_len, use_copy TSRMLS_CC);
        }
        
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
        return intern;
 } /* }}} */
 
@@ -671,8 +673,9 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, int ctor_flag
        int parsed, len;
        zend_uchar path_type;
        long flags;
+       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 (ctor_flags & DIT_CTOR_FLAGS) {
                flags = SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO;
@@ -691,10 +694,12 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, int ctor_flag
        }
 
        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;
        }
 
@@ -713,6 +718,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);
 }
 /* }}} */
 
@@ -1009,16 +1015,20 @@ SPL_METHOD(SplFileInfo, __construct)
        zstr path;
        int path_len;
        zend_uchar path_type;
+       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, "t", &path, &path_len, &path_type) == 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_type, path, path_len, 1 TSRMLS_CC);
+
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
        
        /* intern->type = SPL_FS_INFO; already set */
 }
@@ -1029,10 +1039,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_u_stat(intern->file_name_type, intern->file_name, intern->file_name_len, func_num, FG(default_context), return_value TSRMLS_CC); \
+       zend_restore_error_handling(&error_handling TSRMLS_CC); \
 }
 /* }}} */
 
@@ -1119,8 +1131,9 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
        UChar *target;
        int ret, link_len, target_len;
        char *link, 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);
 
        if (intern->file_name_type == IS_UNICODE) {
                php_stream_path_encode(NULL, &link, &link_len, intern->file_name.u, intern->file_name_len, REPORT_ERRORS, FG(default_context));
@@ -1151,6 +1164,7 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
                        RETVAL_STRING(buff, 1);
                }
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -1164,8 +1178,9 @@ SPL_METHOD(SplFileInfo, getRealPath)
        int filename_len, path_len;
        char *filename, buff[MAXPATHLEN];
        zend_bool free_filename = 0;
+       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.v && intern->u.dir.entry.d_name[0]) {
                spl_filesystem_object_get_file_name(intern TSRMLS_CC);
@@ -1204,6 +1219,7 @@ SPL_METHOD(SplFileInfo, getRealPath)
        if (free_filename) {
                efree(filename);
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 #endif
@@ -1224,12 +1240,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);
 }
 /* }}} */
 
@@ -1239,12 +1258,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);
 }
 /* }}} */
 
@@ -1254,12 +1276,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);
 }
 /* }}} */
 
@@ -1269,8 +1294,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) {
                zend_uchar path_type;
@@ -1280,6 +1306,7 @@ SPL_METHOD(SplFileInfo, getPathInfo)
                        spl_filesystem_object_create_info(intern, path_type, path, path_len, 1, ce, return_value TSRMLS_CC);
                }
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -2088,8 +2115,9 @@ SPL_METHOD(SplFileObject, __construct)
        zstr 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;
@@ -2098,6 +2126,7 @@ SPL_METHOD(SplFileObject, __construct)
                        &intern->file_name, &intern->file_name_len, &intern->file_name_type,
                        &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;
        }
        
@@ -2129,6 +2158,7 @@ SPL_METHOD(SplFileObject, __construct)
                intern->_path_type = IS_STRING;
        }
 
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 } /* }}} */
 
 /* {{{ proto void SplTempFileObject::__construct([int max_memory]) U
@@ -2138,10 +2168,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;
        }
 
@@ -2167,6 +2199,7 @@ SPL_METHOD(SplTempFileObject, __construct)
                intern->_path_len = 0;
                intern->_path.s = estrndup("", 0);
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 } /* }}} */
 
 /* {{{ proto void SplFileObject::rewind() U
index 82190ba9aacc5e5e6a96940ac54be2e9f3c3b777..ebae46197f792c4c91091e952003e091f7546da1 100755 (executable)
@@ -425,8 +425,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: {
@@ -482,6 +483,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;
        }
 
@@ -531,6 +533,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 U
@@ -1289,6 +1292,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);
        
@@ -1297,7 +1301,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) {
@@ -1305,14 +1309,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;
@@ -1321,10 +1328,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;
@@ -1339,6 +1348,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
 
                        /* UTODO: class_name must be zstr */
                        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);
@@ -1349,6 +1359,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;
@@ -1359,10 +1370,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, "%v::getIterator() must return an object that implememnts Traversable", ce->name);
+                                               zend_restore_error_handling(&error_handling TSRMLS_CC);
                                                return NULL;
                                        }
                                        zobject = retval;
@@ -1376,6 +1389,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:
@@ -1389,10 +1403,12 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                        intern->u.regex.preg_flags = 0;
                        /* UTODO: do we need tocare if regex unicode? */
                        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;
@@ -1400,6 +1416,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                        intern->u.regex.pce = pcre_get_compiled_regex_cache(ZEND_STR_TYPE, 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++;
@@ -1408,12 +1425,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 d4b65adf99a8d4b487ab9b27910068ab7d612818..42ab09375f6bab3c7f9b1a693c504c03ce9bfd4b 100755 (executable)
@@ -605,15 +605,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 30707bf2aafeff7c330148c6b0825a5ab2f06558..fef7d48ef56b5d7824913612b72c76e19b997410 100644 (file)
@@ -1713,10 +1713,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, "Z|lz/", &ppfilename, &mode, &errmsg) ||
                FAILURE == php_stream_path_param_encode(ppfilename, &filename, &filename_len, REPORT_ERRORS, FG(default_context))) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                return;
        }
        if (errmsg) {
@@ -1727,6 +1729,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 {
@@ -1736,6 +1739,7 @@ PHP_FUNCTION(sqlite_open)
 
                if (php_check_open_basedir(fullpath TSRMLS_CC)) {
                        efree(fullpath);
+                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                        if (object) {
                                RETURN_NULL();
                        } else {
@@ -1749,6 +1753,7 @@ PHP_FUNCTION(sqlite_open)
        if (fullpath) {
                efree(fullpath);
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -1761,10 +1766,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, "Z|lz/", &ppfilename, &mode, &errmsg) ||
                FAILURE == php_stream_path_param_encode(ppfilename, &filename, &filename_len, REPORT_ERRORS, FG(default_context))) {
+               zend_restore_error_handling(&error_handling TSRMLS_CC);
                RETURN_NULL();
        }
        if (errmsg) {
@@ -1775,11 +1782,13 @@ 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 (php_check_open_basedir(fullpath TSRMLS_CC)) {
                        efree(fullpath);
+                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                        RETURN_NULL();
                }
        }
@@ -1788,6 +1797,7 @@ PHP_FUNCTION(sqlite_factory)
        if (fullpath) {
                efree(fullpath);
        }
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
 /* }}} */
 
@@ -2560,6 +2570,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, "|tzb", &class_name, &class_name_len, &class_name_type, &ctor_params, &decode_binary)) {
+                       zend_restore_error_handling(&error_handling TSRMLS_CC);
                        return;
                }
                RES_FROM_OBJECT(res, object);
@@ -2570,6 +2581,7 @@ PHP_FUNCTION(sqlite_fetch_object)
                }
        } else {
                if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|tzb", &zres, &class_name, &class_name_len, &class_name_type, &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);
@@ -2582,12 +2594,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 21f1870ca10ce875ea9519ba3934a9ab6645f498..c61758239541c83c715618708dffdd542eebebc1 100644 (file)
@@ -1207,12 +1207,14 @@ 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;
        }
 
@@ -1220,6 +1222,7 @@ PHP_METHOD(sqlite3stmt, __construct)
 
        SQLITE3_CHECK_INITIALIZED(db_obj->initialised, SQLite3)
 
+       zend_restore_error_handling(&error_handling TSRMLS_CC);
        if (!sql_len) {
                RETURN_FALSE;
        }
@@ -1407,11 +1410,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);
+
 }
 /* }}} */