Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ PHP NEWS
- SOAP:
. Fixed use of uninitialized func in do_request() on OOM bailout.
(David Carlier)
. Fixed SoapClient writing to the output headers array, which the exception
trace shares, after decoding a response header threw an exception.
(Valery Ivashchanka)

- Session:
. Fixed session data loss in the files save handler when writing the session
Expand Down
5 changes: 5 additions & 0 deletions ext/soap/php_packet_soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
smart_str_free(&key);
}
master_to_zval_with_doc_cleanup(&val, enc, trav, response);
if (EG(exception)) {
/* The trace of the exception holds a copy of the output headers array */
zval_ptr_dtor(&val);
break;
}
add_assoc_zval(soap_headers, (char*)trav->name, &val);
}
trav = trav->next;
Expand Down
64 changes: 64 additions & 0 deletions ext/soap/tests/output_headers_exception.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
--TEST--
SoapClient stops decoding response headers after an exception
--EXTENSIONS--
soap
--INI--
zend.exception_ignore_args=0
--FILE--
<?php
class TestSoapClient extends SoapClient {
public function __doRequest($request, $location, $action, $version, $oneWay = false, ?string $uriParserClass = null): string {
return <<<'XML'
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<h1 xsi:type="xsd:int">1</h1>
<h2 xsi:type="xsd:string">a</h2>
<h3 xsi:type="xsd:int">3</h3>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:testResponse xmlns:ns1="urn:test">
<return xsi:type="xsd:int">1</return>
</ns1:testResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML;
}
}

function string_from_xml($xml) {
throw new Exception("string_from_xml failed");
}

$client = new TestSoapClient(null, [
'location' => 'test://',
'uri' => 'urn:test',
'typemap' => [[
'type_ns' => 'http://www.w3.org/2001/XMLSchema',
'type_name' => 'string',
'from_xml' => 'string_from_xml',
]],
]);

$headers = [];
try {
$client->__soapCall('test', [], null, null, $headers);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
// The trace holds the output headers as they were when the exception was thrown
var_dump($e->getTrace()[1]['args'][4]);
}
var_dump($headers);
?>
--EXPECT--
string_from_xml failed
array(1) {
["h1"]=>
int(1)
}
array(1) {
["h1"]=>
int(1)
}
Loading