Merge branch 'PHP-5.4' into PHP-5.5

* PHP-5.4:
  Partial fix for bug #64239
This commit is contained in:
Dmitry Stogov 2013-03-19 15:47:43 +04:00
commit 960d5be528
2 changed files with 46 additions and 13 deletions

View file

@ -1025,6 +1025,13 @@ ZEND_FUNCTION(get_object_vars)
}
/* }}} */
static int same_name(const char *key, const char *name, zend_uint name_len)
{
char *lcname = zend_str_tolower_dup(name, name_len);
int ret = memcmp(lcname, key, name_len) == 0;
efree(lcname);
return ret;
}
/* {{{ proto array get_class_methods(mixed class)
Returns an array of method names for class or class instance. */
@ -1072,14 +1079,26 @@ ZEND_FUNCTION(get_class_methods)
uint len = strlen(mptr->common.function_name);
/* Do not display old-style inherited constructors */
if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 ||
mptr->common.scope == ce ||
zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING ||
zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0) {
if (zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING) {
MAKE_STD_ZVAL(method_name);
ZVAL_STRINGL(method_name, mptr->common.function_name, len, 1);
zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL);
} else if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 ||
mptr->common.scope == ce ||
zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0) {
if (mptr->type == ZEND_USER_FUNCTION &&
*mptr->op_array.refcount > 1 &&
(len != key_len - 1 ||
!same_name(key, mptr->common.function_name, len))) {
MAKE_STD_ZVAL(method_name);
ZVAL_STRINGL(method_name, key, key_len - 1, 1);
zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL);
} else {
MAKE_STD_ZVAL(method_name);
ZVAL_STRINGL(method_name, mptr->common.function_name, len, 1);
zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL);
}
}
}
zend_hash_move_forward_ex(&ce->function_table, &pos);
@ -1625,14 +1644,6 @@ ZEND_FUNCTION(restore_exception_handler)
}
/* }}} */
static int same_name(const char *key, const char *name, zend_uint name_len)
{
char *lcname = zend_str_tolower_dup(name, name_len);
int ret = memcmp(lcname, key, name_len) == 0;
efree(lcname);
return ret;
}
static int copy_class_or_interface_name(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
zval *array = va_arg(args, zval *);