[wp-trac] [WordPress Trac] #55711: Introduce a function to determine whether a function can be called.

WordPress Trac noreply at wordpress.org
Fri May 13 00:28:22 UTC 2022


#55711: Introduce a function to determine whether a function can be called.
------------------------------+-----------------------------
 Reporter:  theode            |       Owner:  (none)
     Type:  task (blessed)    |      Status:  new
 Priority:  normal            |   Milestone:  6.1
Component:  General           |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  php8 needs-patch  |     Focuses:  administration
------------------------------+-----------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:8 costdev]:
 > @jrf Well actually... I stand corrected 😂. I spend most of my Core dev
 time on PHP 7.4, so that explains my results. It's surprising to me that
 PHP 7.4 returns a different result for `function_exists()`, but that's a
 discussion for another forum.

 Hmm, I could not reproduce that on PHP 7.4.15. This is what the script
 above returns for me, same as on other PHP 7.x versions:
 {{{
 "PHP 7.4"
 ------------------
 function_exists: false
 is_callable: true
 strpos/str_contains: 0
 }}}

 As previously noted in comment:3:ticket:42085 and
 comment:116:ticket:51857, `function_exists()` can return `true` for
 disabled functions when Suhosin is in use, but I'm not aware of any other
 factors that might cause that:

 > Per the [https://www.php.net/manual/en/function.function-
 exists.php#67947 comments in the PHP manual], `function_exists()` should
 return `false` for functions disabled via `disable_functions` setting.
 >
 > As also noted in comment:3:ticket:42085, it is possible for the
 `function_exists()` check to return `true` if Suhosin is in use. However,
 that would be an edge case, as Suhosin was only officially available for
 PHP 5.4 to 5.6, and its development was discontinued in 2015.
 >
 > It's also worth noting that as of PHP 8, disabled functions can be
 redeclared. Unless the function is redeclared, `function_exists()` still
 returns `false`.
 >
 > It looks like most of the instances in core where we need to check for a
 function that might be disabled just use a simple `function_exists()`
 check.

 So at the moment I'm not sure we need to do anything besides a
 `function_exists()` check here, that seems to be its intended purpose.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55711#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list