summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-08-22 00:59:39 +0000
committerFelipe Pena <felipe@php.net>2008-08-22 00:59:39 +0000
commit317b48f3af5312e27eaa1f90da0ced93fdba05ba (patch)
tree989346ca5ce39979648c0b7bb108e877aa6e144a /Zend/zend_builtin_functions.c
parenta7d2377ce49300a728ce1c77fef49fbb9f8aef83 (diff)
downloadphp-git-317b48f3af5312e27eaa1f90da0ced93fdba05ba.tar.gz
MFH:
- Fixed bug #45862 (get_class_vars is inconsistent with 'protected' and 'private' variables) - Added some tests
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index d7392fbe85..0e3dba8418 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -977,8 +977,6 @@ ZEND_FUNCTION(is_a)
/* {{{ add_class_vars */
static void add_class_vars(zend_class_entry *ce, HashTable *properties, zval *return_value TSRMLS_DC)
{
- int instanceof = EG(scope) && instanceof_function(EG(scope), ce TSRMLS_CC);
-
if (zend_hash_num_elements(properties) > 0) {
HashPosition pos;
zval **prop;
@@ -987,20 +985,28 @@ static void add_class_vars(zend_class_entry *ce, HashTable *properties, zval *re
while (zend_hash_get_current_data_ex(properties, (void **) &prop, &pos) == SUCCESS) {
char *key, *class_name, *prop_name;
uint key_len;
- ulong num_index;
+ ulong num_index, h;
+ int prop_name_len = 0;
zval *prop_copy;
+ zend_property_info *property_info;
zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos);
zend_hash_move_forward_ex(properties, &pos);
+
zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name);
- if (class_name) {
- if (class_name[0] != '*' && strcmp(class_name, ce->name)) {
- /* filter privates from base classes */
- continue;
- } else if (!instanceof) {
- /* filter protected if not inside class */
- continue;
- }
+ prop_name_len = strlen(prop_name);
+
+ h = zend_get_hash_value(prop_name, prop_name_len+1);
+ if (zend_hash_quick_find(&ce->properties_info, prop_name, prop_name_len+1, h, (void **) &property_info) == FAILURE) {
+ continue;
+ }
+
+ if (property_info->flags & ZEND_ACC_SHADOW) {
+ continue;
+ } else if ((property_info->flags & ZEND_ACC_PRIVATE) && EG(scope) != ce) {
+ continue;
+ } else if ((property_info->flags & ZEND_ACC_PROTECTED) && zend_check_protected(ce, EG(scope)) == 0) {
+ continue;
}
/* copy: enforce read only access */