Skip to content

Commit 685b129

Browse files
duncan3dcnikic
authored andcommitted
Fix bug #73538
Remove any previous default headers and replace with the specified ones, as documented, and as is the case when a single header is passed.
1 parent bc30206 commit 685b129

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ PHP NEWS
3737
. Fixed bug #73087, #61183, #71494 (Memory corruption in bindParam).
3838
(Dorin Marcoci)
3939

40+
- Soap:
41+
. Fixed bug #73538 (SoapClient::__setSoapHeaders doesn't overwrite SOAP
42+
headers). (duncan3dc)
43+
4044
- SPL:
4145
. Fixed bug #73423 (Reproducible crash with GDB backtrace). (Laruence)
4246

ext/soap/soap.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3209,12 +3209,8 @@ PHP_METHOD(SoapClient, __setSoapHeaders)
32093209
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
32103210
zend_hash_str_del(Z_OBJPROP_P(this_ptr), "__default_headers", sizeof("__default_headers")-1);
32113211
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
3212-
zval *default_headers;
3213-
32143212
verify_soap_headers_array(Z_ARRVAL_P(headers));
3215-
if ((default_headers = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__default_headers", sizeof("__default_headers")-1)) == NULL) {
3216-
add_property_zval(this_ptr, "__default_headers", headers);
3217-
}
3213+
add_property_zval(this_ptr, "__default_headers", headers);
32183214
} else if (Z_TYPE_P(headers) == IS_OBJECT &&
32193215
instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry)) {
32203216
zval default_headers;

ext/soap/tests/bugs/bug73538.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
SOAP: SoapClient::__setHeaders array overrides previous headers
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
$client = new SoapClient(null, [
9+
"location" => "test://",
10+
"uri" => "test://",
11+
"exceptions" => false,
12+
"trace" => true,
13+
]);
14+
$client->__setSoapHeaders(new \SoapHeader('ns', 'Header', ['something' => 1]));
15+
$client->__setSoapHeaders(new \SoapHeader('ns', 'Header', ['something' => 2]));
16+
$client->test();
17+
echo $client->__getLastRequest();
18+
19+
$client = new SoapClient(null, [
20+
"location" => "test://",
21+
"uri" => "test://",
22+
"exceptions" => false,
23+
"trace" => true,
24+
]);
25+
$client->__setSoapHeaders([new \SoapHeader('ns', 'Header', ['something' => 1])]);
26+
$client->__setSoapHeaders([new \SoapHeader('ns', 'Header', ['something' => 2])]);
27+
$client->test();
28+
echo $client->__getLastRequest();
29+
30+
?>
31+
--EXPECT--
32+
<?xml version="1.0" encoding="UTF-8"?>
33+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="test://" xmlns:ns2="ns" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header><ns2:Header><item><key>something</key><value>2</value></item></ns2:Header></SOAP-ENV:Header><SOAP-ENV:Body><ns1:test/></SOAP-ENV:Body></SOAP-ENV:Envelope>
34+
<?xml version="1.0" encoding="UTF-8"?>
35+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="test://" xmlns:ns2="ns" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header><ns2:Header><item><key>something</key><value>2</value></item></ns2:Header></SOAP-ENV:Header><SOAP-ENV:Body><ns1:test/></SOAP-ENV:Body></SOAP-ENV:Envelope>

0 commit comments

Comments
 (0)