diff options
author | Stefan Marr <gron@php.net> | 2010-06-08 15:56:36 +0000 |
---|---|---|
committer | Stefan Marr <gron@php.net> | 2010-06-08 15:56:36 +0000 |
commit | e6bd5368ad144267c2b7263d84b7d2159c3d2548 (patch) | |
tree | 2cfe42d0ca4830eaeffa5d800577085cbdfb3e60 /Zend/zend_variables.c | |
parent | df3b9225fd219583865f2d053e37c54863362c33 (diff) | |
download | php-git-e6bd5368ad144267c2b7263d84b7d2159c3d2548.tar.gz |
Fixed issue with statics in traits.
#Please review this change, I moved the routine which copies statics from the closure code to zend_variables.c
#Please also have a look to check whether the TSRMLS_DC is correct, and whether it fits with the rest in zend_variables, because there you are using some macro magic and I am not exactly sure what the reason is for that.
Diffstat (limited to 'Zend/zend_variables.c')
-rw-r--r-- | Zend/zend_variables.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index f6f1ea728e..67b08b4802 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -188,6 +188,43 @@ ZEND_API void _zval_internal_ptr_dtor_wrapper(zval **zval_ptr) } #endif +ZEND_API int zval_copy_static_var(zval **p TSRMLS_DC, int num_args, va_list args, zend_hash_key *key) /* {{{ */ +{ + HashTable *target = va_arg(args, HashTable*); + zend_bool is_ref; + + if (Z_TYPE_PP(p) & (IS_LEXICAL_VAR|IS_LEXICAL_REF)) { + is_ref = Z_TYPE_PP(p) & IS_LEXICAL_REF; + + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + } + if (zend_hash_quick_find(EG(active_symbol_table), key->arKey, key->nKeyLength, key->h, (void **) &p) == FAILURE) { + if (is_ref) { + zval *tmp; + + ALLOC_INIT_ZVAL(tmp); + Z_SET_ISREF_P(tmp); + zend_hash_quick_add(EG(active_symbol_table), key->arKey, key->nKeyLength, key->h, &tmp, sizeof(zval*), (void**)&p); + } else { + p = &EG(uninitialized_zval_ptr); + zend_error(E_NOTICE,"Undefined variable: %s", key->arKey); + } + } else { + if (is_ref) { + SEPARATE_ZVAL_TO_MAKE_IS_REF(p); + } else if (Z_ISREF_PP(p)) { + SEPARATE_ZVAL(p); + } + } + } + if (zend_hash_quick_add(target, key->arKey, key->nKeyLength, key->h, p, sizeof(zval*), NULL) == SUCCESS) { + Z_ADDREF_PP(p); + } + return ZEND_HASH_APPLY_KEEP; +} +/* }}} */ + /* * Local variables: * tab-width: 4 |