xref: /php-src/ext/soap/tests/gh16318.phpt (revision 6ff4a2d7)
1--TEST--
2GH-16318 (Recursive array segfaults soap encoding)
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7
8// SOAP-ENC array
9$tmp =& $test1;
10$test1[] = $tmp;
11
12// map array
13$test2 = [];
14$test2["a"] = "a";
15$test2[] =& $test2;
16
17class TestSoapClient extends SoapClient {
18    public function __doRequest(string $request, string $location, string $action, int $version, bool $oneWay = false): ?string
19    {
20        die($request);
21    }
22}
23$client = new TestSoapClient(NULL,array("location"=>"test://","uri"=>"http://soapinterop.org/","trace"=>1,"exceptions"=>0));
24
25foreach ([$test1, $test2] as $test) {
26    try {
27        $client->__soapCall("echoStructArray", array($test), array("soapaction"=>"http://soapinterop.org/","uri"=>"http://soapinterop.org/"));
28    } catch (ValueError $e) {
29        echo $e->getMessage(), "\n";
30    }
31}
32
33?>
34--EXPECT--
35Recursive array cannot be encoded
36Recursive array cannot be encoded
37