diff options
Diffstat (limited to 'Zend/zend_execute_API.c')
| -rw-r--r-- | Zend/zend_execute_API.c | 416 |
1 files changed, 237 insertions, 179 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index f2881f7054..b3d6319560 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -44,9 +44,10 @@ ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data); ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value); +ZEND_API zend_class_entry *(*zend_autoload)(zend_string *name, zend_string *lc_name); /* true globals */ -ZEND_API const zend_fcall_info empty_fcall_info = { 0, {{0}, {{0}}, {0}}, NULL, NULL, NULL, 0, 0 }; +ZEND_API const zend_fcall_info empty_fcall_info = {0}; ZEND_API const zend_fcall_info_cache empty_fcall_info_cache = { NULL, NULL, NULL, NULL }; #ifdef ZEND_WIN32 @@ -140,7 +141,6 @@ void init_executor(void) /* {{{ */ EG(class_table) = CG(class_table); EG(in_autoload) = NULL; - EG(autoload_func) = NULL; EG(error_handling) = EH_NORMAL; EG(flags) = EG_FLAGS_INITIAL; @@ -180,12 +180,12 @@ void init_executor(void) /* {{{ */ EG(ht_iterators) = EG(ht_iterators_slots); memset(EG(ht_iterators), 0, sizeof(EG(ht_iterators_slots))); - EG(each_deprecation_thrown) = 0; - EG(persistent_constants_count) = EG(zend_constants)->nNumUsed; EG(persistent_functions_count) = EG(function_table)->nNumUsed; EG(persistent_classes_count) = EG(class_table)->nNumUsed; + EG(get_gc_buffer).start = EG(get_gc_buffer).end = EG(get_gc_buffer).cur = NULL; + zend_weakrefs_init(); EG(active) = 1; @@ -287,9 +287,7 @@ void shutdown_executor(void) /* {{{ */ if (op_array->static_variables) { HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr); if (ht) { - if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && GC_DELREF(ht) == 0) { - zend_array_destroy(ht); - } + zend_array_release(ht); ZEND_MAP_PTR_SET(op_array->static_variables_ptr, NULL); } } @@ -306,9 +304,7 @@ void shutdown_executor(void) /* {{{ */ if (op_array->static_variables) { HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr); if (ht) { - if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && GC_DELREF(ht) == 0) { - zend_array_destroy(ht); - } + zend_array_release(ht); ZEND_MAP_PTR_SET(op_array->static_variables_ptr, NULL); } } @@ -333,7 +329,7 @@ void shutdown_executor(void) /* {{{ */ zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1); #if ZEND_DEBUG - if (gc_enabled() && !CG(unclean_shutdown)) { + if (!CG(unclean_shutdown)) { gc_collect_cycles(); } #endif @@ -491,6 +487,34 @@ ZEND_API const char *get_active_function_name(void) /* {{{ */ } /* }}} */ +ZEND_API const char *get_active_function_arg_name(uint32_t arg_num) /* {{{ */ +{ + zend_function *func; + + if (!zend_is_executing()) { + return NULL; + } + + func = EG(current_execute_data)->func; + + return get_function_arg_name(func, arg_num); +} +/* }}} */ + +ZEND_API const char *get_function_arg_name(const zend_function *func, uint32_t arg_num) /* {{{ */ +{ + if (!func || func->common.num_args < arg_num) { + return NULL; + } + + if (func->type == ZEND_USER_FUNCTION || (func->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) { + return ZSTR_VAL(func->common.arg_info[arg_num - 1].name); + } else { + return ((zend_internal_arg_info*) func->common.arg_info)[arg_num - 1].name; + } +} +/* }}} */ + ZEND_API const char *zend_get_executed_filename(void) /* {{{ */ { zend_execute_data *ex = EG(current_execute_data); @@ -561,41 +585,6 @@ ZEND_API zend_bool zend_is_executing(void) /* {{{ */ } /* }}} */ -ZEND_API ZEND_COLD int zend_use_undefined_constant(zend_string *name, zend_ast_attr attr, zval *result) /* {{{ */ -{ - char *colon; - - if (UNEXPECTED(EG(exception))) { - return FAILURE; - } else if ((colon = (char*)zend_memrchr(ZSTR_VAL(name), ':', ZSTR_LEN(name)))) { - zend_throw_error(NULL, "Undefined class constant '%s'", ZSTR_VAL(name)); - return FAILURE; - } else if ((attr & IS_CONSTANT_UNQUALIFIED) == 0) { - zend_throw_error(NULL, "Undefined constant '%s'", ZSTR_VAL(name)); - return FAILURE; - } else { - char *actual = ZSTR_VAL(name); - size_t actual_len = ZSTR_LEN(name); - char *slash = (char *) zend_memrchr(actual, '\\', actual_len); - - if (slash) { - actual = slash + 1; - actual_len -= (actual - ZSTR_VAL(name)); - } - - zend_error(E_WARNING, "Use of undefined constant %s - assumed '%s' (this will throw an Error in a future version of PHP)", actual, actual); - if (EG(exception)) { - return FAILURE; - } else { - zend_string *result_str = zend_string_init(actual, actual_len, 0); - zval_ptr_dtor_nogc(result); - ZVAL_NEW_STR(result, result_str); - } - } - return SUCCESS; -} -/* }}} */ - ZEND_API int zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */ { if (Z_TYPE_P(p) == IS_CONSTANT_AST) { @@ -604,10 +593,10 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */ if (ast->kind == ZEND_AST_CONSTANT) { zend_string *name = zend_ast_get_constant_name(ast); zval *zv = zend_get_constant_ex(name, scope, ast->attr); - if (UNEXPECTED(zv == NULL)) { - return zend_use_undefined_constant(name, ast->attr, p); + return FAILURE; } + zval_ptr_dtor_nogc(p); ZVAL_COPY_OR_DUP(p, zv); } else { @@ -630,7 +619,7 @@ ZEND_API int zval_update_constant(zval *pp) /* {{{ */ } /* }}} */ -int _call_user_function_ex(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation) /* {{{ */ +int _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params) /* {{{ */ { zend_fcall_info fci; @@ -640,7 +629,7 @@ int _call_user_function_ex(zval *object, zval *function_name, zval *retval_ptr, fci.retval = retval_ptr; fci.param_count = param_count; fci.params = params; - fci.no_separation = (zend_bool) no_separation; + fci.named_params = named_params; return zend_call_function(&fci, NULL); } @@ -654,6 +643,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / zend_function *func; uint32_t call_info; void *object_or_called_scope; + zend_class_entry *orig_fake_scope; ZVAL_UNDEF(fci->retval); @@ -709,20 +699,9 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / EG(current_execute_data) = dummy_execute_data.prev_execute_data; } return FAILURE; - } else if (error) { - /* Capitalize the first latter of the error message */ - if (error[0] >= 'a' && error[0] <= 'z') { - error[0] += ('A' - 'a'); - } - zend_error(E_DEPRECATED, "%s", error); - efree(error); - if (UNEXPECTED(EG(exception))) { - if (EG(current_execute_data) == &dummy_execute_data) { - EG(current_execute_data) = dummy_execute_data.prev_execute_data; - } - return FAILURE; - } } + + ZEND_ASSERT(!error); } func = fci_cache->function_handler; @@ -740,10 +719,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / func, fci->param_count, object_or_called_scope); if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_DEPRECATED)) { - zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated", - func->common.scope ? ZSTR_VAL(func->common.scope->name) : "", - func->common.scope ? "::" : "", - ZSTR_VAL(func->common.function_name)); + zend_deprecated_function(func); + if (UNEXPECTED(EG(exception))) { zend_vm_stack_free_call_frame(call); if (EG(current_execute_data) == &dummy_execute_data) { @@ -755,24 +732,24 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / } for (i=0; i<fci->param_count; i++) { - zval *param; + zval *param = ZEND_CALL_ARG(call, i+1); zval *arg = &fci->params[i]; + if (UNEXPECTED(Z_ISUNDEF_P(arg))) { + /* Allow forwarding undef slots. This is only used by Closure::__invoke(). */ + ZVAL_UNDEF(param); + ZEND_ADD_CALL_FLAG(call, ZEND_CALL_MAY_HAVE_UNDEF); + continue; + } if (ARG_SHOULD_BE_SENT_BY_REF(func, i + 1)) { if (UNEXPECTED(!Z_ISREF_P(arg))) { - if (!fci->no_separation) { - /* Separation is enabled -- create a ref */ - ZVAL_NEW_REF(arg, arg); - } else if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) { + if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) { /* By-value send is not allowed -- emit a warning, * but still perform the call with a by-value send. */ - zend_error(E_WARNING, - "Parameter %d to %s%s%s() expected to be a reference, value given", i+1, - func->common.scope ? ZSTR_VAL(func->common.scope->name) : "", - func->common.scope ? "::" : "", - ZSTR_VAL(func->common.function_name)); + zend_param_must_be_ref(func, i + 1); if (UNEXPECTED(EG(exception))) { ZEND_CALL_NUM_ARGS(call) = i; +cleanup_args: zend_vm_stack_free_args(call); zend_vm_stack_free_call_frame(call); if (EG(current_execute_data) == &dummy_execute_data) { @@ -790,10 +767,61 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / } } - param = ZEND_CALL_ARG(call, i+1); ZVAL_COPY(param, arg); } + if (fci->named_params) { + zend_string *name; + zval *arg; + uint32_t arg_num = ZEND_CALL_NUM_ARGS(call) + 1; + zend_bool have_named_params = 0; + ZEND_HASH_FOREACH_STR_KEY_VAL(fci->named_params, name, arg) { + zval *target; + if (name) { + void *cache_slot[2] = {NULL, NULL}; + have_named_params = 1; + target = zend_handle_named_arg(&call, name, &arg_num, cache_slot); + if (!target) { + goto cleanup_args; + } + } else { + if (have_named_params) { + zend_throw_error(NULL, + "Cannot use positional argument after named argument"); + goto cleanup_args; + } + + zend_vm_stack_extend_call_frame(&call, arg_num - 1, 1); + target = ZEND_CALL_ARG(call, arg_num); + } + + if (ARG_SHOULD_BE_SENT_BY_REF(func, arg_num)) { + if (UNEXPECTED(!Z_ISREF_P(arg))) { + if (!ARG_MAY_BE_SENT_BY_REF(func, arg_num)) { + /* By-value send is not allowed -- emit a warning, + * but still perform the call with a by-value send. */ + zend_param_must_be_ref(func, arg_num); + if (UNEXPECTED(EG(exception))) { + goto cleanup_args; + } + } + } + } else { + if (Z_ISREF_P(arg) && + !(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) { + /* don't separate references for __call */ + arg = Z_REFVAL_P(arg); + } + } + + ZVAL_COPY(target, arg); + if (!name) { + ZEND_CALL_NUM_ARGS(call)++; + arg_num++; + } + } ZEND_HASH_FOREACH_END(); + } + if (UNEXPECTED(func->op_array.fn_flags & ZEND_ACC_CLOSURE)) { uint32_t call_info; @@ -805,19 +833,36 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / ZEND_ADD_CALL_FLAG(call, call_info); } + if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_MAY_HAVE_UNDEF)) { + if (zend_handle_undef_args(call) == FAILURE) { + zend_vm_stack_free_args(call); + zend_vm_stack_free_call_frame(call); + if (EG(current_execute_data) == &dummy_execute_data) { + EG(current_execute_data) = dummy_execute_data.prev_execute_data; + } + return SUCCESS; + } + } + + orig_fake_scope = EG(fake_scope); + EG(fake_scope) = NULL; if (func->type == ZEND_USER_FUNCTION) { int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0; const zend_op *current_opline_before_exception = EG(opline_before_exception); + uint32_t orig_jit_trace_num = EG(jit_trace_num); zend_init_func_execute_data(call, &func->op_array, fci->retval); zend_execute_ex(call); + EG(jit_trace_num) = orig_jit_trace_num; EG(opline_before_exception) = current_opline_before_exception; if (call_via_handler) { /* We must re-initialize function again */ fci_cache->function_handler = NULL; } - } else if (func->type == ZEND_INTERNAL_FUNCTION) { + } else { int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0; + + ZEND_ASSERT(func->type == ZEND_INTERNAL_FUNCTION); ZVAL_NULL(fci->retval); call->prev_execute_data = EG(current_execute_data); EG(current_execute_data) = call; @@ -829,6 +874,9 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / } EG(current_execute_data) = call->prev_execute_data; zend_vm_stack_free_args(call); + if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_HAS_EXTRA_NAMED_PARAMS)) { + zend_array_release(call->extra_named_params); + } if (EG(exception)) { zval_ptr_dtor(fci->retval); @@ -839,31 +887,19 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / /* We must re-initialize function again */ fci_cache->function_handler = NULL; } - } else { /* ZEND_OVERLOADED_FUNCTION */ - ZVAL_NULL(fci->retval); - - /* Not sure what should be done here if it's a static method */ - if (fci->object) { - call->prev_execute_data = EG(current_execute_data); - EG(current_execute_data) = call; - fci->object->handlers->call_method(func->common.function_name, fci->object, call, fci->retval); - EG(current_execute_data) = call->prev_execute_data; - } else { - zend_throw_error(NULL, "Cannot call overloaded function for non-object"); - } - - zend_vm_stack_free_args(call); - - if (func->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { - zend_string_release_ex(func->common.function_name, 0); - } - efree(func); - if (EG(exception)) { - zval_ptr_dtor(fci->retval); - ZVAL_UNDEF(fci->retval); + /* This flag is regularly checked while running user functions, but not internal + * So see whether interrupt flag was set while the function was running... */ + if (EG(vm_interrupt)) { + EG(vm_interrupt) = 0; + if (EG(timed_out)) { + zend_timeout(); + } else if (zend_interrupt_function) { + zend_interrupt_function(EG(current_execute_data)); + } } } + EG(fake_scope) = orig_fake_scope; zend_vm_stack_free_call_frame(call); @@ -884,15 +920,79 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / } /* }}} */ +ZEND_API void zend_call_known_function( + zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr, + uint32_t param_count, zval *params, HashTable *named_params) +{ + zval retval; + zend_fcall_info fci; + zend_fcall_info_cache fcic; + + ZEND_ASSERT(fn && "zend_function must be passed!"); + + fci.size = sizeof(fci); + fci.object = object; + fci.retval = retval_ptr ? retval_ptr : &retval; + fci.param_count = param_count; + fci.params = params; + fci.named_params = named_params; + ZVAL_UNDEF(&fci.function_name); /* Unused */ + + fcic.function_handler = fn; + fcic.object = object; + fcic.called_scope = called_scope; + + int result = zend_call_function(&fci, &fcic); + if (UNEXPECTED(result == FAILURE)) { + if (!EG(exception)) { + zend_error_noreturn(E_CORE_ERROR, "Couldn't execute method %s%s%s", + fn->common.scope ? ZSTR_VAL(fn->common.scope->name) : "", + fn->common.scope ? "::" : "", ZSTR_VAL(fn->common.function_name)); + } + } + + if (!retval_ptr) { + zval_ptr_dtor(&retval); + } +} + +ZEND_API void zend_call_known_instance_method_with_2_params( + zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2) +{ + zval params[2]; + ZVAL_COPY_VALUE(¶ms[0], param1); + ZVAL_COPY_VALUE(¶ms[1], param2); + zend_call_known_instance_method(fn, object, retval_ptr, 2, params); +} + +/* 0-9 a-z A-Z _ \ 0x80-0xff */ +static const uint32_t valid_chars[8] = { + 0x00000000, + 0x03ff0000, + 0x97fffffe, + 0x07fffffe, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, +}; + +static zend_bool zend_is_valid_class_name(zend_string *name) { + for (size_t i = 0; i < ZSTR_LEN(name); i++) { + unsigned char c = ZSTR_VAL(name)[i]; + if (!ZEND_BIT_TEST(valid_chars, c)) { + return 0; + } + } + return 1; +} + ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *key, uint32_t flags) /* {{{ */ { zend_class_entry *ce = NULL; - zval args[1], *zv; - zval local_retval; + zval *zv; zend_string *lc_name; - zend_fcall_info fcall_info; - zend_fcall_info_cache fcall_cache; - zend_class_entry *orig_fake_scope; + zend_string *autoload_name; if (key) { lc_name = key; @@ -927,9 +1027,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string * return ce; } - /* The compiler is not-reentrant. Make sure we __autoload() only during run-time - * (doesn't impact functionality of __autoload() - */ + /* The compiler is not-reentrant. Make sure we autoload only during run-time. */ if ((flags & ZEND_FETCH_CLASS_NO_AUTOLOAD) || zend_is_compiling()) { if (!key) { zend_string_release_ex(lc_name, 0); @@ -937,22 +1035,15 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string * return NULL; } - if (!EG(autoload_func)) { - zend_function *func = zend_fetch_function(ZSTR_KNOWN(ZEND_STR_MAGIC_AUTOLOAD)); - - if (func) { - EG(autoload_func) = func; - } else { - if (!key) { - zend_string_release_ex(lc_name, 0); - } - return NULL; + if (!zend_autoload) { + if (!key) { + zend_string_release_ex(lc_name, 0); } - + return NULL; } - /* Verify class name before passing it to __autoload() */ - if (!key && strspn(ZSTR_VAL(name), "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\") != ZSTR_LEN(name)) { + /* Verify class name before passing it to the autoloader. */ + if (!key && !zend_is_valid_class_name(name)) { zend_string_release_ex(lc_name, 0); return NULL; } @@ -969,42 +1060,19 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string * return NULL; } - ZVAL_UNDEF(&local_retval); - if (ZSTR_VAL(name)[0] == '\\') { - ZVAL_STRINGL(&args[0], ZSTR_VAL(name) + 1, ZSTR_LEN(name) - 1); + autoload_name = zend_string_init(ZSTR_VAL(name) + 1, ZSTR_LEN(name) - 1, 0); } else { - ZVAL_STR_COPY(&args[0], name); + autoload_name = zend_string_copy(name); } - fcall_info.size = sizeof(fcall_info); - ZVAL_STR_COPY(&fcall_info.function_name, EG(autoload_func)->common.function_name); - fcall_info.retval = &local_retval; - fcall_info.param_count = 1; - fcall_info.params = args; - fcall_info.object = NULL; - fcall_info.no_separation = 1; - - fcall_cache.function_handler = EG(autoload_func); - fcall_cache.called_scope = NULL; - fcall_cache.object = NULL; - - orig_fake_scope = EG(fake_scope); - EG(fake_scope) = NULL; zend_exception_save(); - if ((zend_call_function(&fcall_info, &fcall_cache) == SUCCESS) && !EG(exception)) { - ce = zend_hash_find_ptr(EG(class_table), lc_name); - } + ce = zend_autoload(autoload_name, lc_name); zend_exception_restore(); - EG(fake_scope) = orig_fake_scope; - - zval_ptr_dtor(&args[0]); - zval_ptr_dtor_str(&fcall_info.function_name); + zend_string_release_ex(autoload_name, 0); zend_hash_del(EG(in_autoload), lc_name); - zval_ptr_dtor(&local_retval); - if (!key) { zend_string_release_ex(lc_name, 0); } @@ -1052,7 +1120,7 @@ ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex) /* {{{ */ } /* }}} */ -ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name) /* {{{ */ +ZEND_API int zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name) /* {{{ */ { zval pv; zend_op_array *new_op_array; @@ -1116,26 +1184,25 @@ ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char } /* }}} */ -ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name) /* {{{ */ +ZEND_API int zend_eval_string(const char *str, zval *retval_ptr, const char *string_name) /* {{{ */ { return zend_eval_stringl(str, strlen(str), retval_ptr, string_name); } /* }}} */ -ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions) /* {{{ */ +ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, int handle_exceptions) /* {{{ */ { int result; result = zend_eval_stringl(str, str_len, retval_ptr, string_name); if (handle_exceptions && EG(exception)) { - zend_exception_error(EG(exception), E_ERROR); - result = FAILURE; + result = zend_exception_error(EG(exception), E_ERROR); } return result; } /* }}} */ -ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions) /* {{{ */ +ZEND_API int zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, int handle_exceptions) /* {{{ */ { return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, handle_exceptions); } @@ -1143,7 +1210,7 @@ ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, static void zend_set_timeout_ex(zend_long seconds, int reset_signals); -ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(int dummy) /* {{{ */ +ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void) /* {{{ */ { #if defined(PHP_WIN32) # ifndef ZTS @@ -1203,15 +1270,6 @@ static void zend_timeout_handler(int dummy) /* {{{ */ #endif if (zend_on_timeout) { -#ifdef ZEND_SIGNALS - /* - We got here because we got a timeout signal, so we are in a signal handler - at this point. However, we want to be able to timeout any user-supplied - shutdown functions, so pretend we are not in a signal handler while we are - calling these - */ - SIGG(running) = 0; -#endif zend_on_timeout(EG(timeout_seconds)); } @@ -1255,13 +1313,13 @@ static void zend_set_timeout_ex(zend_long seconds, int reset_signals) /* {{{ */ #ifdef ZEND_WIN32 zend_executor_globals *eg; - if(!seconds) { + if (!seconds) { return; } - /* Don't use ChangeTimerQueueTimer() as it will not restart an expired - timer, so we could end up with just an ignored timeout. Instead - delete and recreate. */ + /* Don't use ChangeTimerQueueTimer() as it will not restart an expired + * timer, so we could end up with just an ignored timeout. Instead + * delete and recreate. */ if (NULL != tq_timer) { if (!DeleteTimerQueueTimer(NULL, tq_timer, INVALID_HANDLE_VALUE)) { tq_timer = NULL; @@ -1370,23 +1428,23 @@ check_fetch_type: case ZEND_FETCH_CLASS_SELF: scope = zend_get_executed_scope(); if (UNEXPECTED(!scope)) { - zend_throw_or_error(fetch_type, NULL, "Cannot access self:: when no class scope is active"); + zend_throw_or_error(fetch_type, NULL, "Cannot access \"self\" when no class scope is active"); } return scope; case ZEND_FETCH_CLASS_PARENT: scope = zend_get_executed_scope(); if (UNEXPECTED(!scope)) { - zend_throw_or_error(fetch_type, NULL, "Cannot access parent:: when no class scope is active"); + zend_throw_or_error(fetch_type, NULL, "Cannot access \"parent\" when no class scope is active"); return NULL; } if (UNEXPECTED(!scope->parent)) { - zend_throw_or_error(fetch_type, NULL, "Cannot access parent:: when current class scope has no parent"); + zend_throw_or_error(fetch_type, NULL, "Cannot access \"parent\" when current class scope has no parent"); } return scope->parent; case ZEND_FETCH_CLASS_STATIC: ce = zend_get_called_scope(EG(current_execute_data)); if (UNEXPECTED(!ce)) { - zend_throw_or_error(fetch_type, NULL, "Cannot access static:: when no class scope is active"); + zend_throw_or_error(fetch_type, NULL, "Cannot access \"static\" when no class scope is active"); return NULL; } return ce; @@ -1404,11 +1462,11 @@ check_fetch_type: } else if ((ce = zend_lookup_class_ex(class_name, NULL, fetch_type)) == NULL) { if (!(fetch_type & ZEND_FETCH_CLASS_SILENT) && !EG(exception)) { if (fetch_sub_type == ZEND_FETCH_CLASS_INTERFACE) { - zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name)); + zend_throw_or_error(fetch_type, NULL, "Interface \"%s\" not found", ZSTR_VAL(class_name)); } else if (fetch_sub_type == ZEND_FETCH_CLASS_TRAIT) { - zend_throw_or_error(fetch_type, NULL, "Trait '%s' not found", ZSTR_VAL(class_name)); + zend_throw_or_error(fetch_type, NULL, "Trait \"%s\" not found", ZSTR_VAL(class_name)); } else { - zend_throw_or_error(fetch_type, NULL, "Class '%s' not found", ZSTR_VAL(class_name)); + zend_throw_or_error(fetch_type, NULL, "Class \"%s\" not found", ZSTR_VAL(class_name)); } } return NULL; @@ -1441,11 +1499,11 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string return NULL; } if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) { - zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name)); + zend_throw_or_error(fetch_type, NULL, "Interface \"%s\" not found", ZSTR_VAL(class_name)); } else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) { - zend_throw_or_error(fetch_type, NULL, "Trait '%s' not found", ZSTR_VAL(class_name)); + zend_throw_or_error(fetch_type, NULL, "Trait \"%s\" not found", ZSTR_VAL(class_name)); } else { - zend_throw_or_error(fetch_type, NULL, "Class '%s' not found", ZSTR_VAL(class_name)); + zend_throw_or_error(fetch_type, NULL, "Class \"%s\" not found", ZSTR_VAL(class_name)); } return NULL; } |
