bug39815.phpt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. Bug #39815 (to_zval_double() in ext/soap/php_encoding.c is not locale-independent)
  3. --EXTENSIONS--
  4. soap
  5. --SKIPIF--
  6. <?php
  7. if (!@setlocale(LC_ALL, 'sv_SE', 'sv_SE.ISO8859-1')) die('skip sv_SE locale not available');
  8. if (!@setlocale(LC_ALL, 'en_US', 'en_US.ISO8859-1')) die('skip en_US locale not available');
  9. ?>
  10. --INI--
  11. precision=14
  12. soap.wsdl_cache_enabled=0
  13. --FILE--
  14. <?php
  15. function test(){
  16. return 123.456;
  17. }
  18. class LocalSoapClient extends SoapClient {
  19. function __construct($wsdl, $options) {
  20. parent::__construct($wsdl, $options);
  21. $this->server = new SoapServer($wsdl, $options);
  22. $this->server->addFunction('test');
  23. }
  24. function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
  25. ob_start();
  26. $this->server->handle($request);
  27. $response = ob_get_contents();
  28. ob_end_clean();
  29. return $response;
  30. }
  31. }
  32. $x = new LocalSoapClient(NULL,array('location'=>'test://',
  33. 'uri'=>'http://testuri.org',
  34. "trace"=>1));
  35. setlocale(LC_ALL,"sv_SE","sv_SE.ISO8859-1");
  36. var_dump($x->test());
  37. echo $x->__getLastResponse();
  38. setlocale(LC_ALL,"en_US","en_US.ISO8859-1");
  39. var_dump($x->test());
  40. echo $x->__getLastResponse();
  41. ?>
  42. --EXPECT--
  43. float(123.456)
  44. <?xml version="1.0" encoding="UTF-8"?>
  45. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 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><return xsi:type="xsd:float">123.456</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
  46. float(123.456)
  47. <?xml version="1.0" encoding="UTF-8"?>
  48. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 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><return xsi:type="xsd:float">123.456</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>