summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c383
1 files changed, 102 insertions, 281 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 184b352ec8..81c78f2a97 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -29,15 +29,6 @@
#include "zend_closures.h"
#include "zend_generators.h"
-#undef ZEND_TEST_EXCEPTIONS
-
-#if ZEND_DEBUG
-static zend_class_entry *zend_test_interface;
-static zend_class_entry *zend_test_class;
-static zend_class_entry *zend_test_trait;
-static zend_object_handlers zend_test_class_handlers;
-#endif
-
static ZEND_FUNCTION(zend_version);
static ZEND_FUNCTION(func_num_args);
static ZEND_FUNCTION(func_get_arg);
@@ -61,13 +52,6 @@ static ZEND_FUNCTION(interface_exists);
static ZEND_FUNCTION(trait_exists);
static ZEND_FUNCTION(function_exists);
static ZEND_FUNCTION(class_alias);
-#if ZEND_DEBUG
-static ZEND_FUNCTION(leak);
-static ZEND_FUNCTION(leak_variable);
-#ifdef ZEND_TEST_EXCEPTIONS
-static ZEND_FUNCTION(crash);
-#endif
-#endif
static ZEND_FUNCTION(get_included_files);
static ZEND_FUNCTION(is_subclass_of);
static ZEND_FUNCTION(is_a);
@@ -93,13 +77,9 @@ static ZEND_FUNCTION(get_extension_funcs);
static ZEND_FUNCTION(get_defined_constants);
static ZEND_FUNCTION(debug_backtrace);
static ZEND_FUNCTION(debug_print_backtrace);
-#if ZEND_DEBUG
-static ZEND_FUNCTION(zend_test_func);
-static ZEND_FUNCTION(zend_test_func2);
-#ifdef ZTS
+#if ZEND_DEBUG && defined(ZTS)
static ZEND_FUNCTION(zend_thread_id);
#endif
-#endif
static ZEND_FUNCTION(gc_mem_caches);
static ZEND_FUNCTION(gc_collect_cycles);
static ZEND_FUNCTION(gc_enabled);
@@ -199,13 +179,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_alias, 0, 0, 2)
ZEND_ARG_INFO(0, autoload)
ZEND_END_ARG_INFO()
-#if ZEND_DEBUG
-ZEND_BEGIN_ARG_INFO_EX(arginfo_leak_variable, 0, 0, 1)
- ZEND_ARG_INFO(0, variable)
- ZEND_ARG_INFO(0, leak_data)
-ZEND_END_ARG_INFO()
-#endif
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_trigger_error, 0, 0, 1)
ZEND_ARG_INFO(0, message)
ZEND_ARG_INFO(0, error_type)
@@ -259,70 +232,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_extension_loaded, 0, 0, 1)
ZEND_ARG_INFO(0, extension_name)
ZEND_END_ARG_INFO()
-#if ZEND_DEBUG
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func, IS_ARRAY, NULL, 0)
-ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func2, IS_ARRAY, NULL, 1)
-ZEND_END_ARG_INFO()
-#endif
-
/* }}} */
-#if ZEND_DEBUG
-static zend_object *zend_test_class_new(zend_class_entry *class_type) /* {{{ */ {
- zend_object *obj = zend_objects_new(class_type);
- obj->handlers = &zend_test_class_handlers;
- return obj;
-}
-/* }}} */
-
-static zend_function *zend_test_class_method_get(zend_object **object, zend_string *name, const zval *key) /* {{{ */ {
- zend_internal_function *fptr = emalloc(sizeof(zend_internal_function));
- fptr->type = ZEND_OVERLOADED_FUNCTION_TEMPORARY;
- fptr->num_args = 1;
- fptr->arg_info = NULL;
- fptr->scope = (*object)->ce;
- fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
- fptr->function_name = zend_string_copy(name);
- fptr->handler = ZEND_FN(zend_test_func);
- zend_set_function_arg_flags((zend_function*)fptr);
-
- return (zend_function*)fptr;
-}
-/* }}} */
-
-static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name) /* {{{ */ {
- zend_internal_function *fptr = emalloc(sizeof(zend_internal_function));
- fptr->type = ZEND_OVERLOADED_FUNCTION;
- fptr->num_args = 1;
- fptr->arg_info = NULL;
- fptr->scope = ce;
- fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC;
- fptr->function_name = name;
- fptr->handler = ZEND_FN(zend_test_func);
- zend_set_function_arg_flags((zend_function*)fptr);
-
- return (zend_function*)fptr;
-}
-/* }}} */
-
-static int zend_test_class_call_method(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ {
- RETVAL_STR(zend_string_copy(method));
- return 0;
-}
-/* }}} */
-
-static ZEND_METHOD(_ZendTestTrait, testMethod) /* {{{ */ {
- RETURN_TRUE;
-}
-/* }}} */
-
-static zend_function_entry zend_test_trait_methods[] = {
- ZEND_ME(_ZendTestTrait, testMethod, arginfo_zend__void, ZEND_ACC_PUBLIC)
- ZEND_FE_END
-};
-#endif
-
static const zend_function_entry builtin_functions[] = { /* {{{ */
ZEND_FE(zend_version, arginfo_zend__void)
ZEND_FE(func_num_args, arginfo_zend__void)
@@ -347,13 +258,6 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
ZEND_FE(trait_exists, arginfo_trait_exists)
ZEND_FE(function_exists, arginfo_function_exists)
ZEND_FE(class_alias, arginfo_class_alias)
-#if ZEND_DEBUG
- ZEND_FE(leak, NULL)
- ZEND_FE(leak_variable, arginfo_leak_variable)
-#ifdef ZEND_TEST_EXCEPTIONS
- ZEND_FE(crash, NULL)
-#endif
-#endif
ZEND_FE(get_included_files, arginfo_zend__void)
ZEND_FALIAS(get_required_files, get_included_files, arginfo_zend__void)
ZEND_FE(is_subclass_of, arginfo_is_subclass_of)
@@ -372,7 +276,7 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
ZEND_FE(get_declared_interfaces, arginfo_zend__void)
ZEND_FE(get_defined_functions, arginfo_get_defined_functions)
ZEND_FE(get_defined_vars, arginfo_zend__void)
- ZEND_FE(create_function, arginfo_create_function)
+ ZEND_DEP_FE(create_function, arginfo_create_function)
ZEND_FE(get_resource_type, arginfo_get_resource_type)
ZEND_FE(get_resources, arginfo_get_resources)
ZEND_FE(get_loaded_extensions, arginfo_get_loaded_extensions)
@@ -381,13 +285,9 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
ZEND_FE(get_defined_constants, arginfo_get_defined_constants)
ZEND_FE(debug_backtrace, arginfo_debug_backtrace)
ZEND_FE(debug_print_backtrace, arginfo_debug_print_backtrace)
-#if ZEND_DEBUG
- ZEND_FE(zend_test_func, arginfo_zend_test_func)
- ZEND_FE(zend_test_func2, arginfo_zend_test_func2)
-#ifdef ZTS
+#if ZEND_DEBUG && defined(ZTS)
ZEND_FE(zend_thread_id, NULL)
#endif
-#endif
ZEND_FE(gc_mem_caches, arginfo_zend__void)
ZEND_FE(gc_collect_cycles, arginfo_zend__void)
ZEND_FE(gc_enabled, arginfo_zend__void)
@@ -405,26 +305,6 @@ ZEND_MINIT_FUNCTION(core) { /* {{{ */
zend_register_default_classes();
-#if ZEND_DEBUG
- INIT_CLASS_ENTRY(class_entry, "_ZendTestInterface", NULL);
- zend_test_interface = zend_register_internal_interface(&class_entry);
- zend_declare_class_constant_long(zend_test_interface, ZEND_STRL("DUMMY"), 0);
- INIT_CLASS_ENTRY(class_entry, "_ZendTestClass", NULL);
- zend_test_class = zend_register_internal_class_ex(&class_entry, NULL);
- zend_class_implements(zend_test_class, 1, zend_test_interface);
- zend_test_class->create_object = zend_test_class_new;
- zend_test_class->get_static_method = zend_test_class_static_method_get;
-
- memcpy(&zend_test_class_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- zend_test_class_handlers.get_method = zend_test_class_method_get;
- zend_test_class_handlers.call_method = zend_test_class_call_method;
-
- INIT_CLASS_ENTRY(class_entry, "_ZendTestTrait", zend_test_trait_methods);
- zend_test_trait = zend_register_internal_class(&class_entry);
- zend_test_trait->ce_flags |= ZEND_ACC_TRAIT;
- zend_declare_property_null(zend_test_trait, "testProp", sizeof("testProp")-1, ZEND_ACC_PUBLIC);
-#endif
-
return SUCCESS;
}
/* }}} */
@@ -657,9 +537,10 @@ ZEND_FUNCTION(strcmp)
{
zend_string *s1, *s2;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &s1, &s2) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STR(s1)
+ Z_PARAM_STR(s2)
+ ZEND_PARSE_PARAMETERS_END();
RETURN_LONG(zend_binary_strcmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2)));
}
@@ -672,9 +553,11 @@ ZEND_FUNCTION(strncmp)
zend_string *s1, *s2;
zend_long len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "SSl", &s1, &s2, &len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(3, 3)
+ Z_PARAM_STR(s1)
+ Z_PARAM_STR(s2)
+ Z_PARAM_LONG(len)
+ ZEND_PARSE_PARAMETERS_END();
if (len < 0) {
zend_error(E_WARNING, "Length must be greater than or equal to 0");
@@ -691,9 +574,10 @@ ZEND_FUNCTION(strcasecmp)
{
zend_string *s1, *s2;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &s1, &s2) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STR(s1)
+ Z_PARAM_STR(s2)
+ ZEND_PARSE_PARAMETERS_END();
RETURN_LONG(zend_binary_strcasecmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2)));
}
@@ -706,9 +590,11 @@ ZEND_FUNCTION(strncasecmp)
zend_string *s1, *s2;
zend_long len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "SSl", &s1, &s2, &len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(3, 3)
+ Z_PARAM_STR(s1)
+ Z_PARAM_STR(s2)
+ Z_PARAM_LONG(len)
+ ZEND_PARSE_PARAMETERS_END();
if (len < 0) {
zend_error(E_WARNING, "Length must be greater than or equal to 0");
@@ -732,6 +618,11 @@ ZEND_FUNCTION(each)
return;
}
+ if (!EG(each_deprecation_thrown)) {
+ zend_error(E_DEPRECATED, "The each() function is deprecated. This message will be suppressed on further calls");
+ EG(each_deprecation_thrown) = 1;
+ }
+
target_hash = HASH_OF(array);
if (!target_hash) {
zend_error(E_WARNING,"Variable passed to each() is not an array or object");
@@ -763,7 +654,7 @@ ZEND_FUNCTION(each)
if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
}
zend_hash_index_add_new(Z_ARRVAL_P(return_value), 1, entry);
- zend_hash_add_new(Z_ARRVAL_P(return_value), CG(known_strings)[ZEND_STR_VALUE], entry);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_VALUE), entry);
/* add the key elements */
if (zend_hash_get_current_key(target_hash, &key, &num_key) == HASH_KEY_IS_STRING) {
@@ -773,7 +664,7 @@ ZEND_FUNCTION(each)
ZVAL_LONG(&tmp, num_key);
}
zend_hash_index_add_new(Z_ARRVAL_P(return_value), 0, &tmp);
- zend_hash_add_new(Z_ARRVAL_P(return_value), CG(known_strings)[ZEND_STR_KEY], &tmp);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_KEY), &tmp);
zend_hash_move_forward(target_hash);
}
/* }}} */
@@ -797,7 +688,7 @@ ZEND_FUNCTION(error_reporting)
zend_ini_entry *p = EG(error_reporting_ini_entry);
if (!p) {
- p = zend_hash_find_ptr(EG(ini_directives), CG(known_strings)[ZEND_STR_ERROR_REPORTING]);
+ p = zend_hash_find_ptr(EG(ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING));
if (p) {
EG(error_reporting_ini_entry) = p;
} else {
@@ -809,7 +700,7 @@ ZEND_FUNCTION(error_reporting)
ALLOC_HASHTABLE(EG(modified_ini_directives));
zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
}
- if (EXPECTED(zend_hash_add_ptr(EG(modified_ini_directives), CG(known_strings)[ZEND_STR_ERROR_REPORTING], p) != NULL)) {
+ if (EXPECTED(zend_hash_add_ptr(EG(modified_ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING), p) != NULL)) {
p->orig_value = p->value;
p->orig_modifiable = p->modifiable;
p->modified = 1;
@@ -841,7 +732,7 @@ static int validate_constant_array(HashTable *ht) /* {{{ */
ZVAL_DEREF(val);
if (Z_REFCOUNTED_P(val)) {
if (Z_TYPE_P(val) == IS_ARRAY) {
- if (!Z_IMMUTABLE_P(val)) {
+ if (Z_REFCOUNTED_P(val)) {
if (Z_ARRVAL_P(val)->u.v.nApplyCount > 0) {
zend_error(E_WARNING, "Constants cannot be recursive arrays");
ret = 0;
@@ -879,7 +770,7 @@ static void copy_constant_array(zval *dst, zval *src) /* {{{ */
new_val = zend_hash_index_add_new(Z_ARRVAL_P(dst), idx, val);
}
if (Z_TYPE_P(val) == IS_ARRAY) {
- if (!Z_IMMUTABLE_P(val)) {
+ if (Z_REFCOUNTED_P(val)) {
copy_constant_array(new_val, val);
}
} else if (Z_REFCOUNTED_P(val)) {
@@ -929,7 +820,7 @@ repeat:
case IS_RESOURCE:
break;
case IS_ARRAY:
- if (!Z_IMMUTABLE_P(val)) {
+ if (Z_REFCOUNTED_P(val)) {
if (!validate_constant_array(Z_ARRVAL_P(val))) {
RETURN_FALSE;
} else {
@@ -959,7 +850,7 @@ repeat:
RETURN_FALSE;
}
- ZVAL_DUP(&c.value, val);
+ ZVAL_COPY(&c.value, val);
zval_ptr_dtor(&val_free);
register_constant:
c.flags = case_sensitive; /* non persistent */
@@ -998,7 +889,7 @@ ZEND_FUNCTION(get_class)
{
zval *obj = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|o!", &obj) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|o", &obj) == FAILURE) {
RETURN_FALSE;
}
@@ -1228,8 +1119,7 @@ ZEND_FUNCTION(get_object_vars)
HashTable *properties;
zend_string *key;
zend_object *zobj;
- zend_ulong index;
- zend_bool fast_copy = 0;
+ zend_ulong num_key;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_OBJECT(obj)
@@ -1248,45 +1138,49 @@ ZEND_FUNCTION(get_object_vars)
zobj = Z_OBJ_P(obj);
if (!zobj->ce->default_properties_count && properties == zobj->properties && !ZEND_HASH_GET_APPLY_COUNT(properties)) {
- fast_copy = 1;
- /* Check if the object has a numeric property, See Bug 73998 */
- ZEND_HASH_FOREACH_STR_KEY(properties, key) {
- if (key && ZEND_HANDLE_NUMERIC(key, index)) {
- fast_copy = 0;
- break;
- }
- } ZEND_HASH_FOREACH_END();
- }
-
- if (fast_copy) {
+ /* fast copy */
if (EXPECTED(zobj->handlers == &std_object_handlers)) {
- if (EXPECTED(!(GC_FLAGS(properties) & IS_ARRAY_IMMUTABLE))) {
- GC_REFCOUNT(properties)++;
- }
- RETURN_ARR(properties);
+ RETURN_ARR(zend_proptable_to_symtable(properties, 0));
}
- RETURN_ARR(zend_array_dup(properties));
+ RETURN_ARR(zend_proptable_to_symtable(properties, 1));
} else {
array_init_size(return_value, zend_hash_num_elements(properties));
- ZEND_HASH_FOREACH_STR_KEY_VAL_IND(properties, key, value) {
- if (key) {
- if (zend_check_property_access(zobj, key) == SUCCESS) {
- if (Z_ISREF_P(value) && Z_REFCOUNT_P(value) == 1) {
- value = Z_REFVAL_P(value);
- }
- if (Z_REFCOUNTED_P(value)) {
- Z_ADDREF_P(value);
- }
- if (ZSTR_VAL(key)[0] == 0) {
- const char *prop_name, *class_name;
- size_t prop_len;
- zend_unmangle_property_name_ex(key, &class_name, &prop_name, &prop_len);
- zend_hash_str_add_new(Z_ARRVAL_P(return_value), prop_name, prop_len, value);
- } else {
- zend_symtable_add_new(Z_ARRVAL_P(return_value), key, value);
- }
+ ZEND_HASH_FOREACH_KEY_VAL(properties, num_key, key, value) {
+ zend_bool unmangle = 0;
+ if (Z_TYPE_P(value) == IS_INDIRECT) {
+ value = Z_INDIRECT_P(value);
+ if (UNEXPECTED(Z_ISUNDEF_P(value))) {
+ continue;
}
+
+ ZEND_ASSERT(key);
+ if (zend_check_property_access(zobj, key) == FAILURE) {
+ continue;
+ }
+ unmangle = 1;
+ }
+
+ if (Z_ISREF_P(value) && Z_REFCOUNT_P(value) == 1) {
+ value = Z_REFVAL_P(value);
+ }
+ Z_TRY_ADDREF_P(value);
+
+ if (UNEXPECTED(!key)) {
+ /* This case is only possible due to loopholes, e.g. ArrayObject */
+ zend_hash_index_add(Z_ARRVAL_P(return_value), num_key, value);
+ } else if (unmangle && ZSTR_VAL(key)[0] == 0) {
+ const char *prop_name, *class_name;
+ size_t prop_len;
+ zend_unmangle_property_name_ex(key, &class_name, &prop_name, &prop_len);
+ /* We assume here that a mangled property name is never
+ * numeric. This is probably a safe assumption, but
+ * theoretically someone might write an extension with
+ * private, numeric properties. Well, too bad.
+ */
+ zend_hash_str_add_new(Z_ARRVAL_P(return_value), prop_name, prop_len, value);
+ } else {
+ zend_symtable_add_new(Z_ARRVAL_P(return_value), key, value);
}
} ZEND_HASH_FOREACH_END();
}
@@ -1650,63 +1544,6 @@ ZEND_FUNCTION(class_alias)
}
/* }}} */
-#if ZEND_DEBUG
-/* {{{ proto void leak([int num_bytes])
- Cause an intentional memory leak, for testing/debugging purposes */
-ZEND_FUNCTION(leak)
-{
- zend_long leakbytes = 3;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &leakbytes) == FAILURE) {
- return;
- }
-
- emalloc(leakbytes);
-}
-/* }}} */
-
-/* {{{ proto void leak_variable(mixed variable [, bool leak_data])
- Leak a variable that is a resource or an object */
-ZEND_FUNCTION(leak_variable)
-{
- zval *zv;
- zend_bool leak_data = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &zv, &leak_data) == FAILURE) {
- return;
- }
-
- if (!leak_data) {
- Z_ADDREF_P(zv);
- } else if (Z_TYPE_P(zv) == IS_RESOURCE) {
- Z_ADDREF_P(zv);
- } else if (Z_TYPE_P(zv) == IS_OBJECT) {
- Z_ADDREF_P(zv);
- } else {
- zend_error(E_WARNING, "Leaking non-zval data is only applicable to resources and objects");
- }
-}
-/* }}} */
-
-
-#ifdef ZEND_TEST_EXCEPTIONS
-/* {{{ proto void crash(void)
- Crash the script */
-ZEND_FUNCTION(crash)
-{
- char *nowhere = NULL;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- memcpy(nowhere, "something", sizeof("something"));
-}
-/* }}} */
-#endif
-
-#endif /* ZEND_DEBUG */
-
/* {{{ proto array get_included_files(void)
Returns an array with the file names that were include_once()'d */
ZEND_FUNCTION(get_included_files)
@@ -1760,7 +1597,6 @@ ZEND_FUNCTION(trigger_error)
ZEND_FUNCTION(set_error_handler)
{
zval *error_handler;
- zend_string *error_handler_name = NULL;
zend_long error_type = E_ALL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|l", &error_handler, &error_type) == FAILURE) {
@@ -1768,13 +1604,13 @@ ZEND_FUNCTION(set_error_handler)
}
if (Z_TYPE_P(error_handler) != IS_NULL) { /* NULL == unset */
- if (!zend_is_callable(error_handler, 0, &error_handler_name)) {
+ if (!zend_is_callable(error_handler, 0, NULL)) {
+ zend_string *error_handler_name = zend_get_callable_name(error_handler);
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
get_active_function_name(), error_handler_name?ZSTR_VAL(error_handler_name):"unknown");
zend_string_release(error_handler_name);
return;
}
- zend_string_release(error_handler_name);
}
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
@@ -1829,20 +1665,19 @@ ZEND_FUNCTION(restore_error_handler)
ZEND_FUNCTION(set_exception_handler)
{
zval *exception_handler;
- zend_string *exception_handler_name = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &exception_handler) == FAILURE) {
return;
}
if (Z_TYPE_P(exception_handler) != IS_NULL) { /* NULL == unset */
- if (!zend_is_callable(exception_handler, 0, &exception_handler_name)) {
+ if (!zend_is_callable(exception_handler, 0, NULL)) {
+ zend_string *exception_handler_name = zend_get_callable_name(exception_handler);
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
get_active_function_name(), exception_handler_name?ZSTR_VAL(exception_handler_name):"unknown");
zend_string_release(exception_handler_name);
return;
}
- zend_string_release(exception_handler_name);
}
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
@@ -2092,28 +1927,12 @@ ZEND_FUNCTION(create_function)
}
/* }}} */
-#if ZEND_DEBUG
-ZEND_FUNCTION(zend_test_func)
-{
- zval *arg1, *arg2;
-
- zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &arg1, &arg2);
-}
-
-ZEND_FUNCTION(zend_test_func2)
-{
- zval *arg1, *arg2;
-
- zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &arg1, &arg2);
-}
-
-#ifdef ZTS
+#if ZEND_DEBUG && defined(ZTS)
ZEND_FUNCTION(zend_thread_id)
{
RETURN_LONG((zend_long)tsrm_thread_id());
}
#endif
-#endif
/* {{{ proto string get_resource_type(resource res)
Get the resource type name for a given resource */
@@ -2654,9 +2473,9 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
lineno = skip->opline->lineno;
}
ZVAL_STR_COPY(&tmp, filename);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_FILE], &tmp);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_FILE), &tmp);
ZVAL_LONG(&tmp, lineno);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_LINE], &tmp);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_LINE), &tmp);
/* try to fetch args only if an FCALL was just made - elsewise we're in the middle of a function
* and debug_baktrace() might have been called by the error_handler. in this case we don't
@@ -2674,9 +2493,9 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
}
if (prev->func && ZEND_USER_CODE(prev->func->common.type)) {
ZVAL_STR_COPY(&tmp, prev->func->op_array.filename);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_FILE], &tmp);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_FILE), &tmp);
ZVAL_LONG(&tmp, prev->opline->lineno);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_LINE], &tmp);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_LINE), &tmp);
break;
}
prev_call = prev;
@@ -2702,7 +2521,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
if (function_name) {
ZVAL_STR_COPY(&tmp, function_name);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_FUNCTION], &tmp);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_FUNCTION), &tmp);
if (object) {
if (func->common.scope) {
@@ -2712,27 +2531,27 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
} else {
ZVAL_STR(&tmp, object->handlers->get_class_name(object));
}
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_CLASS], &tmp);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_CLASS), &tmp);
if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) {
ZVAL_OBJ(&tmp, object);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_OBJECT], &tmp);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_OBJECT), &tmp);
Z_ADDREF(tmp);
}
- ZVAL_INTERNED_STR(&tmp, CG(known_strings)[ZEND_STR_OBJECT_OPERATOR]);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_TYPE], &tmp);
+ ZVAL_INTERNED_STR(&tmp, ZSTR_KNOWN(ZEND_STR_OBJECT_OPERATOR));
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_TYPE), &tmp);
} else if (func->common.scope) {
ZVAL_STR_COPY(&tmp, func->common.scope->name);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_CLASS], &tmp);
- ZVAL_INTERNED_STR(&tmp, CG(known_strings)[ZEND_STR_PAAMAYIM_NEKUDOTAYIM]);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_TYPE], &tmp);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_CLASS), &tmp);
+ ZVAL_INTERNED_STR(&tmp, ZSTR_KNOWN(ZEND_STR_PAAMAYIM_NEKUDOTAYIM));
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_TYPE), &tmp);
}
if ((options & DEBUG_BACKTRACE_IGNORE_ARGS) == 0 &&
func->type != ZEND_EVAL_CODE) {
debug_backtrace_get_args(call, &tmp);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_ARGS], &tmp);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_ARGS), &tmp);
}
} else {
/* i know this is kinda ugly, but i'm trying to avoid extra cycles in the main execution loop */
@@ -2741,30 +2560,30 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
if (!ptr->func || !ZEND_USER_CODE(ptr->func->common.type) || ptr->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
/* can happen when calling eval from a custom sapi */
- pseudo_function_name = CG(known_strings)[ZEND_STR_UNKNOWN];
+ pseudo_function_name = ZSTR_KNOWN(ZEND_STR_UNKNOWN);
build_filename_arg = 0;
} else
switch (ptr->opline->extended_value) {
case ZEND_EVAL:
- pseudo_function_name = CG(known_strings)[ZEND_STR_EVAL];
+ pseudo_function_name = ZSTR_KNOWN(ZEND_STR_EVAL);
build_filename_arg = 0;
break;
case ZEND_INCLUDE:
- pseudo_function_name = CG(known_strings)[ZEND_STR_INCLUDE];
+ pseudo_function_name = ZSTR_KNOWN(ZEND_STR_INCLUDE);
break;
case ZEND_REQUIRE:
- pseudo_function_name = CG(known_strings)[ZEND_STR_REQUIRE];
+ pseudo_function_name = ZSTR_KNOWN(ZEND_STR_REQUIRE);
break;
case ZEND_INCLUDE_ONCE:
- pseudo_function_name = CG(known_strings)[ZEND_STR_INCLUDE_ONCE];
+ pseudo_function_name = ZSTR_KNOWN(ZEND_STR_INCLUDE_ONCE);
break;
case ZEND_REQUIRE_ONCE:
- pseudo_function_name = CG(known_strings)[ZEND_STR_REQUIRE_ONCE];
+ pseudo_function_name = ZSTR_KNOWN(ZEND_STR_REQUIRE_ONCE);
break;
default:
/* this can actually happen if you use debug_backtrace() in your error_handler and
* you're in the top-scope */
- pseudo_function_name = CG(known_strings)[ZEND_STR_UNKNOWN];
+ pseudo_function_name = ZSTR_KNOWN(ZEND_STR_UNKNOWN);
build_filename_arg = 0;
break;
}
@@ -2780,11 +2599,11 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
ZVAL_STR_COPY(&tmp, include_filename);
zend_hash_next_index_insert_new(Z_ARRVAL(arg_array), &tmp);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_ARGS], &arg_array);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_ARGS), &arg_array);
}
ZVAL_INTERNED_STR(&tmp, pseudo_function_name);
- zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_FUNCTION], &tmp);
+ zend_hash_add_new(Z_ARRVAL(stack_frame), ZSTR_KNOWN(ZEND_STR_FUNCTION), &tmp);
}
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &stack_frame);
@@ -2889,4 +2708,6 @@ ZEND_FUNCTION(get_extension_funcs)
* c-basic-offset: 4
* indent-tabs-mode: t
* End:
+ * vim600: sw=4 ts=4 fdm=marker
+ * vim<600: sw=4 ts=4
*/