-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix bug #31875 - get_defined_functions() should not list disabled fun… #1312
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
Fix bug #31875 - get_defined_functions() should not list disabled fun… #1312
Conversation
Why it is better to not list them? |
|
I don't think this is bug, or something worth to be fixed... it's defined, just disabled.. |
In 2005 when I first created this bug, I think I'd been trying to do some testing of php - and had knocked up a script to do foreach(function) { test } and/or was trying to develop against a locked down hosting companies version of php, and wanted to work out what functions were not available. At the moment, as far as i'm aware, get_defined_functions() is still the only way in php to get a "complete" list of available functions. I'd personally say the expectation for someone calling this function would be that the function would work if it is defined. Otherwise you effectively need to create a get_available_functions ( foreach x in get_defined_functions( if function_exists(x)... for the output to be of any use. @laruence In terms of the "it's defined, just disabled" argument - I think if PHP is compiled with --without-X, that functions belonging to X would not be included in the list of defined functions. Taking your comment to the extreme - if a function is defined, but not compiled in, then it's "just disabled" ;) get_defined_functions — Returns an array of all defined functions I'd expect that given the documentation, the result to be the same for the above functions. However, the notes section on http://php.net/function_exists is confusing: "A function name may exist even if the function itself is unusable due to configuration or compiling options " - is that really the case?? Especially given the example given - to check if imap_open exists to test if IMAP functionality is in PHP. The return statement of RETURN_BOOL(func && (func->type != ZEND_INTERNAL_FUNCTION || func->internal_function.handler != zif_display_disabled_function)); would seem to be designed to negate the need for this comment? |
Disabled functions yet are defined functions. I don't believe this is really a bug. Maybe we can have a |
Or maybe we could have a |
What about introducing extra argument: |
@lubosdz I like it 👍 |
* pull-request/1312: get_defined_functions extra parameter to exclude disabled functions news entry for PR #1312
* PHP-7.0: get_defined_functions additional parameter to exclude disabled functions news entry for PR #1312
Merged d838285 Thanks. |
* PHP-7.1: get_defined_functions additional parameter to exclude disabled functions news entry for PR #1312
…ctions.