|
| 1 | +--TEST-- |
| 2 | +Bug #51561 (SoapServer with a extended class and using sessions, lost the setPersistence()) |
| 3 | +--EXTENSIONS-- |
| 4 | +soap |
| 5 | +--SKIPIF-- |
| 6 | +<?php |
| 7 | + if (!file_exists(__DIR__ . "/../../../../sapi/cli/tests/php_cli_server.inc")) { |
| 8 | + echo "skip sapi/cli/tests/php_cli_server.inc required but not found"; |
| 9 | + } |
| 10 | +?> |
| 11 | +--FILE-- |
| 12 | +<?php |
| 13 | + |
| 14 | +include __DIR__ . "/../../../../sapi/cli/tests/php_cli_server.inc"; |
| 15 | + |
| 16 | +$args = ["-d", "extension_dir=" . ini_get("extension_dir"), "-d", "extension=" . (substr(PHP_OS, 0, 3) == "WIN" ? "php_" : "") . "soap." . PHP_SHLIB_SUFFIX]; |
| 17 | +if (php_ini_loaded_file()) { |
| 18 | + // Necessary such that it works from a development directory in which case extension_dir might not be the real extension dir |
| 19 | + $args[] = "-c"; |
| 20 | + $args[] = php_ini_loaded_file(); |
| 21 | +} |
| 22 | +$code = "session_start();" . |
| 23 | + "require_once '" . __DIR__ . "/bug51561.inc';" . |
| 24 | + <<<'PHP' |
| 25 | + class Server extends Server2 { |
| 26 | + private $value; |
| 27 | + public function setValue($param) { $this->value = $param; } |
| 28 | + public function getValue() { return $this->value; } |
| 29 | + } |
| 30 | + $server = new SoapServer(null, array('uri' => "blablabla.com",'encoding' => "ISO-8859-1",'soap_version' => SOAP_1_2)); |
| 31 | + $server->setClass("Server"); |
| 32 | + $server->setPersistence(SOAP_PERSISTENCE_SESSION); |
| 33 | + $server->handle(); |
| 34 | + PHP; |
| 35 | + |
| 36 | +php_cli_server_start($code, null, $args); |
| 37 | + |
| 38 | +$cli = new SoapClient(null, array('location' => "http://".PHP_CLI_SERVER_ADDRESS, 'uri' => "blablabla.com",'encoding' => "ISO-8859-1",'soap_version' => SOAP_1_2)); |
| 39 | +$cli->setValue(100); |
| 40 | +$response = $cli->getValue(); |
| 41 | +echo "Get = ".$response; |
| 42 | + |
| 43 | +?> |
| 44 | +--EXPECTF-- |
| 45 | +Fatal error: Uncaught SoapFault exception: [env:Receiver] SoapServer class was deserialized from the session prior to loading the class passed to SoapServer::setClass(). Start the session after loading all classes to resolve this issue. in %s:%d |
| 46 | +Stack trace: |
| 47 | +#0 %s(%d): SoapClient->__call('getValue', Array) |
| 48 | +#1 {main} |
| 49 | + thrown in %s on line %d |
0 commit comments