php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79191 Error in SoapClient creation leads to DOMDocument::save() not working
Submitted: 2020-01-29 13:57 UTC Modified: 2020-02-03 23:15 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sebastian@php.net Assigned: cmb (profile)
Status: Closed Package: *XML functions
PHP Version: 7.4.2 OS: Irrelevant
Private report: No CVE-ID: None
 [2020-01-29 13:57 UTC] 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)

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-29 14:13 UTC] 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-30 00:52 UTC] 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-30 11:24 UTC] 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 11:26 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2020-02-03 22:29 UTC] cmb@php.net
-Package: DOM XML related +Package: *XML functions
 [2020-02-03 23:14 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=fe1bfb78d65d28dd151da417477a0cee51de8afb
Log: Fix #79191: Error in SoapClient ctor disables DOMDocument::save()
 [2020-02-03 23:14 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2020-02-03 23:15 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 14 05:01:28 2024 UTC