From ff3b0c84a3a96ebd8e7a2bcdf32351c4d7fa29d9 Mon Sep 17 00:00:00 2001 From: Andrei Zmievski Date: Mon, 19 Jun 2000 14:04:57 +0000 Subject: [PATCH] Call __wakeup() after all the instance variables are initialized. --- ext/wddx/wddx.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index 069f928257..01ec184c85 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -606,6 +606,7 @@ static void php_wddx_push_element(void *user_data, const char *name, const char for (i=0; atts[i]; i++) { if (!strcmp(atts[i], EL_VERSION)) { + /* nothing for now */ } } } else if (!strcmp(name, EL_STRING)) { @@ -702,21 +703,39 @@ static void php_wddx_pop_element(void *user_data, const char *name) zval *obj; zval *tmp; ELS_FETCH(); + + if (stack->top == 0) + return; if (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) || !strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) || !strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT)) { + wddx_stack_top(stack, (void**)&ent1); + + /* Call __wakeup() method on the object. */ + if (ent1->data->type == IS_OBJECT) { + zval *fname, *retval = NULL; + + MAKE_STD_ZVAL(fname); + ZVAL_STRING(fname, "__wakeup", 1); + + call_user_function_ex(NULL, ent1->data, fname, &retval, 0, 0, 0, NULL); + + zval_dtor(fname); + FREE_ZVAL(fname); + if (retval) + zval_ptr_dtor(&retval); + } + if (stack->top > 1) { - wddx_stack_top(stack, (void**)&ent1); stack->top--; wddx_stack_top(stack, (void**)&ent2); if (ent2->data->type == IS_ARRAY || ent2->data->type == IS_OBJECT) { target_hash = HASH_OF(ent2->data); - + if (ent1->varname) { if (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) && ent1->data->type == IS_STRING && ent1->data->value.str.len) { - zval *fname, *retval = NULL; if (zend_hash_find(EG(class_table), ent1->data->value.str.val, ent1->data->value.str.len+1, (void **) &ce)==FAILURE) { @@ -745,17 +764,6 @@ static void php_wddx_pop_element(void *user_data, const char *name) /* Clean up class name var entry */ zval_dtor(ent1->data); efree(ent1->data); - - /* Call __wakeup() method on the object. */ - MAKE_STD_ZVAL(fname); - ZVAL_STRING(fname, "__wakeup", 1); - - call_user_function_ex(NULL, obj, fname, &retval, 0, 0, 0, NULL); - - zval_dtor(fname); - FREE_ZVAL(fname); - if (retval) - zval_ptr_dtor(&retval); } else zend_hash_update(target_hash, -- 2.40.0