com php-src: Fix bug #73538: NEWS ext/soap/soap.c ext/soap/tests/bugs/bug73538.phpt

From: Date: Sun, 20 Nov 2016 20:18:28 +0000
Subject: com php-src: Fix bug #73538: NEWS ext/soap/soap.c ext/soap/tests/bugs/bug73538.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95914@lists.php.net to get a copy of this message
Commit: 685b1292e9a050ec413662c4b7dcf69030d2010c Author: Craig Duncan <git@duncanc.co.uk> Sun, 20 Nov 2016 17:41:14 +0000 Committer: Nikita Popov <nikic@php.net> Sun, 20 Nov 2016 21:18:28 +0100 Parents: bc30206b8ad4975126bd36f48add769d0d9a221a Branches: PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=685b1292e9a050ec413662c4b7dcf69030d2010c Log: 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. Bugs: https://bugs.php.net/73538 Changed paths: M NEWS M ext/soap/soap.c A ext/soap/tests/bugs/bug73538.phpt Diff: diff --git a/NEWS b/NEWS index eafe8b6..3fe30bb 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,10 @@ PHP NEWS . Fixed bug #73087, #61183, #71494 (Memory corruption in bindParam). (Dorin Marcoci) +- Soap: + . Fixed bug #73538 (SoapClient::__setSoapHeaders doesn't overwrite SOAP + headers). (duncan3dc) + - SPL: . Fixed bug #73423 (Reproducible crash with GDB backtrace). (Laruence) diff --git a/ext/soap/soap.c b/ext/soap/soap.c index a217028..ffa9884 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -3209,12 +3209,8 @@ PHP_METHOD(SoapClient, __setSoapHeaders) if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) { zend_hash_str_del(Z_OBJPROP_P(this_ptr), "__default_headers", sizeof("__default_headers")-1); } else if (Z_TYPE_P(headers) == IS_ARRAY) { - zval *default_headers; - verify_soap_headers_array(Z_ARRVAL_P(headers)); - if ((default_headers = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__default_headers", sizeof("__default_headers")-1)) == NULL) { - add_property_zval(this_ptr, "__default_headers", headers); - } + add_property_zval(this_ptr, "__default_headers", headers); } else if (Z_TYPE_P(headers) == IS_OBJECT && instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry)) { zval default_headers; diff --git a/ext/soap/tests/bugs/bug73538.phpt b/ext/soap/tests/bugs/bug73538.phpt new file mode 100644 index 0000000..1bf0372 --- /dev/null +++ b/ext/soap/tests/bugs/bug73538.phpt @@ -0,0 +1,35 @@ +--TEST-- +SOAP: SoapClient::__setHeaders array overrides previous headers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$client = new SoapClient(null, [ + "location" => "test://", + "uri" => "test://", + "exceptions" => false, + "trace" => true, +]); +$client->__setSoapHeaders(new \SoapHeader('ns', 'Header', ['something' => 1])); +$client->__setSoapHeaders(new \SoapHeader('ns', 'Header', ['something' => 2])); +$client->test(); +echo $client->__getLastRequest(); + +$client = new SoapClient(null, [ + "location" => "test://", + "uri" => "test://", + "exceptions" => false, + "trace" => true, +]); +$client->__setSoapHeaders([new \SoapHeader('ns', 'Header', ['something' => 1])]); +$client->__setSoapHeaders([new \SoapHeader('ns', 'Header', ['something' => 2])]); +$client->test(); +echo $client->__getLastRequest(); + +?> +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<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> +<?xml version="1.0" encoding="UTF-8"?> +<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>

« previous php.cvs (#95914) next »