Skip to content

Commit 215ed1b

Browse files
committed
soap: add test with persistent session
1 parent 1b2bde4 commit 215ed1b

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
--TEST--
2+
SoapServer::handle() must not free the session persisted object when a header handler returns a SoapFault
3+
--EXTENSIONS--
4+
soap
5+
session
6+
--INI--
7+
session.save_handler=files
8+
session.use_cookies=0
9+
soap.wsdl_cache_enabled=0
10+
--FILE--
11+
<?php
12+
class Handler
13+
{
14+
public $property = 'kept';
15+
16+
public function __destruct()
17+
{
18+
echo 'Handler::__destruct', PHP_EOL;
19+
}
20+
21+
public function myHeader($x)
22+
{
23+
return new SoapFault('Server', 'header fault');
24+
}
25+
26+
public function existing()
27+
{
28+
return 'ok';
29+
}
30+
}
31+
32+
ini_set('session.save_path', __DIR__);
33+
session_id('soapPersistenceHeaderFault');
34+
session_start();
35+
36+
$server = new SoapServer(null, ['uri' => 'http://test-uri']);
37+
$server->setClass('Handler');
38+
$server->setPersistence(SOAP_PERSISTENCE_SESSION);
39+
40+
$request = <<<XML
41+
<?xml version="1.0" encoding="UTF-8"?>
42+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
43+
<SOAP-ENV:Header><ns1:myHeader xmlns:ns1="http://test-uri"><x>1</x></ns1:myHeader></SOAP-ENV:Header>
44+
<SOAP-ENV:Body><ns1:existing xmlns:ns1="http://test-uri"/></SOAP-ENV:Body>
45+
</SOAP-ENV:Envelope>
46+
XML;
47+
48+
$server->handle($request);
49+
50+
echo 'after handle', PHP_EOL;
51+
var_dump($_SESSION['_bogus_session_name']->property);
52+
echo 'end', PHP_EOL;
53+
?>
54+
--CLEAN--
55+
<?php
56+
@unlink(__DIR__ . '/sess_soapPersistenceHeaderFault');
57+
?>
58+
--EXPECT--
59+
<?xml version="1.0" encoding="UTF-8"?>
60+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>header fault</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
61+
after handle
62+
string(4) "kept"
63+
end
64+
Handler::__destruct

0 commit comments

Comments
 (0)