-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement mechanism for finding prop_info for property slot #3573
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,6 +242,21 @@ ZEND_API HashTable *zend_get_properties_for(zval *obj, zend_prop_purpose purpose | |
} \ | ||
} while (0) | ||
|
||
ZEND_API int zend_check_property_info_access(struct _zend_property_info *prop_info); | ||
|
||
static inline struct _zend_property_info *zend_get_property_info_for_slot(zend_object *obj, zval *slot) | ||
{ | ||
struct _zend_property_info **table = obj->ce->properties_info_table; | ||
intptr_t prop_num = slot - obj->properties_table; | ||
ZEND_ASSERT(prop_num >= 0 && prop_num < obj->ce->default_properties_count); | ||
return table[prop_num]; | ||
} | ||
|
||
static inline int zend_check_property_slot_access(zend_object *obj, zval *slot) /* {{{ */ | ||
{ | ||
return zend_check_property_info_access(zend_get_property_info_for_slot(obj, slot)); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no reason to inline this function. Better, merge it with zend_check_property_info_access(). |
||
#define zend_free_trampoline(func) do { \ | ||
if ((func) == &EG(trampoline)) { \ | ||
EG(trampoline).common.function_name = NULL; \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,25 +53,29 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, | |
} | ||
arg_sep_len = strlen(arg_sep); | ||
|
||
ZEND_HASH_FOREACH_KEY_VAL_IND(ht, idx, key, zdata) { | ||
/* handling for private & protected object properties */ | ||
ZEND_HASH_FOREACH_KEY_VAL(ht, idx, key, zdata) { | ||
if (key) { | ||
if (ZSTR_VAL(key)[0] == '\0' && type != NULL) { | ||
const char *tmp; | ||
prop_name = ZSTR_VAL(key); | ||
prop_len = ZSTR_LEN(key); | ||
} else { | ||
prop_name = NULL; | ||
prop_len = 0; | ||
} | ||
|
||
if (Z_TYPE_P(zdata) == IS_INDIRECT) { | ||
zdata = Z_INDIRECT_P(zdata); | ||
if (Z_ISUNDEF_P(zdata)) { | ||
continue; | ||
} | ||
|
||
zend_object *zobj = Z_OBJ_P(type); | ||
if (zend_check_property_access(zobj, key) != SUCCESS) { | ||
if (type) { | ||
const char *tmp; | ||
if (zend_check_property_slot_access(Z_OBJ_P(type), zdata) != SUCCESS) { | ||
/* private or protected property access outside of the class */ | ||
continue; | ||
} | ||
zend_unmangle_property_name_ex(key, &tmp, &prop_name, &prop_len); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We, probably, may get property name from property_info->name, instead of unmangling. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. property_info->name is a mangled name though. Unmangling is unavoidable here. |
||
} else { | ||
prop_name = ZSTR_VAL(key); | ||
prop_len = ZSTR_LEN(key); | ||
} | ||
} else { | ||
prop_name = NULL; | ||
prop_len = 0; | ||
} | ||
|
||
ZVAL_DEREF(zdata); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opcache might need special handling for this field. At least, add an assertion that it's NULL.