]> granicus.if.org Git - php/commitdiff
Fixed bug #42151 (__destruct functions not called after catching a SoapFault exception)
authorDmitry Stogov <dmitry@php.net>
Wed, 1 Aug 2007 10:39:33 +0000 (10:39 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 1 Aug 2007 10:39:33 +0000 (10:39 +0000)
NEWS
ext/soap/soap.c
ext/soap/tests/bugs/bug42151.phpt [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index d5f3c409d99b409690512d0c54292f74910bf259..e17841036ad9d1fc5f62ac661f0330f5c9f887c2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -70,6 +70,8 @@ PHP                                                                        NEWS
 - Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory 
   already exists). (Pierre)
 
+- Fixed bug #42151 (__destruct functions not called after catching a SoapFault
+  exception). (Dmitry)
 - Fixed bug #42142 (substr_replace() returns FALSE when length > string
   length). (Ilia) 
 - Fixed bug #42135 (Second call of session_start() causes creation of SID).
index e3584b134c9d47192c77e8e644e63123ca0981b4..1eb3abe6385e523bbab40c5cb416a75612f8739b 100644 (file)
@@ -2067,6 +2067,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
 #ifdef va_copy
                        va_list argcopy;
 #endif
+                       zend_object_store_bucket *old_objects;
                        int old = PG(display_errors);
 
                        INIT_ZVAL(outbuf);
@@ -2093,6 +2094,8 @@ static void soap_error_handler(int error_num, const char *error_filename, const
                        INIT_PZVAL(exception);
                        zend_throw_exception_object(exception TSRMLS_CC);
 
+                       old_objects = EG(objects_store).object_buckets;
+                       EG(objects_store).object_buckets = NULL;
                        PG(display_errors) = 0;
                        zend_try {
                                call_old_error_handler(error_num, error_filename, error_lineno, format, args);
@@ -2101,6 +2104,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
                                EG(in_execution) = _old_in_execution;
                                EG(current_execute_data) = _old_current_execute_data;
                        } zend_end_try();
+                       EG(objects_store).object_buckets = old_objects;
                        PG(display_errors) = old;
                        zend_bailout();
                } else {
diff --git a/ext/soap/tests/bugs/bug42151.phpt b/ext/soap/tests/bugs/bug42151.phpt
new file mode 100755 (executable)
index 0000000..7f7a87b
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+Bug #42151 __destruct functions not called after catching a SoapFault exception
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+class foo {
+       function __construct(){
+               $foo = @ new SoapClient('httpx://');
+       }
+       function __destruct(){
+               echo 'I never get executed.' . "\n";
+       }
+}
+class bar {
+       function __destruct(){
+               echo 'I don\'t get executed either.' . "\n";
+       }
+}
+try {
+       $bar = new bar();
+       $foo = new foo();
+} catch (Exception $e){
+       echo $e->getMessage() . "\n";
+}
+echo "ok\n";
+?>
+--EXPECT--
+SOAP-ERROR: Parsing WSDL: Couldn't load from 'httpx://'
+ok
+I don't get executed either.