cvs: ZendEngine2 / zend.c zend.h zend_API.c zend_API.h zend_compile.c zend_compile.h zend_object_handlers.c zend_vm_def.h zend_vm_execute.h
zend_vm_opcodes.h /tests bug26166.phpt php-src NEWS
| From: | Dmitry Stogov | Date: | Tue, 27 Sep 2005 07:59:02 +0000 |
| Subject: | cvs: ZendEngine2 / zend.c zend.h zend_API.c zend_API.h zend_compile.c zend_compile.h zend_object_handlers.c zend_vm_def.h zend_vm_execute.h zend_vm_opcodes.h /tests bug26166.phpt php-src NEWS |
||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4181@lists.php.net to get a copy of this message | ||
dmitry Tue Sep 27 03:59:02 2005 EDT
Modified files:
/php-src NEWS
/ZendEngine2 zend.c zend.h zend_API.c zend_API.h zend_compile.c
zend_compile.h zend_object_handlers.c zend_vm_def.h
zend_vm_execute.h zend_vm_opcodes.h
/ZendEngine2/tests bug26166.phpt
Log:
Changed __toString() behavior to call it in all necessary places
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2065&r2=1.2066&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.2065 php-src/NEWS:1.2066 --- php-src/NEWS:1.2065 Sun Sep 18 23:21:34 2005 +++ php-src/NEWS Tue Sep 27 03:58:59 2005 @@ -2,6 +2,8 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 6.0 - Unicode support. (Andrei, Dmitriy, et al) +- Changed __toString() behavior to call it in all necessary places + (Marcus, Dmitry) - Changed "instanceof" and "catch" operators, is_a() and is_subclass_of() functions to not call __autoload(). (Dmitry) - cURL improvements: (Ilia) http://cvs.php.net/diff.php/ZendEngine2/zend.c?r1=1.323&r2=1.324&ty=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.323 ZendEngine2/zend.c:1.324 --- ZendEngine2/zend.c:1.323 Thu Sep 15 12:19:41 2005 +++ ZendEngine2/zend.c Tue Sep 27 03:58:59 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.323 2005/09/15 16:19:41 derick Exp $ */ +/* $Id: zend.c,v 1.324 2005/09/27 07:58:59 dmitry Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -347,39 +347,28 @@ case IS_OBJECT: { TSRMLS_FETCH(); -#if 0 - /* Standard PHP objects */ - if (Z_OBJ_HT_P(expr) == &std_object_handlers || !Z_OBJ_HT_P(expr)->cast_object) { - if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - break; - } - zend_error(E_NOTICE, "Object of class %v could not be converted to string", Z_OBJCE_P(expr)->name); - } -#endif if (Z_OBJ_HANDLER_P(expr, cast_object)) { if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { break; } - } else { - if(Z_OBJ_HANDLER_P(expr, get)) { - zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); - if(Z_TYPE_P(z) != IS_OBJECT) { - zend_make_printable_zval(z, expr_copy, use_copy); - FREE_ZVAL(z); - return; - } + } + if (Z_OBJ_HANDLER_P(expr, get)) { + zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); + if(Z_TYPE_P(z) != IS_OBJECT) { + zend_make_printable_zval(z, expr_copy, use_copy); + FREE_ZVAL(z); + break; } } if (EG(exception)) { - zval_dtor(expr_copy); expr_copy->value.str.len = 0; expr_copy->value.str.val = STR_EMPTY_ALLOC(); break; } + } expr_copy->value.str.val = (char *) emalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG); expr_copy->value.str.len = sprintf(expr_copy->value.str.val, "Object id #%ld", (long)expr->value.obj.handle); - expr_copy->type = IS_STRING; break; default: *expr_copy = *expr; @@ -387,6 +376,7 @@ convert_to_string(expr_copy); break; } + expr_copy->type = IS_STRING; *use_copy = 1; } @@ -426,40 +416,26 @@ expr_copy->value.str.val = estrndup("Array", expr_copy->value.str.len); break; case IS_OBJECT: - { -#if 0 - /* Standard PHP objects */ - if (Z_OBJ_HT_P(expr) == &std_object_handlers || !Z_OBJ_HT_P(expr)->cast_object) { - if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - break; - } - zend_error(E_NOTICE, "Object of class %v could not be converted to string", Z_OBJCE_P(expr)->name); - } -#endif - if (Z_OBJ_HANDLER_P(expr, cast_object)) { - if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - break; - } - } else { - if(Z_OBJ_HANDLER_P(expr, get)) { - zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); - if(Z_TYPE_P(z) != IS_OBJECT) { - zend_make_printable_zval(z, expr_copy, use_copy); - FREE_ZVAL(z); - return; - } - } + if (Z_OBJ_HANDLER_P(expr, cast_object)) { + if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { + break; } - if (EG(exception)) { - zval_dtor(expr_copy); - expr_copy->value.str.len = 0; - expr_copy->value.str.val = STR_EMPTY_ALLOC(); + } + if (Z_OBJ_HANDLER_P(expr, get)) { + zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); + if(Z_TYPE_P(z) != IS_OBJECT) { + zend_make_printable_zval(z, expr_copy, use_copy); + FREE_ZVAL(z); break; } } + if (EG(exception)) { + expr_copy->value.str.len = 0; + expr_copy->value.str.val = STR_EMPTY_ALLOC(); + break; + } expr_copy->value.str.val = (char *) emalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG); expr_copy->value.str.len = sprintf(expr_copy->value.str.val, "Object id #%ld", (long)expr->value.obj.handle); - expr_copy->type = IS_STRING; break; case IS_DOUBLE: *expr_copy = *expr; @@ -491,40 +467,26 @@ } switch (expr->type) { case IS_OBJECT: - { -#if 0 - /* Standard PHP objects */ - if (Z_OBJ_HT_P(expr) == &std_object_handlers || !Z_OBJ_HT_P(expr)->cast_object) { - if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - break; - } - zend_error(E_NOTICE, "Object of class %v could not be converted to string", Z_OBJCE_P(expr)->name); - } -#endif - if (Z_OBJ_HANDLER_P(expr, cast_object)) { - if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_UNICODE, 0 TSRMLS_CC) == SUCCESS) { - break; - } - } else { - if(Z_OBJ_HANDLER_P(expr, get)) { - zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); - if(Z_TYPE_P(z) != IS_OBJECT) { - zend_make_unicode_zval(z, expr_copy, use_copy); - FREE_ZVAL(z); - return; - } - } + if (Z_OBJ_HANDLER_P(expr, cast_object)) { + if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_UNICODE, 0 TSRMLS_CC) == SUCCESS) { + break; } - if (EG(exception)) { - zval_dtor(expr_copy); - expr_copy->value.ustr.len = 0; - expr_copy->value.ustr.val = USTR_MAKE(""); + } + if (Z_OBJ_HANDLER_P(expr, get)) { + zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); + if(Z_TYPE_P(z) != IS_OBJECT) { + zend_make_unicode_zval(z, expr_copy, use_copy); + FREE_ZVAL(z); break; } } - expr_copy->value.ustr.val = emalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG + 1); + if (EG(exception)) { + expr_copy->value.ustr.len = 0; + expr_copy->value.ustr.val = USTR_MAKE(""); + break; + } + expr_copy->value.ustr.val = eumalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG + 1); expr_copy->value.ustr.len = u_sprintf(expr_copy->value.ustr.val, "Object id #%ld", (long)expr->value.obj.handle); - expr_copy->type = IS_UNICODE; break; default: *expr_copy = *expr; @@ -532,6 +494,7 @@ convert_to_unicode(expr_copy); break; } + expr_copy->type = IS_UNICODE; *use_copy = 1; } @@ -969,6 +932,8 @@ ce->__isset = ce->__isset->common.u_twin; } else if (ce->__call) { ce->__call = ce->__call->common.u_twin; + } else if (ce->__tostring) { + ce->__tostring = ce->__tostring->common.u_twin; } else if (ce->serialize_func) { ce->serialize_func = ce->serialize_func->common.u_twin; } else if (ce->unserialize_func) { http://cvs.php.net/diff.php/ZendEngine2/zend.h?r1=1.299&r2=1.300&ty=u Index: ZendEngine2/zend.h diff -u ZendEngine2/zend.h:1.299 ZendEngine2/zend.h:1.300 --- ZendEngine2/zend.h:1.299 Thu Sep 1 06:04:54 2005 +++ ZendEngine2/zend.h Tue Sep 27 03:58:59 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.299 2005/09/01 10:04:54 dmitry Exp $ */ +/* $Id: zend.h,v 1.300 2005/09/27 07:58:59 dmitry Exp $ */ #ifndef ZEND_H #define ZEND_H @@ -360,6 +360,7 @@ union _zend_function *__unset; union _zend_function *__isset; union _zend_function *__call; + union _zend_function *__tostring; union _zend_function *serialize_func; union _zend_function *unserialize_func; http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.315&r2=1.316&ty=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.315 ZendEngine2/zend_API.c:1.316 --- ZendEngine2/zend_API.c:1.315 Thu Sep 1 06:04:55 2005 +++ ZendEngine2/zend_API.c Tue Sep 27 03:58:59 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.315 2005/09/01 10:04:55 dmitry Exp $ */ +/* $Id: zend_API.c,v 1.316 2005/09/27 07:58:59 dmitry Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -2022,6 +2022,9 @@ } else if (lcname_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && ZEND_U_EQUAL(utype, lcname, lcname_len, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1) && fptr->common.num_args != 2) { zend_error(error_type, "Method %v::%s() must take exactly 2 arguments", ce->name, ZEND_CALL_FUNC_NAME); + } else if (lcname_len == sizeof(ZEND_TOSTRING_FUNC_NAME) - 1 && + ZEND_U_EQUAL(utype, lcname, lcname_len, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && fptr->common.num_args != 0) { + zend_error(error_type, "Method %v::%s() cannot take arguments", ce->name, ZEND_CALL_FUNC_NAME); } efree(lcname); } @@ -2035,7 +2038,7 @@ int count=0, unload=0; HashTable *target_function_table = function_table; int error_type; - zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL; + zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__tostring = NULL; char *lowercase_name; int fname_len; char *lc_class_name; @@ -2139,6 +2142,8 @@ clone = reg_function; } else if ((fname_len == sizeof(ZEND_CALL_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME))) { __call = reg_function; + } else if ((fname_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME))) { + __tostring = reg_function; } else if ((fname_len == sizeof(ZEND_GET_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME))) { __get = reg_function; } else if ((fname_len == sizeof(ZEND_SET_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME))) { @@ -2176,6 +2181,7 @@ scope->destructor = dtor; scope->clone = clone; scope->__call = __call; + scope->__tostring = __tostring; scope->__get = __get; scope->__set = __set; scope->__unset = __unset; @@ -2207,6 +2213,12 @@ } __call->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } + if (__tostring) { + if (__tostring->common.fn_flags & ZEND_ACC_STATIC) { + zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __tostring->common.function_name); + } + __tostring->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; + } if (__get) { if (__get->common.fn_flags & ZEND_ACC_STATIC) { zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __get->common.function_name); http://cvs.php.net/diff.php/ZendEngine2/zend_API.h?r1=1.221&r2=1.222&ty=u Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.221 ZendEngine2/zend_API.h:1.222 --- ZendEngine2/zend_API.h:1.221 Fri Sep 23 18:49:57 2005 +++ ZendEngine2/zend_API.h Tue Sep 27 03:58:59 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.h,v 1.221 2005/09/23 22:49:57 helly Exp $ */ +/* $Id: zend_API.h,v 1.222 2005/09/27 07:58:59 dmitry Exp $ */ #ifndef ZEND_API_H #define ZEND_API_H @@ -131,6 +131,7 @@ class_container.create_object = NULL; \ class_container.interface_gets_implemented = NULL; \ class_container.__call = handle_fcall; \ + class_container.__tostring = NULL; \ class_container.__get = handle_propget; \ class_container.__set = handle_propset; \ class_container.__unset = handle_propunset; \ http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.663&r2=1.664&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.663 ZendEngine2/zend_compile.c:1.664 --- ZendEngine2/zend_compile.c:1.663 Fri Sep 16 09:42:31 2005 +++ ZendEngine2/zend_compile.c Tue Sep 27 03:58:59 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.663 2005/09/16 13:42:31 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.664 2005/09/27 07:58:59 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1163,6 +1163,8 @@ CG(active_class_entry)->__unset = (zend_function *) CG(active_op_array); } else if ((lcname_len == sizeof(ZEND_ISSET_FUNC_NAME)-1) && (ZEND_U_EQUAL(Z_TYPE(function_name->u.constant), lcname, lcname_len, ZEND_ISSET_FUNC_NAME, sizeof(ZEND_ISSET_FUNC_NAME)-1))) { CG(active_class_entry)->__isset = (zend_function *) CG(active_op_array); + } else if ((lcname_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && (ZEND_U_EQUAL(Z_TYPE(function_name->u.constant), lcname, lcname_len, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME)-1))) { + CG(active_class_entry)->__tostring = (zend_function *) CG(active_op_array); } else if (!(fn_flags & ZEND_ACC_STATIC)) { CG(active_op_array)->fn_flags |= ZEND_ACC_ALLOW_STATIC; } @@ -1873,6 +1875,9 @@ if (!ce->__call) { ce->__call = ce->parent->__call; } + if (!ce->__tostring) { + ce->__tostring = ce->parent->__tostring; + } if (!ce->clone) { ce->clone = ce->parent->clone; } @@ -4152,6 +4157,7 @@ ce->__unset = NULL; ce->__isset = NULL; ce->__call = NULL; + ce->__tostring = NULL; ce->create_object = NULL; ce->get_iterator = NULL; ce->iterator_funcs.funcs = NULL; http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.324&r2=1.325&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.324 ZendEngine2/zend_compile.h:1.325 --- ZendEngine2/zend_compile.h:1.324 Fri Sep 23 18:55:10 2005 +++ ZendEngine2/zend_compile.h Tue Sep 27 03:59:00 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.324 2005/09/23 22:55:10 helly Exp $ */ +/* $Id: zend_compile.h,v 1.325 2005/09/27 07:59:00 dmitry Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -723,6 +723,7 @@ #define ZEND_UNSET_FUNC_NAME "__unset" #define ZEND_ISSET_FUNC_NAME "__isset" #define ZEND_CALL_FUNC_NAME "__call" +#define ZEND_TOSTRING_FUNC_NAME "__tostring" #define ZEND_AUTOLOAD_FUNC_NAME "__autoload" #endif /* ZEND_COMPILE_H */ http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.146&r2=1.147&ty=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.146 ZendEngine2/zend_object_handlers.c:1.147 --- ZendEngine2/zend_object_handlers.c:1.146 Thu Sep 1 06:05:00 2005 +++ ZendEngine2/zend_object_handlers.c Tue Sep 27 03:59:00 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.146 2005/09/01 10:05:00 dmitry Exp $ */ +/* $Id: zend_object_handlers.c,v 1.147 2005/09/27 07:59:00 dmitry Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -1008,37 +1008,30 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC) { - zval fname, *retval; + zval *retval; + zend_class_entry *ce; switch (type) { case IS_STRING: case IS_UNICODE: - if (!zend_hash_exists(&Z_OBJCE_P(readobj)->function_table, "__tostring", sizeof("__tostring"))) { - return FAILURE; - } - ZVAL_ASCII_STRING(&fname, "__tostring", 0); - if (call_user_function_ex(NULL, &readobj, &fname, &retval, 0, NULL, 0, NULL TSRMLS_CC) == SUCCESS) { - if (UG(unicode)) { - zval_dtor(&fname); - } - if (retval) { - if (Z_TYPE_P(retval) != (UG(unicode)?IS_UNICODE:IS_STRING)) { - zend_error(E_ERROR, "Method %v::__toString() must return a string value", Z_OBJCE_P(readobj)->name); + ce = Z_OBJCE_P(readobj); + if (ce->__tostring && + zend_call_method_with_0_params(&readobj, ce, &ce->__tostring, "__tostring", &retval)) { + if (Z_TYPE_P(retval) == (UG(unicode)?IS_UNICODE:IS_STRING)) { + *writeobj = *retval; + zval_copy_ctor(writeobj); + zval_ptr_dtor(&retval); + INIT_PZVAL(writeobj); + if (Z_TYPE_P(writeobj) != type) { + convert_to_explicit_type(writeobj, type); } + return SUCCESS; } else { - MAKE_STD_ZVAL(retval); - ZVAL_ASCII_STRINGL(retval, "", 0, 1); + zval_ptr_dtor(&retval); + zend_error(E_RECOVERABLE_ERROR, "Method %v::__toString() must return a string value", ce->name); } - *writeobj = *retval; - zval_copy_ctor(writeobj); - INIT_PZVAL(writeobj); - zval_ptr_dtor(&retval); - return SUCCESS; - } - if (UG(unicode)) { - zval_dtor(&fname); } - break; + return FAILURE; default: break; } @@ -1069,7 +1062,7 @@ zend_std_object_get_class, /* get_class_entry */ zend_std_object_get_class_name, /* get_class_name */ zend_std_compare_objects, /* compare_objects */ - NULL, /* cast_object */ + zend_std_cast_object_tostring, /* cast_object */ NULL, /* count_elements */ }; http://cvs.php.net/diff.php/ZendEngine2/zend_vm_def.h?r1=1.79&r2=1.80&ty=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.79 ZendEngine2/zend_vm_def.h:1.80 --- ZendEngine2/zend_vm_def.h:1.79 Fri Sep 23 05:38:36 2005 +++ ZendEngine2/zend_vm_def.h Tue Sep 27 03:59:00 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.79 2005/09/23 09:38:36 tony2001 Exp $ */ +/* $Id: zend_vm_def.h,v 1.80 2005/09/27 07:59:00 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -884,34 +884,28 @@ zend_free_op free_op1; zval z_copy; zval *z = GET_OP1_ZVAL_PTR(BP_VAR_R); + UErrorCode status = U_ZERO_ERROR; - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, UG(unicode) ? IS_UNICODE : IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - UErrorCode status = U_ZERO_ERROR; - /* Convert inline HTML blocks to the output encoding, but only if necessary. */ - if (opline->extended_value && - strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - EG(active_op_array)->script_encoding)) { - zval z_conv; - UConverter *script_enc_conv = NULL; - if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { - zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); - } - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); - z_conv.type = IS_BINARY; - if (U_SUCCESS(status)) { - zend_print_variable(&z_conv); - } else { - zend_error(E_WARNING, "Could not convert inline HTML for output"); - } - zval_dtor(&z_conv); - ucnv_close(script_enc_conv); + /* Convert inline HTML blocks to the output encoding, but only if necessary. */ + if (opline->extended_value && + strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), + EG(active_op_array)->script_encoding)) { + zval z_conv; + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + z_conv.type = IS_BINARY; + if (U_SUCCESS(status)) { + zend_print_variable(&z_conv); } else { - zend_print_variable(z); + zend_error(E_WARNING, "Could not convert inline HTML for output"); } + zval_dtor(&z_conv); + ucnv_close(script_enc_conv); + } else { + zend_print_variable(z); } FREE_OP1(); http://cvs.php.net/diff.php/ZendEngine2/zend_vm_execute.h?r1=1.82&r2=1.83&ty=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.82 ZendEngine2/zend_vm_execute.h:1.83 --- ZendEngine2/zend_vm_execute.h:1.82 Fri Sep 23 05:38:35 2005 +++ ZendEngine2/zend_vm_execute.h Tue Sep 27 03:59:00 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_execute.h,v 1.82 2005/09/23 09:38:35 tony2001 Exp $ */ +/* $Id: zend_vm_execute.h,v 1.83 2005/09/27 07:59:00 dmitry Exp $ */ static opcode_handler_t zend_user_opcode_handlers[256] = {(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL}; @@ -1367,34 +1367,28 @@ zval z_copy; zval *z = &opline->op1.u.constant; + UErrorCode status = U_ZERO_ERROR; - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, UG(unicode) ? IS_UNICODE : IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - UErrorCode status = U_ZERO_ERROR; - /* Convert inline HTML blocks to the output encoding, but only if necessary. */ - if (opline->extended_value && - strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - EG(active_op_array)->script_encoding)) { - zval z_conv; - UConverter *script_enc_conv = NULL; - if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { - zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); - } - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); - z_conv.type = IS_BINARY; - if (U_SUCCESS(status)) { - zend_print_variable(&z_conv); - } else { - zend_error(E_WARNING, "Could not convert inline HTML for output"); - } - zval_dtor(&z_conv); - ucnv_close(script_enc_conv); + /* Convert inline HTML blocks to the output encoding, but only if necessary. */ + if (opline->extended_value && + strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), + EG(active_op_array)->script_encoding)) { + zval z_conv; + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + z_conv.type = IS_BINARY; + if (U_SUCCESS(status)) { + zend_print_variable(&z_conv); } else { - zend_print_variable(z); + zend_error(E_WARNING, "Could not convert inline HTML for output"); } + zval_dtor(&z_conv); + ucnv_close(script_enc_conv); + } else { + zend_print_variable(z); } ZEND_VM_NEXT_OPCODE(); @@ -3879,34 +3873,28 @@ zend_free_op free_op1; zval z_copy; zval *z = _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); + UErrorCode status = U_ZERO_ERROR; - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, UG(unicode) ? IS_UNICODE : IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - UErrorCode status = U_ZERO_ERROR; - /* Convert inline HTML blocks to the output encoding, but only if necessary. */ - if (opline->extended_value && - strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - EG(active_op_array)->script_encoding)) { - zval z_conv; - UConverter *script_enc_conv = NULL; - if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { - zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); - } - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); - z_conv.type = IS_BINARY; - if (U_SUCCESS(status)) { - zend_print_variable(&z_conv); - } else { - zend_error(E_WARNING, "Could not convert inline HTML for output"); - } - zval_dtor(&z_conv); - ucnv_close(script_enc_conv); + /* Convert inline HTML blocks to the output encoding, but only if necessary. */ + if (opline->extended_value && + strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), + EG(active_op_array)->script_encoding)) { + zval z_conv; + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + z_conv.type = IS_BINARY; + if (U_SUCCESS(status)) { + zend_print_variable(&z_conv); } else { - zend_print_variable(z); + zend_error(E_WARNING, "Could not convert inline HTML for output"); } + zval_dtor(&z_conv); + ucnv_close(script_enc_conv); + } else { + zend_print_variable(z); } zval_dtor(free_op1.var); @@ -6930,34 +6918,28 @@ zend_free_op free_op1; zval z_copy; zval *z = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); + UErrorCode status = U_ZERO_ERROR; - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, UG(unicode) ? IS_UNICODE : IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - UErrorCode status = U_ZERO_ERROR; - /* Convert inline HTML blocks to the output encoding, but only if necessary. */ - if (opline->extended_value && - strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - EG(active_op_array)->script_encoding)) { - zval z_conv; - UConverter *script_enc_conv = NULL; - if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { - zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); - } - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); - z_conv.type = IS_BINARY; - if (U_SUCCESS(status)) { - zend_print_variable(&z_conv); - } else { - zend_error(E_WARNING, "Could not convert inline HTML for output"); - } - zval_dtor(&z_conv); - ucnv_close(script_enc_conv); + /* Convert inline HTML blocks to the output encoding, but only if necessary. */ + if (opline->extended_value && + strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), + EG(active_op_array)->script_encoding)) { + zval z_conv; + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + z_conv.type = IS_BINARY; + if (U_SUCCESS(status)) { + zend_print_variable(&z_conv); } else { - zend_print_variable(z); + zend_error(E_WARNING, "Could not convert inline HTML for output"); } + zval_dtor(&z_conv); + ucnv_close(script_enc_conv); + } else { + zend_print_variable(z); } if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -19709,34 +19691,28 @@ zval z_copy; zval *z = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC); + UErrorCode status = U_ZERO_ERROR; - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, UG(unicode) ? IS_UNICODE : IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - UErrorCode status = U_ZERO_ERROR; - /* Convert inline HTML blocks to the output encoding, but only if necessary. */ - if (opline->extended_value && - strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - EG(active_op_array)->script_encoding)) { - zval z_conv; - UConverter *script_enc_conv = NULL; - if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { - zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); - } - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); - z_conv.type = IS_BINARY; - if (U_SUCCESS(status)) { - zend_print_variable(&z_conv); - } else { - zend_error(E_WARNING, "Could not convert inline HTML for output"); - } - zval_dtor(&z_conv); - ucnv_close(script_enc_conv); + /* Convert inline HTML blocks to the output encoding, but only if necessary. */ + if (opline->extended_value && + strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), + EG(active_op_array)->script_encoding)) { + zval z_conv; + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + z_conv.type = IS_BINARY; + if (U_SUCCESS(status)) { + zend_print_variable(&z_conv); } else { - zend_print_variable(z); + zend_error(E_WARNING, "Could not convert inline HTML for output"); } + zval_dtor(&z_conv); + ucnv_close(script_enc_conv); + } else { + zend_print_variable(z); } ZEND_VM_NEXT_OPCODE(); http://cvs.php.net/diff.php/ZendEngine2/zend_vm_opcodes.h?r1=1.59&r2=1.60&ty=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.59 ZendEngine2/zend_vm_opcodes.h:1.60 --- ZendEngine2/zend_vm_opcodes.h:1.59 Fri Sep 23 05:38:37 2005 +++ ZendEngine2/zend_vm_opcodes.h Tue Sep 27 03:59:01 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_opcodes.h,v 1.59 2005/09/23 09:38:37 tony2001 Exp $ */ +/* $Id: zend_vm_opcodes.h,v 1.60 2005/09/27 07:59:01 dmitry Exp $ */ #define ZEND_NOP 0 #define ZEND_ADD 1 http://cvs.php.net/diff.php/ZendEngine2/tests/bug26166.phpt?r1=1.2&r2=1.3&ty=u Index: ZendEngine2/tests/bug26166.phpt diff -u ZendEngine2/tests/bug26166.phpt:1.2 ZendEngine2/tests/bug26166.phpt:1.3 --- ZendEngine2/tests/bug26166.phpt:1.2 Mon Dec 22 17:50:02 2003 +++ ZendEngine2/tests/bug26166.phpt Tue Sep 27 03:59:01 2005 @@ -64,4 +64,4 @@ Got the exception ===NONE=== -Fatal error: Method None::__toString() must return a string value in %sbug26166.php on line %d +Catchable fatal error: Method None::__toString() must return a string value in %sbug26166.php on line %d
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2065&r2=1.2066&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.2065 php-src/NEWS:1.2066 --- php-src/NEWS:1.2065 Sun Sep 18 23:21:34 2005 +++ php-src/NEWS Tue Sep 27 03:58:59 2005 @@ -2,6 +2,8 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 6.0 - Unicode support. (Andrei, Dmitriy, et al) +- Changed __toString() behavior to call it in all necessary places + (Marcus, Dmitry) - Changed "instanceof" and "catch" operators, is_a() and is_subclass_of() functions to not call __autoload(). (Dmitry) - cURL improvements: (Ilia) http://cvs.php.net/diff.php/ZendEngine2/zend.c?r1=1.323&r2=1.324&ty=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.323 ZendEngine2/zend.c:1.324 --- ZendEngine2/zend.c:1.323 Thu Sep 15 12:19:41 2005 +++ ZendEngine2/zend.c Tue Sep 27 03:58:59 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.323 2005/09/15 16:19:41 derick Exp $ */ +/* $Id: zend.c,v 1.324 2005/09/27 07:58:59 dmitry Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -347,39 +347,28 @@ case IS_OBJECT: { TSRMLS_FETCH(); -#if 0 - /* Standard PHP objects */ - if (Z_OBJ_HT_P(expr) == &std_object_handlers || !Z_OBJ_HT_P(expr)->cast_object) { - if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - break; - } - zend_error(E_NOTICE, "Object of class %v could not be converted to string", Z_OBJCE_P(expr)->name); - } -#endif if (Z_OBJ_HANDLER_P(expr, cast_object)) { if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { break; } - } else { - if(Z_OBJ_HANDLER_P(expr, get)) { - zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); - if(Z_TYPE_P(z) != IS_OBJECT) { - zend_make_printable_zval(z, expr_copy, use_copy); - FREE_ZVAL(z); - return; - } + } + if (Z_OBJ_HANDLER_P(expr, get)) { + zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); + if(Z_TYPE_P(z) != IS_OBJECT) { + zend_make_printable_zval(z, expr_copy, use_copy); + FREE_ZVAL(z); + break; } } if (EG(exception)) { - zval_dtor(expr_copy); expr_copy->value.str.len = 0; expr_copy->value.str.val = STR_EMPTY_ALLOC(); break; } + } expr_copy->value.str.val = (char *) emalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG); expr_copy->value.str.len = sprintf(expr_copy->value.str.val, "Object id #%ld", (long)expr->value.obj.handle); - expr_copy->type = IS_STRING; break; default: *expr_copy = *expr; @@ -387,6 +376,7 @@ convert_to_string(expr_copy); break; } + expr_copy->type = IS_STRING; *use_copy = 1; } @@ -426,40 +416,26 @@ expr_copy->value.str.val = estrndup("Array", expr_copy->value.str.len); break; case IS_OBJECT: - { -#if 0 - /* Standard PHP objects */ - if (Z_OBJ_HT_P(expr) == &std_object_handlers || !Z_OBJ_HT_P(expr)->cast_object) { - if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - break; - } - zend_error(E_NOTICE, "Object of class %v could not be converted to string", Z_OBJCE_P(expr)->name); - } -#endif - if (Z_OBJ_HANDLER_P(expr, cast_object)) { - if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - break; - } - } else { - if(Z_OBJ_HANDLER_P(expr, get)) { - zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); - if(Z_TYPE_P(z) != IS_OBJECT) { - zend_make_printable_zval(z, expr_copy, use_copy); - FREE_ZVAL(z); - return; - } - } + if (Z_OBJ_HANDLER_P(expr, cast_object)) { + if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { + break; } - if (EG(exception)) { - zval_dtor(expr_copy); - expr_copy->value.str.len = 0; - expr_copy->value.str.val = STR_EMPTY_ALLOC(); + } + if (Z_OBJ_HANDLER_P(expr, get)) { + zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); + if(Z_TYPE_P(z) != IS_OBJECT) { + zend_make_printable_zval(z, expr_copy, use_copy); + FREE_ZVAL(z); break; } } + if (EG(exception)) { + expr_copy->value.str.len = 0; + expr_copy->value.str.val = STR_EMPTY_ALLOC(); + break; + } expr_copy->value.str.val = (char *) emalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG); expr_copy->value.str.len = sprintf(expr_copy->value.str.val, "Object id #%ld", (long)expr->value.obj.handle); - expr_copy->type = IS_STRING; break; case IS_DOUBLE: *expr_copy = *expr; @@ -491,40 +467,26 @@ } switch (expr->type) { case IS_OBJECT: - { -#if 0 - /* Standard PHP objects */ - if (Z_OBJ_HT_P(expr) == &std_object_handlers || !Z_OBJ_HT_P(expr)->cast_object) { - if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - break; - } - zend_error(E_NOTICE, "Object of class %v could not be converted to string", Z_OBJCE_P(expr)->name); - } -#endif - if (Z_OBJ_HANDLER_P(expr, cast_object)) { - if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_UNICODE, 0 TSRMLS_CC) == SUCCESS) { - break; - } - } else { - if(Z_OBJ_HANDLER_P(expr, get)) { - zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); - if(Z_TYPE_P(z) != IS_OBJECT) { - zend_make_unicode_zval(z, expr_copy, use_copy); - FREE_ZVAL(z); - return; - } - } + if (Z_OBJ_HANDLER_P(expr, cast_object)) { + if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_UNICODE, 0 TSRMLS_CC) == SUCCESS) { + break; } - if (EG(exception)) { - zval_dtor(expr_copy); - expr_copy->value.ustr.len = 0; - expr_copy->value.ustr.val = USTR_MAKE(""); + } + if (Z_OBJ_HANDLER_P(expr, get)) { + zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); + if(Z_TYPE_P(z) != IS_OBJECT) { + zend_make_unicode_zval(z, expr_copy, use_copy); + FREE_ZVAL(z); break; } } - expr_copy->value.ustr.val = emalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG + 1); + if (EG(exception)) { + expr_copy->value.ustr.len = 0; + expr_copy->value.ustr.val = USTR_MAKE(""); + break; + } + expr_copy->value.ustr.val = eumalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG + 1); expr_copy->value.ustr.len = u_sprintf(expr_copy->value.ustr.val, "Object id #%ld", (long)expr->value.obj.handle); - expr_copy->type = IS_UNICODE; break; default: *expr_copy = *expr; @@ -532,6 +494,7 @@ convert_to_unicode(expr_copy); break; } + expr_copy->type = IS_UNICODE; *use_copy = 1; } @@ -969,6 +932,8 @@ ce->__isset = ce->__isset->common.u_twin; } else if (ce->__call) { ce->__call = ce->__call->common.u_twin; + } else if (ce->__tostring) { + ce->__tostring = ce->__tostring->common.u_twin; } else if (ce->serialize_func) { ce->serialize_func = ce->serialize_func->common.u_twin; } else if (ce->unserialize_func) { http://cvs.php.net/diff.php/ZendEngine2/zend.h?r1=1.299&r2=1.300&ty=u Index: ZendEngine2/zend.h diff -u ZendEngine2/zend.h:1.299 ZendEngine2/zend.h:1.300 --- ZendEngine2/zend.h:1.299 Thu Sep 1 06:04:54 2005 +++ ZendEngine2/zend.h Tue Sep 27 03:58:59 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.299 2005/09/01 10:04:54 dmitry Exp $ */ +/* $Id: zend.h,v 1.300 2005/09/27 07:58:59 dmitry Exp $ */ #ifndef ZEND_H #define ZEND_H @@ -360,6 +360,7 @@ union _zend_function *__unset; union _zend_function *__isset; union _zend_function *__call; + union _zend_function *__tostring; union _zend_function *serialize_func; union _zend_function *unserialize_func; http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.315&r2=1.316&ty=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.315 ZendEngine2/zend_API.c:1.316 --- ZendEngine2/zend_API.c:1.315 Thu Sep 1 06:04:55 2005 +++ ZendEngine2/zend_API.c Tue Sep 27 03:58:59 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.315 2005/09/01 10:04:55 dmitry Exp $ */ +/* $Id: zend_API.c,v 1.316 2005/09/27 07:58:59 dmitry Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -2022,6 +2022,9 @@ } else if (lcname_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && ZEND_U_EQUAL(utype, lcname, lcname_len, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1) && fptr->common.num_args != 2) { zend_error(error_type, "Method %v::%s() must take exactly 2 arguments", ce->name, ZEND_CALL_FUNC_NAME); + } else if (lcname_len == sizeof(ZEND_TOSTRING_FUNC_NAME) - 1 && + ZEND_U_EQUAL(utype, lcname, lcname_len, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && fptr->common.num_args != 0) { + zend_error(error_type, "Method %v::%s() cannot take arguments", ce->name, ZEND_CALL_FUNC_NAME); } efree(lcname); } @@ -2035,7 +2038,7 @@ int count=0, unload=0; HashTable *target_function_table = function_table; int error_type; - zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL; + zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__tostring = NULL; char *lowercase_name; int fname_len; char *lc_class_name; @@ -2139,6 +2142,8 @@ clone = reg_function; } else if ((fname_len == sizeof(ZEND_CALL_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME))) { __call = reg_function; + } else if ((fname_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME))) { + __tostring = reg_function; } else if ((fname_len == sizeof(ZEND_GET_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME))) { __get = reg_function; } else if ((fname_len == sizeof(ZEND_SET_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME))) { @@ -2176,6 +2181,7 @@ scope->destructor = dtor; scope->clone = clone; scope->__call = __call; + scope->__tostring = __tostring; scope->__get = __get; scope->__set = __set; scope->__unset = __unset; @@ -2207,6 +2213,12 @@ } __call->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } + if (__tostring) { + if (__tostring->common.fn_flags & ZEND_ACC_STATIC) { + zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __tostring->common.function_name); + } + __tostring->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; + } if (__get) { if (__get->common.fn_flags & ZEND_ACC_STATIC) { zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __get->common.function_name); http://cvs.php.net/diff.php/ZendEngine2/zend_API.h?r1=1.221&r2=1.222&ty=u Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.221 ZendEngine2/zend_API.h:1.222 --- ZendEngine2/zend_API.h:1.221 Fri Sep 23 18:49:57 2005 +++ ZendEngine2/zend_API.h Tue Sep 27 03:58:59 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.h,v 1.221 2005/09/23 22:49:57 helly Exp $ */ +/* $Id: zend_API.h,v 1.222 2005/09/27 07:58:59 dmitry Exp $ */ #ifndef ZEND_API_H #define ZEND_API_H @@ -131,6 +131,7 @@ class_container.create_object = NULL; \ class_container.interface_gets_implemented = NULL; \ class_container.__call = handle_fcall; \ + class_container.__tostring = NULL; \ class_container.__get = handle_propget; \ class_container.__set = handle_propset; \ class_container.__unset = handle_propunset; \ http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.663&r2=1.664&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.663 ZendEngine2/zend_compile.c:1.664 --- ZendEngine2/zend_compile.c:1.663 Fri Sep 16 09:42:31 2005 +++ ZendEngine2/zend_compile.c Tue Sep 27 03:58:59 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.663 2005/09/16 13:42:31 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.664 2005/09/27 07:58:59 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1163,6 +1163,8 @@ CG(active_class_entry)->__unset = (zend_function *) CG(active_op_array); } else if ((lcname_len == sizeof(ZEND_ISSET_FUNC_NAME)-1) && (ZEND_U_EQUAL(Z_TYPE(function_name->u.constant), lcname, lcname_len, ZEND_ISSET_FUNC_NAME, sizeof(ZEND_ISSET_FUNC_NAME)-1))) { CG(active_class_entry)->__isset = (zend_function *) CG(active_op_array); + } else if ((lcname_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && (ZEND_U_EQUAL(Z_TYPE(function_name->u.constant), lcname, lcname_len, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME)-1))) { + CG(active_class_entry)->__tostring = (zend_function *) CG(active_op_array); } else if (!(fn_flags & ZEND_ACC_STATIC)) { CG(active_op_array)->fn_flags |= ZEND_ACC_ALLOW_STATIC; } @@ -1873,6 +1875,9 @@ if (!ce->__call) { ce->__call = ce->parent->__call; } + if (!ce->__tostring) { + ce->__tostring = ce->parent->__tostring; + } if (!ce->clone) { ce->clone = ce->parent->clone; } @@ -4152,6 +4157,7 @@ ce->__unset = NULL; ce->__isset = NULL; ce->__call = NULL; + ce->__tostring = NULL; ce->create_object = NULL; ce->get_iterator = NULL; ce->iterator_funcs.funcs = NULL; http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.324&r2=1.325&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.324 ZendEngine2/zend_compile.h:1.325 --- ZendEngine2/zend_compile.h:1.324 Fri Sep 23 18:55:10 2005 +++ ZendEngine2/zend_compile.h Tue Sep 27 03:59:00 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.324 2005/09/23 22:55:10 helly Exp $ */ +/* $Id: zend_compile.h,v 1.325 2005/09/27 07:59:00 dmitry Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -723,6 +723,7 @@ #define ZEND_UNSET_FUNC_NAME "__unset" #define ZEND_ISSET_FUNC_NAME "__isset" #define ZEND_CALL_FUNC_NAME "__call" +#define ZEND_TOSTRING_FUNC_NAME "__tostring" #define ZEND_AUTOLOAD_FUNC_NAME "__autoload" #endif /* ZEND_COMPILE_H */ http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.146&r2=1.147&ty=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.146 ZendEngine2/zend_object_handlers.c:1.147 --- ZendEngine2/zend_object_handlers.c:1.146 Thu Sep 1 06:05:00 2005 +++ ZendEngine2/zend_object_handlers.c Tue Sep 27 03:59:00 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.146 2005/09/01 10:05:00 dmitry Exp $ */ +/* $Id: zend_object_handlers.c,v 1.147 2005/09/27 07:59:00 dmitry Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -1008,37 +1008,30 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC) { - zval fname, *retval; + zval *retval; + zend_class_entry *ce; switch (type) { case IS_STRING: case IS_UNICODE: - if (!zend_hash_exists(&Z_OBJCE_P(readobj)->function_table, "__tostring", sizeof("__tostring"))) { - return FAILURE; - } - ZVAL_ASCII_STRING(&fname, "__tostring", 0); - if (call_user_function_ex(NULL, &readobj, &fname, &retval, 0, NULL, 0, NULL TSRMLS_CC) == SUCCESS) { - if (UG(unicode)) { - zval_dtor(&fname); - } - if (retval) { - if (Z_TYPE_P(retval) != (UG(unicode)?IS_UNICODE:IS_STRING)) { - zend_error(E_ERROR, "Method %v::__toString() must return a string value", Z_OBJCE_P(readobj)->name); + ce = Z_OBJCE_P(readobj); + if (ce->__tostring && + zend_call_method_with_0_params(&readobj, ce, &ce->__tostring, "__tostring", &retval)) { + if (Z_TYPE_P(retval) == (UG(unicode)?IS_UNICODE:IS_STRING)) { + *writeobj = *retval; + zval_copy_ctor(writeobj); + zval_ptr_dtor(&retval); + INIT_PZVAL(writeobj); + if (Z_TYPE_P(writeobj) != type) { + convert_to_explicit_type(writeobj, type); } + return SUCCESS; } else { - MAKE_STD_ZVAL(retval); - ZVAL_ASCII_STRINGL(retval, "", 0, 1); + zval_ptr_dtor(&retval); + zend_error(E_RECOVERABLE_ERROR, "Method %v::__toString() must return a string value", ce->name); } - *writeobj = *retval; - zval_copy_ctor(writeobj); - INIT_PZVAL(writeobj); - zval_ptr_dtor(&retval); - return SUCCESS; - } - if (UG(unicode)) { - zval_dtor(&fname); } - break; + return FAILURE; default: break; } @@ -1069,7 +1062,7 @@ zend_std_object_get_class, /* get_class_entry */ zend_std_object_get_class_name, /* get_class_name */ zend_std_compare_objects, /* compare_objects */ - NULL, /* cast_object */ + zend_std_cast_object_tostring, /* cast_object */ NULL, /* count_elements */ }; http://cvs.php.net/diff.php/ZendEngine2/zend_vm_def.h?r1=1.79&r2=1.80&ty=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.79 ZendEngine2/zend_vm_def.h:1.80 --- ZendEngine2/zend_vm_def.h:1.79 Fri Sep 23 05:38:36 2005 +++ ZendEngine2/zend_vm_def.h Tue Sep 27 03:59:00 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.79 2005/09/23 09:38:36 tony2001 Exp $ */ +/* $Id: zend_vm_def.h,v 1.80 2005/09/27 07:59:00 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -884,34 +884,28 @@ zend_free_op free_op1; zval z_copy; zval *z = GET_OP1_ZVAL_PTR(BP_VAR_R); + UErrorCode status = U_ZERO_ERROR; - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, UG(unicode) ? IS_UNICODE : IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - UErrorCode status = U_ZERO_ERROR; - /* Convert inline HTML blocks to the output encoding, but only if necessary. */ - if (opline->extended_value && - strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - EG(active_op_array)->script_encoding)) { - zval z_conv; - UConverter *script_enc_conv = NULL; - if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { - zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); - } - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); - z_conv.type = IS_BINARY; - if (U_SUCCESS(status)) { - zend_print_variable(&z_conv); - } else { - zend_error(E_WARNING, "Could not convert inline HTML for output"); - } - zval_dtor(&z_conv); - ucnv_close(script_enc_conv); + /* Convert inline HTML blocks to the output encoding, but only if necessary. */ + if (opline->extended_value && + strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), + EG(active_op_array)->script_encoding)) { + zval z_conv; + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + z_conv.type = IS_BINARY; + if (U_SUCCESS(status)) { + zend_print_variable(&z_conv); } else { - zend_print_variable(z); + zend_error(E_WARNING, "Could not convert inline HTML for output"); } + zval_dtor(&z_conv); + ucnv_close(script_enc_conv); + } else { + zend_print_variable(z); } FREE_OP1(); http://cvs.php.net/diff.php/ZendEngine2/zend_vm_execute.h?r1=1.82&r2=1.83&ty=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.82 ZendEngine2/zend_vm_execute.h:1.83 --- ZendEngine2/zend_vm_execute.h:1.82 Fri Sep 23 05:38:35 2005 +++ ZendEngine2/zend_vm_execute.h Tue Sep 27 03:59:00 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_execute.h,v 1.82 2005/09/23 09:38:35 tony2001 Exp $ */ +/* $Id: zend_vm_execute.h,v 1.83 2005/09/27 07:59:00 dmitry Exp $ */ static opcode_handler_t zend_user_opcode_handlers[256] = {(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL}; @@ -1367,34 +1367,28 @@ zval z_copy; zval *z = &opline->op1.u.constant; + UErrorCode status = U_ZERO_ERROR; - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, UG(unicode) ? IS_UNICODE : IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - UErrorCode status = U_ZERO_ERROR; - /* Convert inline HTML blocks to the output encoding, but only if necessary. */ - if (opline->extended_value && - strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - EG(active_op_array)->script_encoding)) { - zval z_conv; - UConverter *script_enc_conv = NULL; - if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { - zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); - } - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); - z_conv.type = IS_BINARY; - if (U_SUCCESS(status)) { - zend_print_variable(&z_conv); - } else { - zend_error(E_WARNING, "Could not convert inline HTML for output"); - } - zval_dtor(&z_conv); - ucnv_close(script_enc_conv); + /* Convert inline HTML blocks to the output encoding, but only if necessary. */ + if (opline->extended_value && + strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), + EG(active_op_array)->script_encoding)) { + zval z_conv; + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + z_conv.type = IS_BINARY; + if (U_SUCCESS(status)) { + zend_print_variable(&z_conv); } else { - zend_print_variable(z); + zend_error(E_WARNING, "Could not convert inline HTML for output"); } + zval_dtor(&z_conv); + ucnv_close(script_enc_conv); + } else { + zend_print_variable(z); } ZEND_VM_NEXT_OPCODE(); @@ -3879,34 +3873,28 @@ zend_free_op free_op1; zval z_copy; zval *z = _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); + UErrorCode status = U_ZERO_ERROR; - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, UG(unicode) ? IS_UNICODE : IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - UErrorCode status = U_ZERO_ERROR; - /* Convert inline HTML blocks to the output encoding, but only if necessary. */ - if (opline->extended_value && - strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - EG(active_op_array)->script_encoding)) { - zval z_conv; - UConverter *script_enc_conv = NULL; - if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { - zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); - } - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); - z_conv.type = IS_BINARY; - if (U_SUCCESS(status)) { - zend_print_variable(&z_conv); - } else { - zend_error(E_WARNING, "Could not convert inline HTML for output"); - } - zval_dtor(&z_conv); - ucnv_close(script_enc_conv); + /* Convert inline HTML blocks to the output encoding, but only if necessary. */ + if (opline->extended_value && + strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), + EG(active_op_array)->script_encoding)) { + zval z_conv; + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + z_conv.type = IS_BINARY; + if (U_SUCCESS(status)) { + zend_print_variable(&z_conv); } else { - zend_print_variable(z); + zend_error(E_WARNING, "Could not convert inline HTML for output"); } + zval_dtor(&z_conv); + ucnv_close(script_enc_conv); + } else { + zend_print_variable(z); } zval_dtor(free_op1.var); @@ -6930,34 +6918,28 @@ zend_free_op free_op1; zval z_copy; zval *z = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); + UErrorCode status = U_ZERO_ERROR; - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, UG(unicode) ? IS_UNICODE : IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - UErrorCode status = U_ZERO_ERROR; - /* Convert inline HTML blocks to the output encoding, but only if necessary. */ - if (opline->extended_value && - strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - EG(active_op_array)->script_encoding)) { - zval z_conv; - UConverter *script_enc_conv = NULL; - if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { - zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); - } - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); - z_conv.type = IS_BINARY; - if (U_SUCCESS(status)) { - zend_print_variable(&z_conv); - } else { - zend_error(E_WARNING, "Could not convert inline HTML for output"); - } - zval_dtor(&z_conv); - ucnv_close(script_enc_conv); + /* Convert inline HTML blocks to the output encoding, but only if necessary. */ + if (opline->extended_value && + strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), + EG(active_op_array)->script_encoding)) { + zval z_conv; + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + z_conv.type = IS_BINARY; + if (U_SUCCESS(status)) { + zend_print_variable(&z_conv); } else { - zend_print_variable(z); + zend_error(E_WARNING, "Could not convert inline HTML for output"); } + zval_dtor(&z_conv); + ucnv_close(script_enc_conv); + } else { + zend_print_variable(z); } if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -19709,34 +19691,28 @@ zval z_copy; zval *z = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC); + UErrorCode status = U_ZERO_ERROR; - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, UG(unicode) ? IS_UNICODE : IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - UErrorCode status = U_ZERO_ERROR; - /* Convert inline HTML blocks to the output encoding, but only if necessary. */ - if (opline->extended_value && - strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - EG(active_op_array)->script_encoding)) { - zval z_conv; - UConverter *script_enc_conv = NULL; - if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { - zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); - } - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); - z_conv.type = IS_BINARY; - if (U_SUCCESS(status)) { - zend_print_variable(&z_conv); - } else { - zend_error(E_WARNING, "Could not convert inline HTML for output"); - } - zval_dtor(&z_conv); - ucnv_close(script_enc_conv); + /* Convert inline HTML blocks to the output encoding, but only if necessary. */ + if (opline->extended_value && + strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), + EG(active_op_array)->script_encoding)) { + zval z_conv; + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + z_conv.type = IS_BINARY; + if (U_SUCCESS(status)) { + zend_print_variable(&z_conv); } else { - zend_print_variable(z); + zend_error(E_WARNING, "Could not convert inline HTML for output"); } + zval_dtor(&z_conv); + ucnv_close(script_enc_conv); + } else { + zend_print_variable(z); } ZEND_VM_NEXT_OPCODE(); http://cvs.php.net/diff.php/ZendEngine2/zend_vm_opcodes.h?r1=1.59&r2=1.60&ty=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.59 ZendEngine2/zend_vm_opcodes.h:1.60 --- ZendEngine2/zend_vm_opcodes.h:1.59 Fri Sep 23 05:38:37 2005 +++ ZendEngine2/zend_vm_opcodes.h Tue Sep 27 03:59:01 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_opcodes.h,v 1.59 2005/09/23 09:38:37 tony2001 Exp $ */ +/* $Id: zend_vm_opcodes.h,v 1.60 2005/09/27 07:59:01 dmitry Exp $ */ #define ZEND_NOP 0 #define ZEND_ADD 1 http://cvs.php.net/diff.php/ZendEngine2/tests/bug26166.phpt?r1=1.2&r2=1.3&ty=u Index: ZendEngine2/tests/bug26166.phpt diff -u ZendEngine2/tests/bug26166.phpt:1.2 ZendEngine2/tests/bug26166.phpt:1.3 --- ZendEngine2/tests/bug26166.phpt:1.2 Mon Dec 22 17:50:02 2003 +++ ZendEngine2/tests/bug26166.phpt Tue Sep 27 03:59:01 2005 @@ -64,4 +64,4 @@ Got the exception ===NONE=== -Fatal error: Method None::__toString() must return a string value in %sbug26166.php on line %d +Catchable fatal error: Method None::__toString() must return a string value in %sbug26166.php on line %d