Browse Source

- Allow overloaded objects to receive the method name in its original

- case.
experimental/new_apache_hooks
Andi Gutmans 24 years ago
parent
commit
2d6404d5b0
  1. 2
      Zend/zend_compile.c
  2. 26
      Zend/zend_execute.c
  3. 13
      Zend/zend_object_handlers.c

2
Zend/zend_compile.c

@ -1081,8 +1081,6 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC)
last_op->extended_value = ZEND_FETCH_FROM_THIS;
}
zend_lowercase_znode_if_const(&last_op->op2);
left_bracket->u.constant.value.lval = ZEND_INIT_FCALL_BY_NAME;
zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *));

26
Zend/zend_execute.c

@ -1892,30 +1892,15 @@ binary_assign_op_addr_obj:
{
zval *function_name;
zval tmp;
zend_bool is_const;
char *function_name_strval;
int function_name_strlen;
zend_ptr_stack_n_push(&EG(arg_types_stack), 2, EX(fbc), EX(object));
is_const = (EX(opline)->op2.op_type == IS_CONST);
if (is_const) {
function_name_strval = EX(opline)->op2.u.constant.value.str.val;
function_name_strlen = EX(opline)->op2.u.constant.value.str.len;
} else {
function_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R);
tmp = *function_name;
zval_copy_ctor(&tmp);
convert_to_string(&tmp);
function_name = &tmp;
zend_str_tolower(tmp.value.str.val, tmp.value.str.len);
function_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R);
function_name_strval = function_name->value.str.val;
function_name_strlen = function_name->value.str.len;
function_name_strval = tmp.value.str.val;
function_name_strlen = tmp.value.str.len;
}
EX(calling_scope) = EG(scope);
if (EX(opline)->extended_value == ZEND_FETCH_FROM_THIS) {
@ -1953,10 +1938,7 @@ binary_assign_op_addr_obj:
EX(calling_scope) = NULL;
}
if (!is_const) {
zval_dtor(&tmp);
FREE_OP(EX(Ts), &EX(opline)->op2, EG(free_op2));
}
FREE_OP(EX(Ts), &EX(opline)->op2, EG(free_op2));
NEXT_OPCODE();
}

13
Zend/zend_object_handlers.c

@ -152,12 +152,19 @@ static union _zend_function *zend_std_get_method(zval *object, char *method_name
{
zend_object *zobj;
zend_function *func_method;
char *lc_method_name;
lc_method_name = do_alloca(method_len+1);
/* Create a zend_copy_str_tolower(dest, src, src_length); */
memcpy(lc_method_name, method_name, method_len+1);
zend_str_tolower(lc_method_name, method_len);
zobj = Z_OBJ_P(object);
if(zend_hash_find(&zobj->ce->function_table, method_name, method_len+1, (void **)&func_method) == FAILURE) {
if(zend_hash_find(&zobj->ce->function_table, lc_method_name, method_len+1, (void **)&func_method) == FAILURE) {
zend_error(E_ERROR, "Call to undefined function %s()", method_name);
}
free_alloca(lc_method_name);
return func_method;
}

Loading…
Cancel
Save