]> granicus.if.org Git - php/commitdiff
MFH:
authorWez Furlong <wez@php.net>
Wed, 28 Jul 2004 23:48:26 +0000 (23:48 +0000)
committerWez Furlong <wez@php.net>
Wed, 28 Jul 2004 23:48:26 +0000 (23:48 +0000)
#29258: variant_date_from_timestamp() does not honour timezone
#29392: com_dotnet crashes when echo'ing an object

ext/com_dotnet/com_extension.c
ext/com_dotnet/com_handlers.c
ext/com_dotnet/com_variant.c
ext/com_dotnet/com_wrapper.c

index 51484514605c6b098ca474720b52158eed49879b..c4679a82eecf110929052382e8f89c9496f80d7e 100644 (file)
@@ -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);
index cfe15d43555f6e73e0f0bbb5e1dc3c29edeacfd0..cee0b41017598466f28be8fca638bfc50ab682b2 100644 (file)
@@ -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)
index bf401f82e83ed6d604568d8c9f46b15c0f883fa0..345591306afbe24230cda83eb6227090a1ca1159 100644 (file)
@@ -799,7 +799,8 @@ PHP_FUNCTION(variant_date_from_timestamp)
        }
 
        VariantInit(&res);
-       tmv = gmtime(&timestamp);
+       tzset();
+       tmv = localtime(&timestamp);
        memset(&systime, 0, sizeof(systime));
 
        systime.wDay = tmv->tm_mday;
index 4ca96cc8c5f76799a13b5c213585bb9bff4b85b4..0a35d26d8d962d207fc1256fd07cb7b38ebf2d30 100644 (file)
@@ -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);
                }