From: Dmitry Stogov Date: Wed, 22 Feb 2006 11:38:32 +0000 (+0000) Subject: Unicode support: fixed __toString() in user defined exceptions X-Git-Tag: RELEASE_1_2~116 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d0da6184ac5826c8cef0954321377290bc8e788;p=php Unicode support: fixed __toString() in user defined exceptions --- diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index c94dd5bd1f..7016f9fdb6 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -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);