]> granicus.if.org Git - php/commitdiff
Unicode support: fixed __toString() in user defined exceptions
authorDmitry Stogov <dmitry@php.net>
Wed, 22 Feb 2006 11:38:32 +0000 (11:38 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 22 Feb 2006 11:38:32 +0000 (11:38 +0000)
Zend/zend_exceptions.c

index c94dd5bd1f37f825ec3ab8b3ba66389cfaba5fcc..7016f9fdb6363f3aa77a5f0b26ec4e3cf275b82e 100644 (file)
@@ -757,11 +757,12 @@ ZEND_API void zend_exception_error(zval *exception TSRMLS_DC)
 
                zend_call_method_with_0_params(&exception, ce_exception, NULL, "__tostring", &str);
                if (!EG(exception)) {
-                       if (Z_TYPE_P(str) != IS_STRING) {
-                               zend_error(E_WARNING, "%v::__toString() must return a string", ce_exception->name);
+                       if (Z_TYPE_P(str) == IS_UNICODE) {
+                               zend_update_property_unicodel(default_exception_ce, exception, "string", sizeof("string")-1, Z_USTRVAL_P(str), Z_USTRLEN_P(str) TSRMLS_CC);
+                       } else if (Z_TYPE_P(str) == IS_STRING) {
+                               zend_update_property_stringl(default_exception_ce, exception, "string", sizeof("string")-1, Z_STRVAL_P(str), Z_STRLEN_P(str) TSRMLS_CC);
                        } else {
-                               /* FIXME: Unicode support??? */
-                               zend_update_property_string(default_exception_ce, exception, "string", sizeof("string")-1, EG(exception) ? ce_exception->name.s : Z_STRVAL_P(str) TSRMLS_CC);
+                               zend_error(E_WARNING, "%v::__toString() must return a string", ce_exception->name);
                        }
                }
                zval_ptr_dtor(&str);