diff options
author | Derick Rethans <derick@php.net> | 2001-11-26 21:04:21 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2001-11-26 21:04:21 +0000 |
commit | 06cdf297a8802e59ae8947e66022ba6fa240ea0f (patch) | |
tree | d5469d7364793aa41177926edf7970f238ce6038 /ext/standard/var_unserializer.c | |
parent | b91a66699cba1aabc63ba381fc7e31ff402ceffb (diff) | |
download | php-git-06cdf297a8802e59ae8947e66022ba6fa240ea0f.tar.gz |
- Adding a callback mechanism to the unserializer. (patch by Bernd
Roemer <berndr@bonn.edu>)
#- An explainatory e-mail will be send to php-dev
Diffstat (limited to 'ext/standard/var_unserializer.c')
-rw-r--r-- | ext/standard/var_unserializer.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index cbc00fbb19..ef3f2b8d57 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -371,6 +371,13 @@ yy20: zend_class_entry *ce; int incomplete_class = 0; + char *rval_temp; + + zval *user_func; + zval *retval_ptr; + zval **args[1]; + zval *arg_func_name; + INIT_PZVAL(*rval); len2 = len = parse_iv(start + 2); if (len == 0) @@ -385,12 +392,34 @@ yy20: } } - if (zend_hash_find(EG(class_table), class_name, len2 + 1, (void **) &ce) != SUCCESS) { - incomplete_class = 1; - ce = PHP_IC_ENTRY; - } else + if (zend_hash_find(CG(class_table), class_name, len2 + 1, (void **) &ce) != SUCCESS) { + if (PG(unserialize_callback_func) == NULL) { + incomplete_class = 1; + ce = PHP_IC_ENTRY; + } else { + MAKE_STD_ZVAL(user_func); + ZVAL_STRING(user_func, PG(unserialize_callback_func), 1); + + args[0] = &arg_func_name; + MAKE_STD_ZVAL(arg_func_name); + ZVAL_STRING(arg_func_name, class_name, 1); + + if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { + zend_error(E_WARNING, "'unserialize_callback_func' defined (%s) but not found", user_func->value.str.val); + incomplete_class = 1; + ce = PHP_IC_ENTRY; + } else { + if (zend_hash_find(CG(class_table), class_name, len2 + 1, (void **) &ce) != SUCCESS) { + zend_error(E_WARNING, "'unserialize_callback_func' (%s) hasn't defined the class it was called for", user_func->value.str.val); + incomplete_class = 1; + ce = PHP_IC_ENTRY; + } else + efree(class_name); + } + } + } else efree(class_name); - + *p = YYCURSOR; elements = object_common1(UNSERIALIZE_PASSTHRU, ce); |