diff options
| -rw-r--r-- | Zend/zend_builtin_functions.c | 8 | ||||
| -rw-r--r-- | tests/basic/bug31875.phpt | 13 | 
2 files changed, 17 insertions, 4 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index dff8f52eda..b94616423e 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1864,6 +1864,7 @@ static int copy_function_name(zval *zv, int num_args, va_list args, zend_hash_ke  	zend_function *func = Z_PTR_P(zv);  	zval *internal_ar = va_arg(args, zval *),  	     *user_ar     = va_arg(args, zval *); +	zend_bool *exclude_disabled = va_arg(args, zend_bool *);  	if (hash_key->key == NULL || hash_key->key->val[0] == 0) {  		return 0; @@ -1872,7 +1873,7 @@ static int copy_function_name(zval *zv, int num_args, va_list args, zend_hash_ke  	if (func->type == ZEND_INTERNAL_FUNCTION) {  		char *disable_functions = INI_STR("disable_functions"); -		if (disable_functions != NULL) { +		if ((*exclude_disabled == 1) && (disable_functions != NULL)) {  			if (strstr(disable_functions, func->common.function_name->val) == NULL) {  				add_next_index_str(internal_ar, zend_string_copy(hash_key->key));  			} @@ -1892,8 +1893,9 @@ static int copy_function_name(zval *zv, int num_args, va_list args, zend_hash_ke  ZEND_FUNCTION(get_defined_functions)  {  	zval internal, user; +	zend_bool exclude_disabled = 0; -	if (zend_parse_parameters_none() == FAILURE) { +	if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &exclude_disabled) == FAILURE) {  		return;  	} @@ -1901,7 +1903,7 @@ ZEND_FUNCTION(get_defined_functions)  	array_init(&user);  	array_init(return_value); -	zend_hash_apply_with_arguments(EG(function_table), copy_function_name, 2, &internal, &user); +	zend_hash_apply_with_arguments(EG(function_table), copy_function_name, 3, &internal, &user, &exclude_disabled);  	zend_hash_str_add_new(Z_ARRVAL_P(return_value), "internal", sizeof("internal")-1, &internal);  	zend_hash_str_add_new(Z_ARRVAL_P(return_value), "user", sizeof("user")-1, &user); diff --git a/tests/basic/bug31875.phpt b/tests/basic/bug31875.phpt index d29b7f1b1b..78085d766b 100644 --- a/tests/basic/bug31875.phpt +++ b/tests/basic/bug31875.phpt @@ -6,7 +6,18 @@ Willian Gustavo Veiga <contact@willianveiga.com>  disable_functions=dl  --FILE--  <?php -var_dump(in_array('dl', get_defined_functions())); +$disabled_function = 'dl'; + +$functions = get_defined_functions(); +var_dump(in_array($disabled_function, $functions['internal'])); + +$functions = get_defined_functions(false); +var_dump(in_array($disabled_function, $functions['internal'])); + +$functions = get_defined_functions(true); +var_dump(in_array($disabled_function, $functions['internal']));  ?>  --EXPECTF-- +bool(true) +bool(true)  bool(false)  | 
