Bug #78150 [Ver->Dup]: Unable to use XMLWriter after a SoapFault-Exception

From: Date: Mon, 15 Jun 2020 15:26:45 +0000
Subject: Bug #78150 [Ver->Dup]: Unable to use XMLWriter after a SoapFault-Exception
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227496@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78150&edit=1 ID: 78150 Updated by: cmb@php.net Reported by: n dot scheer at binserv dot de Summary: Unable to use XMLWriter after a SoapFault-Exception -Status: Verified +Status: Duplicate Type: Bug Package: XML Writer Operating System: Centos 7.6 x64 PHP Version: 7.3.6 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Closing as duplicate of bug #79191 (fixed as of PHP 7.3.15 and 7.4.3, respectively). Previous Comments: ------------------------------------------------------------------------ [2019-06-28 09:19:45] n dot scheer at binserv dot de Further testing shows, that registering an exception handler is not needed to trigger the behavior. In fact, it suffices to have a SoapFault-Exception thrown/catched - XMLWriter will refuse to write xml files afterwards. So the reproduction code can be narrowed down to: <?php @unlink( '/tmp/err.xml' ); try { new SoapClient( 'https://localhost/', [] ); } catch ( Throwable $e ) { echo "exception catched\n"; } $xw = new XMLWriter(); var_dump( $xw ); $xw->openURI( '/tmp/err.xml' ); $xw->startDocument( '1.0', 'UTF-8' ); $xw->startElement( 'error' ); $xw->endElement(); if ( $xw->endDocument() ) { echo "error xml written\n"; } else { echo "unable to write error xml\n"; } ------------------------------------------------------------------------ [2019-06-12 15:28:54] n dot scheer at binserv dot de PHP 7.2.19 shows this behaviour as well ------------------------------------------------------------------------ [2019-06-12 15:23:46] n dot scheer at binserv dot de Description: ------------ We currently use an exception-handler that writes information about the exception to a xml file. Recently we noticed, that sometimes the resulting xml file is just empty - without any error message being triggered. I was able to reduce the code to the example below. There's no obvious reason why the script should not be able to write the xml content. Interesting thing is: Throwing an exception manually does not trigger this behavior. Test script: --------------- <?php @unlink( '/tmp/err.xml' ); function exception_handler( Throwable $exception ) { echo "exception handler called\n"; $xw = new XMLWriter(); var_dump( $xw ); $xw->openURI( '/tmp/err.xml' ); $xw->startDocument( '1.0', 'UTF-8' ); $xw->startElement( 'error' ); $xw->endElement(); $returnValue = $xw->endDocument(); if ( $returnValue === false ) { die( "unable to write error xml\n" ); } die("error xml written\n"); } # function exception_handler(...) set_exception_handler( 'exception_handler' ); new SoapClient( 'https://localhost/', [] ); #throw new Exception("dummy"); Expected result: ---------------- exception handler called object(XMLWriter)#1 (0) { } error xml written (/tmp/err.xml exists with content <?xml version="1.0" encoding="UTF-8"?> <error/>) Actual result: -------------- exception handler called object(XMLWriter)#1 (0) { } unable to write error xml (/tmp/err.xml exists but is empty) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78150&edit=1

« previous php.bugs (#227496) next »