diff options
| author | Dmitry Stogov <dmitry@zend.com> | 2013-03-19 17:04:35 +0400 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2013-03-19 17:04:35 +0400 |
| commit | 4837bdb91049e47e0c15873a2d1d4d1f7a4c65d2 (patch) | |
| tree | a53f36f6f09a454dfa10f491ef79331a51ecb1a4 /Zend/zend_API.c | |
| parent | 960d5be52873acdf1afc67aa12b72d2cdc93119c (diff) | |
| parent | 7b0993bfb4b19bb160a72310b907c4fc12a5bef9 (diff) | |
| download | php-git-4837bdb91049e47e0c15873a2d1d4d1f7a4c65d2.tar.gz | |
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
Fixed bug #63976 (Parent class incorrectly using child constant in class property)
Conflicts:
NEWS
Diffstat (limited to 'Zend/zend_API.c')
| -rw-r--r-- | Zend/zend_API.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 8c3a357954..18e7a36c96 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1051,6 +1051,40 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destro } /* }}} */ +static int zval_update_class_constant(zval **pp, int is_static, int offset TSRMLS_DC) /* {{{ */ +{ + if ((Z_TYPE_PP(pp) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT || + (Z_TYPE_PP(pp) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT_ARRAY) { + zend_class_entry **scope = EG(in_execution)?&EG(scope):&CG(active_class_entry); + + if ((*scope)->parent) { + zend_class_entry *ce = *scope; + HashPosition pos; + zend_property_info *prop_info; + + do { + for (zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos); + zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop_info, &pos) == SUCCESS; + zend_hash_move_forward_ex(&ce->properties_info, &pos)) { + if (is_static == ((prop_info->flags & ZEND_ACC_STATIC) != 0) && + offset == prop_info->offset) { + zend_class_entry *old_scope = *scope; + *scope = prop_info->ce; + int ret = zval_update_constant(pp, (void*)1 TSRMLS_CC); + *scope = old_scope; + return ret; + } + } + ce = ce->parent; + } while (ce); + + } + return zval_update_constant(pp, (void*)1 TSRMLS_CC); + } + return 0; +} +/* }}} */ + ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { if ((class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED) == 0 || (!CE_STATIC_MEMBERS(class_type) && class_type->default_static_members_count)) { @@ -1063,7 +1097,7 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC for (i = 0; i < class_type->default_properties_count; i++) { if (class_type->default_properties_table[i]) { - zval_update_constant(&class_type->default_properties_table[i], (void**)1 TSRMLS_CC); + zval_update_class_constant(&class_type->default_properties_table[i], 0, i TSRMLS_CC); } } @@ -1104,7 +1138,7 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC } for (i = 0; i < class_type->default_static_members_count; i++) { - zval_update_constant(&CE_STATIC_MEMBERS(class_type)[i], (void**)1 TSRMLS_CC); + zval_update_class_constant(&CE_STATIC_MEMBERS(class_type)[i], 1, i TSRMLS_CC); } *scope = old_scope; |
