dmitry          Wed Sep  5 11:20:46 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/soap/tests/bugs        bug42214.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/soap   php_soap.h soap.c 
  Log:
  Fixed bug #42214 (SoapServer sends clients internal PHP errors)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.929&r2=1.2027.2.547.2.930&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.929 php-src/NEWS:1.2027.2.547.2.930
--- php-src/NEWS:1.2027.2.547.2.929     Wed Sep  5 10:18:22 2007
+++ php-src/NEWS        Wed Sep  5 11:20:45 2007
@@ -26,6 +26,7 @@
   breaks). (Dmitry)
 - Fixed bug #42359 (xsd:list type not parsed). (Dmitry)
 - Fixed bug #42326 (SoapServer crash). (Dmitry)
+- Fixed bug #42214 (SoapServer sends clients internal PHP errors). (Dmitry)
 - Fixed bug #42086 (SoapServer return Procedure '' not present for WSIBasic
   compliant wsdl). (Dmitry)
 
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_soap.h?r1=1.38.2.6.2.5&r2=1.38.2.6.2.6&diff_format=u
Index: php-src/ext/soap/php_soap.h
diff -u php-src/ext/soap/php_soap.h:1.38.2.6.2.5 
php-src/ext/soap/php_soap.h:1.38.2.6.2.6
--- php-src/ext/soap/php_soap.h:1.38.2.6.2.5    Mon Apr  2 13:43:08 2007
+++ php-src/ext/soap/php_soap.h Wed Sep  5 11:20:45 2007
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_soap.h,v 1.38.2.6.2.5 2007/04/02 13:43:08 dmitry Exp $ */
+/* $Id: php_soap.h,v 1.38.2.6.2.6 2007/09/05 11:20:45 dmitry Exp $ */
 
 #ifndef PHP_SOAP_H
 #define PHP_SOAP_H
@@ -106,6 +106,7 @@
        HashTable *class_map;
        int        features;
        struct _soapHeader **soap_headers_ptr;
+       int send_errors;
 };
 
 #define SOAP_CLASS 1
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/soap.c?r1=1.156.2.28.2.29&r2=1.156.2.28.2.30&diff_format=u
Index: php-src/ext/soap/soap.c
diff -u php-src/ext/soap/soap.c:1.156.2.28.2.29 
php-src/ext/soap/soap.c:1.156.2.28.2.30
--- php-src/ext/soap/soap.c:1.156.2.28.2.29     Fri Aug 31 10:48:45 2007
+++ php-src/ext/soap/soap.c     Wed Sep  5 11:20:45 2007
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: soap.c,v 1.156.2.28.2.29 2007/08/31 10:48:45 dmitry Exp $ */
+/* $Id: soap.c,v 1.156.2.28.2.30 2007/09/05 11:20:45 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1035,6 +1035,7 @@
 
        service = emalloc(sizeof(soapService));
        memset(service, 0, sizeof(soapService));
+       service->send_errors = 1;
 
        cache_wsdl = SOAP_GLOBAL(cache);
 
@@ -1099,6 +1100,11 @@
                        cache_wsdl = Z_LVAL_PP(tmp);
                }
 
+               if (zend_hash_find(ht, "send_errors", sizeof("send_errors"), 
(void**)&tmp) == SUCCESS &&
+                   (Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG)) {
+                       service->send_errors = Z_LVAL_PP(tmp);
+               }
+
        } else if (wsdl == NULL) {
                php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid arguments. 
'uri' option is required in nonWSDL mode.");
        }
@@ -2129,34 +2135,46 @@
 
                        char* code = SOAP_GLOBAL(error_code);
                        char buffer[1024];
-                       int buffer_len;
                        zval *outbuf = NULL;
-                       zval outbuflen;
+                       zval **tmp;
+                       soapServicePtr service;
 
-                       INIT_ZVAL(outbuflen);
+                       if (code == NULL) {
+                               code = "Server";
+                       }
+                       if (SOAP_GLOBAL(error_object) &&
+                           Z_TYPE_P(SOAP_GLOBAL(error_object)) == IS_OBJECT &&
+                           
instanceof_function(Z_OBJCE_P(SOAP_GLOBAL(error_object)), 
soap_server_class_entry TSRMLS_CC) &&
+                       zend_hash_find(Z_OBJPROP_P(SOAP_GLOBAL(error_object)), 
"service", sizeof("service"), (void **)&tmp) != FAILURE &&
+                               (service = 
(soapServicePtr)zend_fetch_resource(tmp TSRMLS_CC, -1, "service", NULL, 1, 
le_service)) &&
+                               !service->send_errors) {
+                               strcpy(buffer, "Internal Error");
+                       } else {
+                               int buffer_len;
+                               zval outbuflen;
+
+                               INIT_ZVAL(outbuflen);
 
 #ifdef va_copy
-                       va_copy(argcopy, args);
-                       buffer_len = vslprintf(buffer, sizeof(buffer)-1, 
format, argcopy);
-                       va_end(argcopy);
+                               va_copy(argcopy, args);
+                               buffer_len = vslprintf(buffer, 
sizeof(buffer)-1, format, argcopy);
+                               va_end(argcopy);
 #else
-                       buffer_len = vslprintf(buffer, sizeof(buffer)-1, 
format, args);
+                               buffer_len = vslprintf(buffer, 
sizeof(buffer)-1, format, args);
 #endif
-                       buffer[sizeof(buffer)-1]=0;
-                       if (buffer_len > sizeof(buffer) - 1 || buffer_len < 0) {
-                               buffer_len = sizeof(buffer) - 1;
-                       }
+                               buffer[sizeof(buffer)-1]=0;
+                               if (buffer_len > sizeof(buffer) - 1 || 
buffer_len < 0) {
+                                       buffer_len = sizeof(buffer) - 1;
+                               }
 
-                       if (code == NULL) {
-                               code = "Server";
-                       }
-                       /* Get output buffer and send as fault detials */
-                       if (php_ob_get_length(&outbuflen TSRMLS_CC) != FAILURE 
&& Z_LVAL(outbuflen) != 0) {
-                               ALLOC_INIT_ZVAL(outbuf);
-                   php_ob_get_buffer(outbuf TSRMLS_CC);
-                       }
-                       php_end_ob_buffer(0, 0 TSRMLS_CC);
+                               /* Get output buffer and send as fault detials 
*/
+                               if (php_ob_get_length(&outbuflen TSRMLS_CC) != 
FAILURE && Z_LVAL(outbuflen) != 0) {
+                                       ALLOC_INIT_ZVAL(outbuf);
+                                       php_ob_get_buffer(outbuf TSRMLS_CC);
+                               }
+                               php_end_ob_buffer(0, 0 TSRMLS_CC);
 
+                       }
                        INIT_ZVAL(fault_obj);
                        set_soap_fault(&fault_obj, NULL, code, buffer, NULL, 
outbuf, NULL TSRMLS_CC);
                        fault = 1;

http://cvs.php.net/viewvc.cgi/php-src/ext/soap/tests/bugs/bug42214.phpt?view=markup&rev=1.1
Index: php-src/ext/soap/tests/bugs/bug42214.phpt
+++ php-src/ext/soap/tests/bugs/bug42214.phpt

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

Reply via email to