mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fixed bug #36575 (SOAP: Incorrect complex type instantiation with hierarchies)
This commit is contained in:
parent
5c1dbf51af
commit
622347bd8c
8 changed files with 223 additions and 38 deletions
2
NEWS
2
NEWS
|
@ -37,6 +37,8 @@ PHP NEWS
|
|||
(Mike)
|
||||
- Fixed crash with DOMImplementation::createDocumentType("name:"). (Mike)
|
||||
- Fixed bug #36599 (DATE_W3C format constant incorrect). (Derick)
|
||||
- Fixed bug #36575 (SOAP: Incorrect complex type instantiation with
|
||||
hierarchies). (Dmitry)
|
||||
- Fixed bug #36510 (strtotime() fails to parse date strings with tabs). (Ilia,
|
||||
Derick)
|
||||
- Fixed bug #36459 (Incorrect adding PHPSESSID to links, which contains \r\n).
|
||||
|
|
|
@ -246,6 +246,23 @@ void whiteSpace_collapse(char* str)
|
|||
*pos = '\0';
|
||||
}
|
||||
|
||||
static encodePtr find_encoder_by_type_name(sdlPtr sdl, const char *type)
|
||||
{
|
||||
if (sdl && sdl->encoders) {
|
||||
HashPosition pos;
|
||||
encodePtr *enc;
|
||||
|
||||
for (zend_hash_internal_pointer_reset_ex(sdl->encoders, &pos);
|
||||
zend_hash_get_current_data_ex(sdl->encoders, (void **) &enc, &pos) == SUCCESS;
|
||||
zend_hash_move_forward_ex(sdl->encoders, &pos)) {
|
||||
if (strcmp((*enc)->details.type_str, type) == 0) {
|
||||
return *enc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xmlNodePtr master_to_xml(encodePtr encode, zval *data, int style, xmlNodePtr parent)
|
||||
{
|
||||
xmlNodePtr node = NULL;
|
||||
|
@ -328,7 +345,12 @@ xmlNodePtr master_to_xml(encodePtr encode, zval *data, int style, xmlNodePtr par
|
|||
encodePtr enc = get_encoder(SOAP_GLOBAL(sdl), SOAP_GLOBAL(sdl)->target_ns, type_name);
|
||||
if (enc) {
|
||||
encode = enc;
|
||||
}
|
||||
} else if (SOAP_GLOBAL(sdl)) {
|
||||
enc = find_encoder_by_type_name(SOAP_GLOBAL(sdl), type_name);
|
||||
if (enc) {
|
||||
encode = enc;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -717,7 +739,7 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo
|
|||
|
||||
zval_copy_ctor(&tmp);
|
||||
convert_to_string(&tmp);
|
||||
str = php_escape_html_entities(Z_STRVAL(tmp), Z_STRLEN(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
|
||||
str = php_escape_html_entities(Z_STRVAL(tmp), Z_STRLEN(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
|
||||
zval_dtor(&tmp);
|
||||
}
|
||||
|
||||
|
@ -758,7 +780,7 @@ static xmlNodePtr to_xml_base64(encodeTypePtr type, zval *data, int style, xmlNo
|
|||
xmlAddChild(parent, ret);
|
||||
FIND_ZVAL_NULL(data, ret, style);
|
||||
|
||||
if (Z_TYPE_P(data) == IS_STRING) {
|
||||
if (Z_TYPE_P(data) == IS_STRING) {
|
||||
str = php_base64_encode((unsigned char*)Z_STRVAL_P(data), Z_STRLEN_P(data), &str_len);
|
||||
xmlNodeSetContentLen(ret, str, str_len);
|
||||
efree(str);
|
||||
|
@ -791,14 +813,14 @@ static xmlNodePtr to_xml_hexbin(encodeTypePtr type, zval *data, int style, xmlNo
|
|||
xmlAddChild(parent, ret);
|
||||
FIND_ZVAL_NULL(data, ret, style);
|
||||
|
||||
if (Z_TYPE_P(data) != IS_STRING) {
|
||||
if (Z_TYPE_P(data) != IS_STRING) {
|
||||
tmp = *data;
|
||||
zval_copy_ctor(&tmp);
|
||||
convert_to_string(&tmp);
|
||||
data = &tmp;
|
||||
}
|
||||
str = (unsigned char *) safe_emalloc(Z_STRLEN_P(data) * 2, sizeof(char), 1);
|
||||
|
||||
|
||||
for (i = j = 0; i < Z_STRLEN_P(data); i++) {
|
||||
str[j++] = hexconvtab[((unsigned char)Z_STRVAL_P(data)[i]) >> 4];
|
||||
str[j++] = hexconvtab[((unsigned char)Z_STRVAL_P(data)[i]) & 15];
|
||||
|
@ -1157,7 +1179,7 @@ static void model_to_zval_object(zval *ret, sdlContentModelPtr model, xmlNodePtr
|
|||
add_next_index_zval(array, val);
|
||||
} while ((node = get_node(node->next, model->u.element->name)) != NULL);
|
||||
val = array;
|
||||
} else if ((SOAP_GLOBAL(features) & SOAP_SINGLE_ELEMENT_ARRAYS) &&
|
||||
} else if ((SOAP_GLOBAL(features) & SOAP_SINGLE_ELEMENT_ARRAYS) &&
|
||||
(model->max_occurs == -1 || model->max_occurs > 1)) {
|
||||
zval *array;
|
||||
|
||||
|
@ -1200,7 +1222,7 @@ static void model_to_zval_object(zval *ret, sdlContentModelPtr model, xmlNodePtr
|
|||
}
|
||||
|
||||
/* Struct encode/decode */
|
||||
static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
|
||||
static zval *to_zval_object_ex(encodeTypePtr type, xmlNodePtr data, zend_class_entry *pce)
|
||||
{
|
||||
zval *ret;
|
||||
xmlNodePtr trav;
|
||||
|
@ -1210,7 +1232,9 @@ static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
|
|||
zend_bool redo_any = 0;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (SOAP_GLOBAL(class_map) && type->type_str) {
|
||||
if (pce) {
|
||||
ce = pce;
|
||||
} else if (SOAP_GLOBAL(class_map) && type->type_str) {
|
||||
zval **classname;
|
||||
zend_class_entry *tmp;
|
||||
|
||||
|
@ -1253,7 +1277,20 @@ static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
|
|||
sdlType->encode->details.sdl_type->kind != XSD_TYPEKIND_SIMPLE &&
|
||||
sdlType->encode->details.sdl_type->kind != XSD_TYPEKIND_LIST &&
|
||||
sdlType->encode->details.sdl_type->kind != XSD_TYPEKIND_UNION) {
|
||||
ret = master_to_zval_int(sdlType->encode, data);
|
||||
|
||||
if (ce != ZEND_STANDARD_CLASS_DEF_PTR &&
|
||||
sdlType->encode->to_zval == sdl_guess_convert_zval &&
|
||||
sdlType->encode->details.sdl_type != NULL &&
|
||||
(sdlType->encode->details.sdl_type->kind == XSD_TYPEKIND_COMPLEX ||
|
||||
sdlType->encode->details.sdl_type->kind == XSD_TYPEKIND_RESTRICTION ||
|
||||
sdlType->encode->details.sdl_type->kind == XSD_TYPEKIND_EXTENSION) &&
|
||||
(sdlType->encode->details.sdl_type->encode == NULL ||
|
||||
(sdlType->encode->details.sdl_type->encode->details.type != IS_ARRAY &&
|
||||
sdlType->encode->details.sdl_type->encode->details.type != SOAP_ENC_ARRAY))) {
|
||||
ret = to_zval_object_ex(&sdlType->encode->details, data, ce);
|
||||
} else {
|
||||
ret = master_to_zval_int(sdlType->encode, data);
|
||||
}
|
||||
FIND_XML_NULL(data, ret);
|
||||
if (get_zval_property(ret, "any" TSRMLS_CC) != NULL) {
|
||||
unset_zval_property(ret, "any" TSRMLS_CC);
|
||||
|
@ -1280,7 +1317,7 @@ static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
|
|||
if (sdlType->model) {
|
||||
model_to_zval_object(ret, sdlType->model, data, sdl TSRMLS_CC);
|
||||
if (redo_any && get_zval_property(ret, "any" TSRMLS_CC) == NULL) {
|
||||
model_to_zval_any(ret, data->children TSRMLS_CC);
|
||||
model_to_zval_any(ret, data->children TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
if (sdlType->attributes) {
|
||||
|
@ -1358,6 +1395,12 @@ static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
|
||||
{
|
||||
return to_zval_object_ex(type, data, NULL);
|
||||
}
|
||||
|
||||
|
||||
static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval *object, int style, int strict TSRMLS_DC)
|
||||
{
|
||||
switch (model->kind) {
|
||||
|
@ -1598,7 +1641,7 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo
|
|||
zval *tmp = get_zval_property(data, "_" TSRMLS_CC);
|
||||
if (tmp) {
|
||||
xmlParam = master_to_xml(enc, tmp, style, parent);
|
||||
} else if (prop == NULL) {
|
||||
} else if (prop == NULL) {
|
||||
xmlParam = master_to_xml(enc, data, style, parent);
|
||||
} else {
|
||||
xmlParam = xmlNewNode(NULL,"BOGUS");
|
||||
|
@ -1693,7 +1736,7 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo
|
|||
an implicit schema. Otherwise, use form.
|
||||
*/
|
||||
if ((*attr)->namens &&
|
||||
(!strncmp((*attr)->namens, XML_NAMESPACE, sizeof(XML_NAMESPACE)) ||
|
||||
(!strncmp((*attr)->namens, XML_NAMESPACE, sizeof(XML_NAMESPACE)) ||
|
||||
(*attr)->form == XSD_FORM_QUALIFIED)) {
|
||||
xmlNsPtr nsp = encode_add_ns(xmlParam, (*attr)->namens);
|
||||
|
||||
|
@ -2790,7 +2833,7 @@ static zval *to_zval_any(encodeTypePtr type, xmlNodePtr data)
|
|||
}
|
||||
|
||||
static xmlNodePtr to_xml_any(encodeTypePtr type, zval *data, int style, xmlNodePtr parent)
|
||||
{
|
||||
{
|
||||
xmlNodePtr ret;
|
||||
|
||||
if (Z_TYPE_P(data) == IS_STRING) {
|
||||
|
@ -3157,7 +3200,7 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS
|
|||
|
||||
if (different || count == 0) {
|
||||
smart_str_appendl(type, "xsd:anyType", 11);
|
||||
return get_conversion(XSD_ANYTYPE);
|
||||
return get_conversion(XSD_ANYTYPE);
|
||||
} else {
|
||||
encodePtr enc;
|
||||
|
||||
|
|
|
@ -2201,6 +2201,7 @@ PHP_METHOD(SoapClient, SoapClient)
|
|||
|
||||
MAKE_STD_ZVAL(class_map);
|
||||
*class_map = **tmp;
|
||||
INIT_PZVAL(class_map);
|
||||
zval_copy_ctor(class_map);
|
||||
#ifdef ZEND_ENGINE_2
|
||||
class_map->refcount--;
|
||||
|
|
|
@ -49,7 +49,7 @@ class LogOffEvent {
|
|||
public $audienceMemberId;
|
||||
public $timestamp;
|
||||
public $smokeStatus;
|
||||
public $callInititator;
|
||||
public $callInitiator;
|
||||
|
||||
function __construct($audienceMemberId, $timestamp, $smokeStatus) {
|
||||
$this->audienceMemberId = $audienceMemberId;
|
||||
|
@ -98,6 +98,15 @@ object(IVREvents)#%d (6) {
|
|||
int(101)
|
||||
["messageId"]=>
|
||||
int(12345)
|
||||
["source"]=>
|
||||
string(3) "IVR"
|
||||
["logOnEvent"]=>
|
||||
object(LogOnEvent)#%d (2) {
|
||||
["audienceMemberId"]=>
|
||||
int(34567)
|
||||
["timestamp"]=>
|
||||
string(25) "2005-11-08T11:22:07+03:00"
|
||||
}
|
||||
["logOffEvent"]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
|
@ -123,13 +132,4 @@ object(IVREvents)#%d (6) {
|
|||
string(3) "IVR"
|
||||
}
|
||||
}
|
||||
["logOnEvent"]=>
|
||||
object(LogOnEvent)#%d (2) {
|
||||
["audienceMemberId"]=>
|
||||
int(34567)
|
||||
["timestamp"]=>
|
||||
string(25) "2005-11-08T11:22:07+03:00"
|
||||
}
|
||||
["source"]=>
|
||||
string(3) "IVR"
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class LogOffEvent {
|
|||
public $audienceMemberId;
|
||||
public $timestamp;
|
||||
public $smokeStatus;
|
||||
public $callInititator;
|
||||
public $callInitiator;
|
||||
|
||||
function __construct($audienceMemberId, $timestamp, $smokeStatus) {
|
||||
$this->audienceMemberId = $audienceMemberId;
|
||||
|
@ -99,6 +99,18 @@ object(IVREvents)#%d (6) {
|
|||
int(101)
|
||||
["messageId"]=>
|
||||
int(12345)
|
||||
["source"]=>
|
||||
string(3) "IVR"
|
||||
["logOnEvent"]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(LogOnEvent)#10 (2) {
|
||||
["audienceMemberId"]=>
|
||||
int(34567)
|
||||
["timestamp"]=>
|
||||
string(25) "2005-11-08T11:22:07+03:00"
|
||||
}
|
||||
}
|
||||
["logOffEvent"]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
|
@ -124,16 +136,4 @@ object(IVREvents)#%d (6) {
|
|||
string(3) "IVR"
|
||||
}
|
||||
}
|
||||
["logOnEvent"]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(LogOnEvent)#10 (2) {
|
||||
["audienceMemberId"]=>
|
||||
int(34567)
|
||||
["timestamp"]=>
|
||||
string(25) "2005-11-08T11:22:07+03:00"
|
||||
}
|
||||
}
|
||||
["source"]=>
|
||||
string(3) "IVR"
|
||||
}
|
||||
|
|
52
ext/soap/tests/bugs/bug36575.phpt
Executable file
52
ext/soap/tests/bugs/bug36575.phpt
Executable file
|
@ -0,0 +1,52 @@
|
|||
--TEST--
|
||||
Bug #36575 (Incorrect complex type instantiation with hierarchies)
|
||||
--SKIPIF--
|
||||
<?php require_once('skipif.inc'); ?>
|
||||
--INI--
|
||||
soap.wsdl_cache_enabled=0
|
||||
--FILE--
|
||||
<?php
|
||||
abstract class CT_A1 {
|
||||
public $var1;
|
||||
}
|
||||
|
||||
class CT_A2 extends CT_A1 {
|
||||
public $var2;
|
||||
}
|
||||
|
||||
class CT_A3 extends CT_A2 {
|
||||
public $var3;
|
||||
}
|
||||
|
||||
// returns A2 in WSDL
|
||||
function test( $a1 ) {
|
||||
$a3 = new CT_A3();
|
||||
$a3->var1 = $a1->var1;
|
||||
$a3->var2 = "var two";
|
||||
$a3->var3 = "var three";
|
||||
return $a3;
|
||||
}
|
||||
|
||||
$classMap = array("A1" => "CT_A1", "A2" => "CT_A2", "A3" => "CT_A3");
|
||||
|
||||
$client = new SoapClient(dirname(__FILE__)."/bug36575.wsdl", array("trace" => 1, "exceptions" => 0, "classmap" => $classMap));
|
||||
$a2 = new CT_A2();
|
||||
$a2->var1 = "one";
|
||||
$a2->var2 = "two";
|
||||
$client->test($a2);
|
||||
|
||||
$soapRequest = $client->__getLastRequest();
|
||||
|
||||
echo $soapRequest;
|
||||
|
||||
$server = new SoapServer(dirname(__FILE__)."/bug36575.wsdl", array("classmap" => $classMap));
|
||||
$server->addFunction("test");
|
||||
$server->handle($soapRequest);
|
||||
echo "ok\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:test.soap#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="urn:test.soap.types#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test><a1 xsi:type="ns2:A2"><var1 xsi:type="xsd:string">one</var1><var2 xsi:type="xsd:string">two</var2></a1></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="urn:test.soap#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="urn:test.soap.types#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:testResponse><result xsi:type="ns2:A3"><var1 xsi:type="xsd:string">one</var1><var2 xsi:type="xsd:string">var two</var2><var3 xsi:type="xsd:string">var three</var3></result></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
|
||||
ok
|
87
ext/soap/tests/bugs/bug36575.wsdl
Executable file
87
ext/soap/tests/bugs/bug36575.wsdl
Executable file
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<definitions name="shoppingcart"
|
||||
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:tns="urn:test.soap#" targetNamespace="urn:test.soap#"
|
||||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:types="urn:test.soap.types#">
|
||||
<!-- all datatypes will be imported to namespace types: -->
|
||||
<types>
|
||||
<xs:schema
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:tns="urn:test.soap.types#"
|
||||
targetNamespace="urn:test.soap.types#">
|
||||
|
||||
<xs:complexType name="A1">
|
||||
<xs:all>
|
||||
<xs:element name="var1" type="xs:string" nillable="true"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="A2">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="tns:A1">
|
||||
<xs:all>
|
||||
<xs:element name="var2" type="xs:string" nillable="true"/>
|
||||
</xs:all>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="A3">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="tns:A2">
|
||||
<xs:all>
|
||||
<xs:element name="var3" type="xs:string" nillable="true"/>
|
||||
</xs:all>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
||||
</types>
|
||||
|
||||
<message name="test-request">
|
||||
<part name="a1" type="types:A1"/>
|
||||
</message>
|
||||
<message name="test-response">
|
||||
<part name="result" type="types:A2"/>
|
||||
</message>
|
||||
|
||||
<portType name="catalog-porttype">
|
||||
<operation name="test" parameterOrder="a1">
|
||||
<input name="test-request" message="tns:test-request"/>
|
||||
<output name="test-response" message="tns:test-response"/>
|
||||
</operation>
|
||||
</portType>
|
||||
|
||||
<!-- @type doesn't like tns: -->
|
||||
<binding name="catalog-binding" type="tns:catalog-porttype">
|
||||
<soap:binding style="rpc"
|
||||
transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
|
||||
<operation name="test">
|
||||
<soap:operation soapAction="urn:test.soap#test"/>
|
||||
<input>
|
||||
<soap:body use="encoded" namespace="urn:test.soap#"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded" namespace="urn:test.soap#"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</output>
|
||||
</operation>
|
||||
</binding>
|
||||
|
||||
<service name="catalog">
|
||||
<!-- @binding doesn't like to be tns: -->
|
||||
<port name="catalog-port" binding="tns:catalog-binding">
|
||||
<soap:address location="xxxxxxxx"/>
|
||||
</port>
|
||||
</service>
|
||||
|
||||
</definitions>
|
|
@ -49,6 +49,6 @@ print_r($client->f());
|
|||
--EXPECT--
|
||||
B Object
|
||||
(
|
||||
[x] => 5
|
||||
[y] => 6
|
||||
[x] => 5
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue