xref: /PHP-8.2/ext/soap/tests/bugs/bug37013.phpt (revision 7f2f0c00)
1--TEST--
2Bug #37013 (server hangs when returning circular object references)
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9$request = <<<REQUEST
10<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
11xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
12xmlns:xsd="http://www.w3.org/2001/XMLSchema"
13xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
14
15<soapenv:Body>
16<ns2:getThingWithParent
17 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
18 xmlns:ns2="urn:test.soapserver#"/>
19</soapenv:Body>
20
21</soapenv:Envelope>
22REQUEST;
23
24
25class ThingWithParent
26{
27 var $parent;
28 var $id;
29 var $children;
30 function __construct( $id, $parent ) {
31  $this->id = $id;
32  $this->parent = $parent;
33 }
34}
35
36
37class MultiRefTest {
38 public function getThingWithParent() {
39  $p = new ThingWithParent( 1, null );
40  $p2 = new ThingWithParent( 2, $p );
41  $p3 = new ThingWithParent( 3, $p );
42
43  $p->children = array( $p2, $p3 );
44
45  return $p2;
46 }
47}
48
49
50$server = new SoapServer(__DIR__."/bug37013.wsdl");
51$server->setClass( "MultiRefTest");
52$server->handle( $request );
53?>
54--EXPECT--
55<?xml version="1.0" encoding="UTF-8"?>
56<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:test.soapserver#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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:Body><ns1:getThingWithParentResponse><result id="ref1" xsi:type="SOAP-ENC:Struct"><parent id="ref2" xsi:type="SOAP-ENC:Struct"><parent xsi:nil="true"/><id xsi:type="xsd:int">1</id><children SOAP-ENC:arrayType="SOAP-ENC:Struct[2]" xsi:type="SOAP-ENC:Array"><item href="#ref1"/><item xsi:type="SOAP-ENC:Struct"><parent href="#ref2"/><id xsi:type="xsd:int">3</id><children xsi:nil="true"/></item></children></parent><id xsi:type="xsd:int">2</id><children xsi:nil="true"/></result></ns1:getThingWithParentResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
57