--- embedaddon/php/ext/intl/msgformat/msgformat_class.c 2012/02/21 23:47:56 1.1 +++ embedaddon/php/ext/intl/msgformat/msgformat_class.c 2013/07/22 01:31:52 1.1.1.3 @@ -24,6 +24,8 @@ #include "msgformat.h" #include "msgformat_attr.h" +#include + zend_class_entry *MessageFormatter_ce_ptr = NULL; static zend_object_handlers MessageFormatter_handlers; @@ -60,6 +62,7 @@ zend_object_value MessageFormatter_object_create(zend_ intern = ecalloc( 1, sizeof(MessageFormatter_object) ); msgformat_data_init( &intern->mf_data TSRMLS_CC ); zend_object_std_init( &intern->zo, ce TSRMLS_CC ); + object_properties_init(&intern->zo, ce); retval.handle = zend_objects_store_put( intern, @@ -80,18 +83,24 @@ zend_object_value MessageFormatter_object_clone(zval * zend_object_handle handle = Z_OBJ_HANDLE_P(object); MessageFormatter_object *mfo, *new_mfo; - MSG_FORMAT_METHOD_FETCH_OBJECT; - new_obj_val = MessageFormatter_ce_ptr->create_object(MessageFormatter_ce_ptr TSRMLS_CC); + MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; + new_obj_val = MessageFormatter_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC); new_mfo = (MessageFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC); /* clone standard parts */ zend_objects_clone_members(&new_mfo->zo, new_obj_val, &mfo->zo, handle TSRMLS_CC); + /* clone formatter object */ - MSG_FORMAT_OBJECT(new_mfo) = umsg_clone(MSG_FORMAT_OBJECT(mfo), &INTL_DATA_ERROR_CODE(new_mfo)); - if(U_FAILURE(INTL_DATA_ERROR_CODE(new_mfo))) { - /* set up error in case error handler is interested */ - intl_error_set( NULL, INTL_DATA_ERROR_CODE(new_mfo), "Failed to clone MessageFormatter object", 0 TSRMLS_CC ); - MessageFormatter_object_dtor(new_mfo, new_obj_val.handle TSRMLS_CC); /* free new object */ - zend_error(E_ERROR, "Failed to clone MessageFormatter object"); + if (MSG_FORMAT_OBJECT(mfo) != NULL) { + MSG_FORMAT_OBJECT(new_mfo) = umsg_clone(MSG_FORMAT_OBJECT(mfo), + &INTL_DATA_ERROR_CODE(mfo)); + + if (U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) { + intl_errors_set(INTL_DATA_ERROR_P(mfo), INTL_DATA_ERROR_CODE(mfo), + "Failed to clone MessageFormatter object", 0 TSRMLS_CC); + zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Failed to clone MessageFormatter object"); + } + } else { + zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Cannot clone unconstructed MessageFormatter"); } return new_obj_val; } @@ -132,7 +141,7 @@ ZEND_END_ARG_INFO() /* {{{ MessageFormatter_class_functions * Every 'MessageFormatter' class method has an entry in this table */ -static function_entry MessageFormatter_class_functions[] = { +static zend_function_entry MessageFormatter_class_functions[] = { PHP_ME( MessageFormatter, __construct, arginfo_messageformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR ) ZEND_FENTRY( create, ZEND_FN( msgfmt_create ), arginfo_messageformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) PHP_NAMED_FE( format, ZEND_FN( msgfmt_format ), arginfo_messageformatter_format )