Bug #79191 [Opn->Ver]: Error in SoapClient creation leads to DOMDocument::save() not working

From: Date: Thu, 30 Jan 2020 11:26:33 +0000
Subject: Bug #79191 [Opn->Ver]: Error in SoapClient creation leads to DOMDocument::save() not working
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225249@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79191&edit=1 ID: 79191 Updated by: cmb@php.net Reported by: sebastian@php.net Summary: Error in SoapClient creation leads to DOMDocument::save() not working -Status: Open +Status: Verified Type: Bug Package: DOM XML related Operating System: Irrelevant PHP Version: 7.4.2 Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2020-01-30 11:24:58] cmb@php.net The following pull request has been associated: Patch Name: Fix #79191: Error in SoapClient ctor disables DOMDocument::save() On GitHub: https://github.com/php/php-src/pull/5133 Patch: https://github.com/php/php-src/pull/5133.patch ------------------------------------------------------------------------ [2020-01-30 00:52:29] daverandom@php.net This is caused by the SoapClient constructor invoking zend_bailout() when any exception other than a SoapFault is encountered [1]. This results in unclean_shutdown being set, which prevents the write operation taking place [2]. The logic in SoapClient is clearly wrong here, I suspect it shouldn't be directly responsible for invoking zend_bailout() at all but I'm not 100% certain of that. [1] https://github.com/php/php-src/blob/acc616c455c007857e6aeb006e3e9aa63565c461/ext/soap/soap.c#L106-L128 [2] https://github.com/php/php-src/blob/acc616c455c007857e6aeb006e3e9aa63565c461/ext/libxml/libxml.c#L385-L387 ------------------------------------------------------------------------ [2020-01-29 14:13:19] sebastian@php.net Please note that DOMDocument::saveXml() works, so the document is correctly stored in the DOMDocument object. It is "just" that DOMDocument::save() no longer works after an error in SoapClient occurred. ------------------------------------------------------------------------ [2020-01-29 13:57:55] sebastian@php.net Description: ------------ When the creation of a SoapClient object fails then DOMDocument::save() no longer works. This issue came up in the context of PHPUnit: * https://github.com/sebastianbergmann/php-code-coverage/issues/692 * https://github.com/sebastianbergmann/php-code-coverage/pull/721 * https://github.com/sebastianbergmann/php-code-coverage/issues/692#issuecomment-579761041 A minimal and self-contained script that reproduces the issue is provided below. Test script: --------------- <?php try { new \SoapClient('does-not-exist.wsdl'); } catch (Throwable $t) { } $dom = new DOMDocument; $dom->loadxml('<?xml version="1.0" ?><root />'); var_dump($dom->save('/tmp/test.xml')); Expected result: ---------------- int(number of bytes written) Actual result: -------------- bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79191&edit=1

« previous php.bugs (#225249) next »