mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Allow the symbol_table to be passed to call_user_function_ex()
This commit is contained in:
parent
da66298659
commit
3cda6a750e
@ -460,6 +460,8 @@ static inline int prepare_string_for_scanning(zval *str CLS_DC)
|
||||
|
||||
CG(ZFL)->switch_streams(input_stream, &cout);
|
||||
#endif
|
||||
zend_set_compiled_filename("Eval code");
|
||||
CG(zend_lineno) = 1;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
31
Zend/zend.c
31
Zend/zend.c
@ -527,9 +527,9 @@ ZEND_API int zend_get_ini_entry(char *name, uint name_length, zval *contents)
|
||||
ZEND_API void zend_error(int type, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
zval **params;
|
||||
zval retval;
|
||||
zval error_type, error_message;
|
||||
zval ***params;
|
||||
zval *retval;
|
||||
zval *error_type, *error_message;
|
||||
char *error_filename;
|
||||
uint error_lineno;
|
||||
ELS_FETCH();
|
||||
@ -589,33 +589,34 @@ ZEND_API void zend_error(int type, const char *format, ...)
|
||||
break;
|
||||
default:
|
||||
/* Handle the error in user space */
|
||||
INIT_PZVAL(&error_message);
|
||||
INIT_PZVAL(&error_type);
|
||||
error_message.value.str.val = (char *) emalloc(ZEND_ERROR_BUFFER_SIZE);
|
||||
ALLOC_INIT_ZVAL(error_message);
|
||||
ALLOC_INIT_ZVAL(error_type);
|
||||
error_message->value.str.val = (char *) emalloc(ZEND_ERROR_BUFFER_SIZE);
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
error_message.value.str.len = vsnprintf(error_message.value.str.val, ZEND_ERROR_BUFFER_SIZE, format, args);
|
||||
error_message->value.str.len = vsnprintf(error_message->value.str.val, ZEND_ERROR_BUFFER_SIZE, format, args);
|
||||
#else
|
||||
/* This is risky... */
|
||||
error_message.value.str.len = vsprintf(error_message.value.str.val, format, args);
|
||||
error_message->value.str.len = vsprintf(error_message->value.str.val, format, args);
|
||||
#endif
|
||||
error_message.type = IS_STRING;
|
||||
error_message->type = IS_STRING;
|
||||
|
||||
error_type.value.lval = type;
|
||||
error_type.type = IS_LONG;
|
||||
error_type->value.lval = type;
|
||||
error_type->type = IS_LONG;
|
||||
|
||||
params = (zval **) emalloc(sizeof(zval *)*2);
|
||||
params = (zval ***) emalloc(sizeof(zval **)*2);
|
||||
params[0] = &error_type;
|
||||
params[1] = &error_message;
|
||||
|
||||
if (call_user_function(CG(function_table), NULL, EG(user_error_handler), &retval, 2, params)==SUCCESS) {
|
||||
zval_dtor(&retval);
|
||||
if (call_user_function_ex(CG(function_table), NULL, EG(user_error_handler), &retval, 2, params, 1, NULL)==SUCCESS) {
|
||||
zval_ptr_dtor(&retval);
|
||||
} else {
|
||||
/* The user error handler failed, use built-in error handler */
|
||||
zend_error_cb(type, error_filename, error_lineno, format, args);
|
||||
}
|
||||
efree(params);
|
||||
efree(error_message.value.str.val);
|
||||
zval_ptr_dtor(&error_message);
|
||||
zval_ptr_dtor(&error_type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ ZEND_API int add_get_index_string(zval *arg, uint idx, char *str, void **dest, i
|
||||
ZEND_API int add_get_index_stringl(zval *arg, uint idx, char *str, uint length, void **dest, int duplicate);
|
||||
|
||||
ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, int param_count, zval *params[]);
|
||||
ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation);
|
||||
ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation, HashTable *symbol_table);
|
||||
|
||||
ZEND_API int add_property_long(zval *arg, char *key, long l);
|
||||
ZEND_API int add_property_unset(zval *arg, char *key);
|
||||
|
@ -325,7 +325,7 @@ int call_user_function(HashTable *function_table, zval *object, zval *function_n
|
||||
for (i=0; i<param_count; i++) {
|
||||
params_array[i] = ¶ms[i];
|
||||
}
|
||||
ex_retval = call_user_function_ex(function_table, object, function_name, &local_retval_ptr, param_count, params_array, 1);
|
||||
ex_retval = call_user_function_ex(function_table, object, function_name, &local_retval_ptr, param_count, params_array, 1, NULL);
|
||||
if (local_retval_ptr) {
|
||||
COPY_PZVAL_TO_ZVAL(*retval_ptr, local_retval_ptr);
|
||||
} else {
|
||||
@ -336,7 +336,7 @@ int call_user_function(HashTable *function_table, zval *object, zval *function_n
|
||||
}
|
||||
|
||||
|
||||
int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation)
|
||||
int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation, HashTable *symbol_table)
|
||||
{
|
||||
int i;
|
||||
zval **original_return_value;
|
||||
@ -417,8 +417,12 @@ int call_user_function_ex(HashTable *function_table, zval *object, zval *functio
|
||||
|
||||
if (function_state.function->type == ZEND_USER_FUNCTION) {
|
||||
calling_symbol_table = EG(active_symbol_table);
|
||||
ALLOC_HASHTABLE(EG(active_symbol_table));
|
||||
zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
if (symbol_table) {
|
||||
EG(active_symbol_table) = symbol_table;
|
||||
} else {
|
||||
ALLOC_HASHTABLE(EG(active_symbol_table));
|
||||
zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
}
|
||||
if (object) {
|
||||
zval *dummy, **this_ptr;
|
||||
|
||||
@ -434,8 +438,10 @@ int call_user_function_ex(HashTable *function_table, zval *object, zval *functio
|
||||
EG(active_op_array) = (zend_op_array *) function_state.function;
|
||||
original_opline_ptr = EG(opline_ptr);
|
||||
zend_execute(EG(active_op_array) ELS_CC);
|
||||
zend_hash_destroy(EG(active_symbol_table));
|
||||
FREE_HASHTABLE(EG(active_symbol_table));
|
||||
if (!symbol_table) {
|
||||
zend_hash_destroy(EG(active_symbol_table));
|
||||
FREE_HASHTABLE(EG(active_symbol_table));
|
||||
}
|
||||
EG(active_symbol_table) = calling_symbol_table;
|
||||
EG(active_op_array) = original_op_array;
|
||||
EG(return_value_ptr_ptr)=original_return_value;
|
||||
|
Loading…
Reference in New Issue
Block a user