dmitry          Mon Jul 10 10:33:55 2006 UTC

  Modified files:              
    /php-src/ext/soap   php_encoding.c 
    /php-src/ext/soap/tests/bugs        bug38055.phpt bug38055.wsdl 
  Log:
  Fixed bug #38055 (Wrong interpretation of boolean parameters)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_encoding.c?r1=1.130&r2=1.131&diff_format=u
Index: php-src/ext/soap/php_encoding.c
diff -u php-src/ext/soap/php_encoding.c:1.130 
php-src/ext/soap/php_encoding.c:1.131
--- php-src/ext/soap/php_encoding.c:1.130       Mon Jul 10 07:23:12 2006
+++ php-src/ext/soap/php_encoding.c     Mon Jul 10 10:33:55 2006
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_encoding.c,v 1.130 2006/07/10 07:23:12 dmitry Exp $ */
+/* $Id: php_encoding.c,v 1.131 2006/07/10 10:33:55 dmitry Exp $ */
 
 #include <time.h>
 
@@ -963,8 +963,13 @@
                                stricmp(data->children->content,"t") == 0 ||
                                strcmp(data->children->content,"1") == 0) {
                                ZVAL_BOOL(ret, 1);
-                       } else {
+                       } else if (stricmp(data->children->content,"false") == 
0 ||
+                               stricmp(data->children->content,"f") == 0 ||
+                               strcmp(data->children->content,"0") == 0) {
                                ZVAL_BOOL(ret, 0);
+                       } else {
+                               ZVAL_STRING(ret, data->children->content, 1);
+                               convert_to_boolean(ret);
                        }
                } else {
                        soap_error0(E_ERROR, "Encoding: Violation of encoding 
rules");
@@ -978,29 +983,17 @@
 static xmlNodePtr to_xml_bool(encodeTypePtr type, zval *data, int style, 
xmlNodePtr parent)
 {
        xmlNodePtr ret;
-       zval tmp;
 
        ret = xmlNewNode(NULL,"BOGUS");
        xmlAddChild(parent, ret);
        FIND_ZVAL_NULL(data, ret, style);
 
-       if (Z_TYPE_P(data) != IS_BOOL) {
-               tmp = *data;
-               zval_copy_ctor(&tmp);
-               convert_to_boolean(data);
-               data = &tmp;
-       }
-
-       if (data->value.lval == 1) {
+       if (zend_is_true(data)) {
                xmlNodeSetContent(ret, "true");
        } else {
                xmlNodeSetContent(ret, "false");
        }
 
-       if (data == &tmp) {
-               zval_dtor(&tmp);
-       }
-
        if (style == SOAP_ENCODED) {
                set_ns_and_type(ret, type);
        }
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/tests/bugs/bug38055.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug38055.phpt
diff -u /dev/null php-src/ext/soap/tests/bugs/bug38055.phpt:1.2
--- /dev/null   Mon Jul 10 10:33:55 2006
+++ php-src/ext/soap/tests/bugs/bug38055.phpt   Mon Jul 10 10:33:55 2006
@@ -0,0 +1,39 @@
+--TEST--
+Bug #38055 (Wrong interpretation of boolean parameters)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function Test($param) {
+       global $g1, $g2;
+       $g1 = $param->boolA;
+       $g2     = $param->boolB;
+       return 1;
+}
+
+class TestSoapClient extends SoapClient {
+  function __construct($wsdl) {
+    parent::__construct($wsdl);
+    $this->server = new SoapServer($wsdl);
+    $this->server->addFunction('Test');
+  }
+
+  function __doRequest($request, $location, $action, $version) {
+    ob_start();
+    $this->server->handle($request);
+    $response = ob_get_contents();
+    ob_end_clean();
+    return $response;
+  }
+}
+
+$client = new TestSoapClient(dirname(__FILE__).'/bug38055.wsdl');
+$boolA = 1;
+$boolB = '1';
+$res = $client->Test(array('boolA'=>$boolA, 'boolB'=>$boolB));
+var_dump($g1);
+var_dump($g2);
+?>
+--EXPECT--
+bool(true)
+bool(true)
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/tests/bugs/bug38055.wsdl?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug38055.wsdl
diff -u /dev/null php-src/ext/soap/tests/bugs/bug38055.wsdl:1.2
--- /dev/null   Mon Jul 10 10:33:55 2006
+++ php-src/ext/soap/tests/bugs/bug38055.wsdl   Mon Jul 10 10:33:55 2006
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
+               xmlns:http="http://schemas.xmlsoap.org/wsdl/http/";
+               xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
+               xmlns:s="http://www.w3.org/2001/XMLSchema";
+               xmlns:s0="http://test.pl";
+               targetNamespace="http://test.pl";
+               xmlns="http://schemas.xmlsoap.org/wsdl/";>
+       <types>
+               <s:schema elementFormDefault="qualified" 
targetNamespace="http://test.pl";>
+                       <s:complexType name="Test">
+                               <s:attribute use="required" name="boolA" 
type="s:boolean"/>
+                               <s:attribute use="required" name="boolB" 
type="s:boolean"/>
+                       </s:complexType>
+                       <s:element type="s0:Test" name="Test"/>
+                       <s:element type="s:int" name="Ret"/>
+               </s:schema>
+       </types>
+
+       <message name="TestSoapIn">
+               <part name="parameters" element="s0:Test"/>
+       </message>
+       <message name="TestSoapOut">
+               <part name="parameters" element="s0:Ret"/>
+       </message>
+       <portType name="TestSoap">
+               <operation name="Test">
+                       <input message="s0:TestSoapIn"/>
+                       <output message="s0:TestSoapOut"/>
+               </operation>
+       </portType>
+       <binding name="TestSoap" type="s0:TestSoap">
+               <soap:binding transport="http://schemas.xmlsoap.org/soap/http"; 
style="document"/>
+               <operation name="Test">
+                       <soap:operation soapAction="http:/Test/Test" 
style="document"/>
+                       <input>
+                               <soap:body use="literal"/>
+                       </input>
+                       <output>
+                               <soap:body use="literal"/>
+                       </output>
+               </operation>
+       </binding>
+       <service name="Test">
+               <port name="TestSoapPort" binding="s0:TestSoap">
+                       <soap:address location="http://localhost/server.php"/>
+               </port>
+       </service>
+</definitions>
\ No newline at end of file

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to