-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Completely remove disabled functions from function table #5473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks, I like that very much. Should disable_classes be treated in a similar manner (see also https://bugs.php.net/79516). |
I agree, but the class case will probably have some complications, because we often reference class entries internally. We must make sure that the class entry is not destroyed. |
should |
@staabm Why? ini_get() should return the value it has been set to, as usual. |
oh, then I misread the PR. had the impression the disabled-function mechnics will be removed. fine then. |
@staabm Ooh, yes, I can see where that came from :) Renamed to be a bit more obvious. |
… (derrabus) This PR was merged into the 3.4 branch. Discussion ---------- [VarDumper] ReflectionFunction::isDisabled() is deprecated | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #36872 | License | MIT | Doc PR | N/A See php/php-src#5473. Calling `ReflectionFunction::isDisabled()` is pointless on php 8 and doing so triggers a deprecation warning. Someone who is more familiar with that component might want to have a second look on this PR. I'm not really sure if this is the right way to fix the issue. Commits ------- 1da347e [VarDumper] ReflectionFunction::isDisabled() is deprecated.
…ctionsExcludeDisabledFalse` sniff > Calling `get_defined_functions()` with `$exclude_disabled` explicitly set to > `false` is deprecated. `get_defined_functions()` will never include disabled functions. Refs: * https://github.com/php/php-src/blob/69888c3ff1f2301ead8e37b23ff8481d475e29d2/UPGRADING#L514-L516 * php/php-src#5473 * php/php-src@53eee29 This sniff addresses that change. Includes unit tests.
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
getallheaders()
is a disabled function, this code will break.I don't think it is possible to reconcile this. Making function_exists() return true would fix this case, but would break other cases, that check function_exists() before calling a function.
I think the only way to make this fully consistent is to actually remove the function from the function table. I don't think this has any disadvantages, apart from throwing a more generic error message.
This will make the
ReflectionFunction::isDisabled()
method useless, as it will no longer be possible to create a ReflectionFunction of a disabled function. Similarly, the$exclude_disabled
parameter ofget_defined_functions()
will be hardcoded to true.