Bug #78150 [Com]: Unable to use XMLWriter in Exception-Handler

From: Date: Wed, 12 Jun 2019 15:28:54 +0000
Subject: Bug #78150 [Com]: Unable to use XMLWriter in Exception-Handler
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221247@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 Comment by: n dot scheer at binserv dot de Reported by: n dot scheer at binserv dot de Summary: Unable to use XMLWriter in Exception-Handler Status: Open Type: Bug Package: XML Writer Operating System: Centos 7.6 x64 PHP Version: 7.3.6 Block user comment: N Private report: N New Comment: PHP 7.2.19 shows this behaviour as well Previous Comments: ------------------------------------------------------------------------ [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 (#221247) next »