From: Leigh Date: Fri, 10 Aug 2012 10:09:25 +0000 (+0100) Subject: zend_make_printable_zval choses cast_object over __toString X-Git-Tag: php-5.5.0alpha1~20^2~99^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a5dfd414941953c282bb68f6b08685252ca93a1a;p=php zend_make_printable_zval choses cast_object over __toString https://bugs.php.net/bug.php?id=62328 Added a check to see if the object implements a __toString magic method. This should be called instead of the cast_object method of built-in classes when defined. --- diff --git a/Zend/zend.c b/Zend/zend.c index 18c4f11604..be30e92e7d 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -258,6 +258,12 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop { TSRMLS_FETCH(); + if (Z_OBJCE_P(expr)->__tostring) { + if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING TSRMLS_CC) == SUCCESS) { + break; + } + } + if (Z_OBJ_HANDLER_P(expr, cast_object)) { zval *val;