Skip to content

Commit 5e38a1b

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79668: get_defined_functions(true) may miss functions
2 parents 3911158 + b8e7b30 commit 5e38a1b

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fixed bug #79595 (zend_init_fpu() alters FPU precision). (cmb, Nikita)
77
. Fixed bug #79650 (php-win.exe 100% cpu lockup). (cmb)
8+
. Fixed bug #79668 (get_defined_functions(true) may miss functions). (cmb,
9+
Nikita)
810

911
- PDO SQLite:
1012
. Fixed bug #79664 (PDOStatement::getColumnMeta fails on empty result set).

Zend/tests/bug79668.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #79668 (get_defined_functions(true) may miss functions)
3+
--INI--
4+
disable_functions=sha1_file,password_hash
5+
--FILE--
6+
<?php
7+
$df = get_defined_functions(true);
8+
foreach (['sha1', 'sha1_file', 'hash', 'password_hash'] as $funcname) {
9+
var_dump(in_array($funcname, $df['internal'], true));
10+
}
11+
?>
12+
--EXPECT--
13+
bool(true)
14+
bool(false)
15+
bool(true)
16+
bool(false)

Zend/zend_builtin_functions.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,7 +1810,6 @@ ZEND_FUNCTION(get_defined_functions)
18101810
zend_string *key;
18111811
zend_function *func;
18121812
zend_bool exclude_disabled = 0;
1813-
char *disable_functions = NULL;
18141813

18151814
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &exclude_disabled) == FAILURE) {
18161815
return;
@@ -1820,19 +1819,11 @@ ZEND_FUNCTION(get_defined_functions)
18201819
array_init(&user);
18211820
array_init(return_value);
18221821

1823-
if (exclude_disabled) {
1824-
disable_functions = INI_STR("disable_functions");
1825-
}
18261822
ZEND_HASH_FOREACH_STR_KEY_PTR(EG(function_table), key, func) {
18271823
if (key && ZSTR_VAL(key)[0] != 0) {
1828-
if (func->type == ZEND_INTERNAL_FUNCTION) {
1829-
if (disable_functions != NULL) {
1830-
if (strstr(disable_functions, func->common.function_name->val) == NULL) {
1831-
add_next_index_str(&internal, zend_string_copy(key));
1832-
}
1833-
} else {
1834-
add_next_index_str(&internal, zend_string_copy(key));
1835-
}
1824+
if (func->type == ZEND_INTERNAL_FUNCTION
1825+
&& (!exclude_disabled || func->internal_function.handler != ZEND_FN(display_disabled_function))) {
1826+
add_next_index_str(&internal, zend_string_copy(key));
18361827
} else if (func->type == ZEND_USER_FUNCTION) {
18371828
add_next_index_str(&user, zend_string_copy(key));
18381829
}

0 commit comments

Comments
 (0)