]> granicus.if.org Git - php/commitdiff
zend_make_printable_zval choses cast_object over __toString
authorLeigh <leight@gmail.com>
Fri, 10 Aug 2012 10:09:25 +0000 (11:09 +0100)
committerLeigh <leight@gmail.com>
Fri, 10 Aug 2012 10:09:25 +0000 (11:09 +0100)
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.

Zend/zend.c

index 18c4f11604c9dc100476d6d690e828d8ebce41f7..be30e92e7ddd7d2e1068c6e92289a0883cd80e26 100644 (file)
@@ -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;