From: Wez Furlong Date: Wed, 28 Jul 2004 23:48:26 +0000 (+0000) Subject: MFH: X-Git-Tag: php-5.0.1RC1~61 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f916456421c00e59cd08cb5d1cf193f97286caa;p=php MFH: #29258: variant_date_from_timestamp() does not honour timezone #29392: com_dotnet crashes when echo'ing an object --- diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c index 5148451460..c4679a82ee 100644 --- a/ext/com_dotnet/com_extension.c +++ b/ext/com_dotnet/com_extension.c @@ -194,7 +194,7 @@ PHP_MINIT_FUNCTION(com_dotnet) INIT_CLASS_ENTRY(ce, "com_exception", NULL); php_com_exception_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(), NULL TSRMLS_CC); php_com_exception_class_entry->ce_flags |= ZEND_ACC_FINAL; - php_com_exception_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED; +// php_com_exception_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED; INIT_CLASS_ENTRY(ce, "com_safearray_proxy", NULL); php_com_saproxy_class_entry = zend_register_internal_class(&ce TSRMLS_CC); diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index cfe15d4355..cee0b41017 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -286,11 +286,19 @@ static void function_dtor(void *pDest) } } +static PHP_FUNCTION(com_method_handler) +{ + Z_OBJ_HANDLER_P(getThis(), call_method)( + ((zend_internal_function*)EG(function_state_ptr)->function)->function_name, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + static union _zend_function *com_method_get(zval *object, char *name, int len TSRMLS_DC) { zend_internal_function f, *fptr = NULL; php_com_dotnet_object *obj; union _zend_function *func; + DISPID dummy; obj = CDNO_FETCH(object); @@ -298,6 +306,10 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS return NULL; } + if (FAILED(php_com_get_id_of_name(obj, name, len, &dummy TSRMLS_CC))) { + return NULL; + } + /* check cache */ if (obj->method_cache == NULL || FAILURE == zend_hash_find(obj->method_cache, name, len, (void**)&fptr)) { f.type = ZEND_OVERLOADED_FUNCTION; @@ -306,7 +318,10 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS f.scope = obj->ce; f.fn_flags = 0; f.function_name = estrndup(name, len); + f.handler = PHP_FN(com_method_handler); + fptr = &f; + if (obj->typeinfo) { /* look for byref params */ ITypeComp *comp; @@ -346,6 +361,9 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS case DESCKIND_TYPECOMP: ITypeComp_Release(bindptr.lptcomp); break; + + case DESCKIND_NONE: + break; } if (TI) { ITypeInfo_Release(TI); @@ -356,21 +374,27 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS } } - /* save this method in the cache */ - if (!obj->method_cache) { - ALLOC_HASHTABLE(obj->method_cache); - zend_hash_init(obj->method_cache, 2, NULL, function_dtor, 0); - } + if (fptr) { + /* save this method in the cache */ + if (!obj->method_cache) { + ALLOC_HASHTABLE(obj->method_cache); + zend_hash_init(obj->method_cache, 2, NULL, function_dtor, 0); + } - zend_hash_update(obj->method_cache, name, len, &f, sizeof(f), (void**)&fptr); + zend_hash_update(obj->method_cache, name, len, &f, sizeof(f), (void**)&fptr); + } } - /* duplicate this into a new chunk of emalloc'd memory, - * since the engine will efree it */ - func = emalloc(sizeof(*fptr)); - memcpy(func, fptr, sizeof(*fptr)); + if (fptr) { + /* duplicate this into a new chunk of emalloc'd memory, + * since the engine will efree it */ + func = emalloc(sizeof(*fptr)); + memcpy(func, fptr, sizeof(*fptr)); - return func; + return func; + } + + return NULL; } static int com_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c index bf401f82e8..345591306a 100644 --- a/ext/com_dotnet/com_variant.c +++ b/ext/com_dotnet/com_variant.c @@ -799,7 +799,8 @@ PHP_FUNCTION(variant_date_from_timestamp) } VariantInit(&res); - tmv = gmtime(×tamp); + tzset(); + tmv = localtime(×tamp); memset(&systime, 0, sizeof(systime)); systime.wDay = tmv->tm_mday; diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c index 4ca96cc8c5..0a35d26d8d 100644 --- a/ext/com_dotnet/com_wrapper.c +++ b/ext/com_dotnet/com_wrapper.c @@ -296,12 +296,16 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex( } else if (wFlags & DISPATCH_PROPERTYPUT) { zend_update_property(Z_OBJCE_P(disp->object), disp->object, Z_STRVAL_PP(name), Z_STRLEN_PP(name)+1, *params[0] TSRMLS_CC); } else if (wFlags & DISPATCH_METHOD) { - if (SUCCESS == call_user_function_ex(EG(function_table), &disp->object, *name, - &retval, pdp->cArgs, params, 1, NULL TSRMLS_CC)) { - ret = S_OK; - } else { + zend_try { + if (SUCCESS == call_user_function_ex(EG(function_table), &disp->object, *name, + &retval, pdp->cArgs, params, 1, NULL TSRMLS_CC)) { + ret = S_OK; + } else { + ret = DISP_E_EXCEPTION; + } + } zend_catch { ret = DISP_E_EXCEPTION; - } + } zend_end_try(); } else { trace("Don't know how to handle this invocation %08x\n", wFlags); }