]> granicus.if.org Git - php/commitdiff
Fix toString() issue again
authorMarcus Boerger <helly@php.net>
Thu, 8 Apr 2004 22:46:43 +0000 (22:46 +0000)
committerMarcus Boerger <helly@php.net>
Thu, 8 Apr 2004 22:46:43 +0000 (22:46 +0000)
ext/spl/spl_iterators.c

index 3e40e5bd7b2373489ed4cd3a0f8cc98513068a3b..99557d498cdae654afa7d6f06ea4b55645ef24e9 100755 (executable)
@@ -1054,46 +1054,46 @@ static INLINE void spl_caching_it_next(spl_dual_it_object *intern TSRMLS_DC)
                        zval_ptr_dtor(&retval);         
                }
                if (intern->u.caching.flags & CIT_CALL_TOSTRING) {
-#if MBO_0
-                       /* This version requires zend_make_printable_zval() being able to
-                        * call __toString().
-                        */
-                       int  use_copy;
-                       zval expr_copy;
-                       ALLOC_ZVAL(intern->u.caching.zstr);
-                       *intern->u.caching.zstr = *intern->current.data;
-                       zend_make_printable_zval(intern->u.caching.zstr, &expr_copy, &use_copy);
-                       if (use_copy) {
-                               *intern->u.caching.zstr = expr_copy;
-                               INIT_PZVAL(intern->u.caching.zstr);
-                               zval_copy_ctor(intern->u.caching.zstr);
-                               zval_dtor(&expr_copy);
+                       if (Z_TYPE_P(intern->current.data) == IS_OBJECT) {
+                               zval expr_copy;
+                               if (intern->current.data->value.obj.handlers->cast_object &&
+                                       intern->current.data->value.obj.handlers->cast_object(intern->current.data, &expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS)
+                               {
+                                       ALLOC_ZVAL(intern->u.caching.zstr);
+                                       *intern->u.caching.zstr = expr_copy;
+                                       INIT_PZVAL(intern->u.caching.zstr);
+                                       zval_copy_ctor(intern->u.caching.zstr);
+                                       zval_dtor(&expr_copy);
+                               } else {
+                                       zend_class_entry *ce_data = spl_get_class_entry(intern->current.data TSRMLS_CC);
+                                       if (ce_data && zend_hash_exists(&ce_data->function_table, "__tostring", sizeof("__tostring"))) {
+                                               zend_call_method_with_0_params(&intern->current.data, ce_data, NULL, "__tostring", &intern->u.caching.zstr);
+                                       } else {
+                                               ALLOC_ZVAL(intern->u.caching.zstr);
+                                               *intern->u.caching.zstr = *intern->current.data;
+                                               zval_copy_ctor(intern->u.caching.zstr);
+                                               INIT_PZVAL(intern->u.caching.zstr);
+                                               convert_to_string(intern->u.caching.zstr);
+                                       }
+                               }
                        } else {
-                               zval_copy_ctor(intern->u.caching.zstr);
-                       }
-#else
-                       zval expr_copy;
-                       if (intern->current.data->value.obj.handlers->cast_object &&
-                               intern->current.data->value.obj.handlers->cast_object(intern->current.data, &expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS)
-                       {
+                               /* This version requires zend_make_printable_zval() being able to
+                                * call __toString().
+                                */
+                               int  use_copy;
+                               zval expr_copy;
                                ALLOC_ZVAL(intern->u.caching.zstr);
-                               *intern->u.caching.zstr = expr_copy;
-                               INIT_PZVAL(intern->u.caching.zstr);
-                               zval_copy_ctor(intern->u.caching.zstr);
-                               zval_dtor(&expr_copy);
-                       } else {
-                               zend_class_entry *ce_data = spl_get_class_entry(intern->current.data TSRMLS_CC);
-                               if (ce_data && zend_hash_exists(&ce_data->function_table, "__tostring", sizeof("__tostring"))) {
-                                       zend_call_method_with_0_params(&intern->current.data, ce_data, NULL, "__tostring", &intern->u.caching.zstr);
+                               *intern->u.caching.zstr = *intern->current.data;
+                               zend_make_printable_zval(intern->u.caching.zstr, &expr_copy, &use_copy);
+                               if (use_copy) {
+                                       *intern->u.caching.zstr = expr_copy;
+                                       INIT_PZVAL(intern->u.caching.zstr);
+                                       zval_copy_ctor(intern->u.caching.zstr);
+                                       zval_dtor(&expr_copy);
                                } else {
-                                       ALLOC_ZVAL(intern->u.caching.zstr);
-                                       *intern->u.caching.zstr = *intern->current.data;
                                        zval_copy_ctor(intern->u.caching.zstr);
-                                       INIT_PZVAL(intern->u.caching.zstr);
-                                       convert_to_string(intern->u.caching.zstr);
                                }
                        }
-#endif
                }
                spl_dual_it_next(intern, 0 TSRMLS_CC);  
        } else {