]> granicus.if.org Git - php/commit
Completely remove disabled functions from function table
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 27 Apr 2020 11:17:37 +0000 (13:17 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 30 Apr 2020 07:53:57 +0000 (09:53 +0200)
commit53eee290b6f5ca531aef19885a392c939013ce36
tree1eac8e854e60f39bd3432f92a603f9f0b9d41169
parent8cb237345a50f724aca35133da7155b6bc47d133
Completely remove disabled functions from function table

Currently, disabling a function only replaces the internal
function handler with one that throws a warning, and a few
places in the engine special-case such functions, such as
function_exists. This leaves us with a Schrödinger's function,
which both does not exist (function_exists returns false) and
does exist (you cannot define a function with the same name).
In particular, this prevents the implementation of robust
polyfills, as reported in https://bugs.php.net/bug.php?id=79382:

    if (!function_exists('getallheaders')) {
        function getallheaders(...) { ... }
    }

If getallheaders() is a disabled function, this code will break.

This patch changes disable_functions to remove the functions from
the function table completely. For all intents and purposes, it
will look like the function does not exist.

This also renders two bits of PHP functionality obsolete and thus
deprecated:

 * ReflectionFunction::isDisabled(), as it will no longer be
   possible to construct the ReflectionFunction of a disabled
   function in the first place.
 * get_defined_functions() with $exclude_disabled=false, as
   get_defined_functions() now never returns disabled functions.

Fixed bug #79382.

Closes GH-5473.
22 files changed:
UPGRADING
Zend/tests/bug69315.phpt
Zend/tests/bug79382.phpt [new file with mode: 0644]
Zend/tests/errmsg_020.phpt
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_builtin_functions.c
Zend/zend_builtin_functions.stub.php
Zend/zend_builtin_functions_arginfo.h
Zend/zend_compile.c
ext/opcache/Optimizer/pass1.c
ext/opcache/Optimizer/sccp.c
ext/opcache/Optimizer/zend_func_info.c
ext/opcache/Optimizer/zend_optimizer.c
ext/opcache/Optimizer/zend_optimizer_internal.h
ext/opcache/tests/bug68104.phpt
ext/opcache/tests/bug76796.phpt
ext/reflection/php_reflection.c
ext/reflection/php_reflection.stub.php
ext/reflection/php_reflection_arginfo.h
ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt
tests/basic/bug31875.phpt