[wp-trac] [WordPress Trac] #64180: Simplify and improve performance in `WP_Hook::apply_filters()`

WordPress Trac noreply at wordpress.org
Sat Nov 1 22:31:17 UTC 2025


#64180: Simplify and improve performance in `WP_Hook::apply_filters()`
-------------------------+------------------------------
 Reporter:  grapestain   |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Plugins      |     Version:  6.8.3
 Severity:  minor        |  Resolution:
 Keywords:               |     Focuses:  performance
-------------------------+------------------------------

Comment (by westonruter):

 Hello!

 > Anyway, while looking at it I figured that the best way to "Avoid the
 array_slice()" is to not use it at all. PHP supports passing more
 arguments to functions than what they declare, it is perfectly valid. So
 this code in fact works just the same:

 {{{#!php
 <?php
 $value = call_user_func_array( $the_['function'], $args );
 }}}


 There's a possibility though that this could cause a fatal error, although
 perhaps unlikely. Consider the case where someone tries to use `intval` as
 the callback for a filter that passes more than one argument. This could
 cause the additional filter parameter to be interpreted as being intended
 for the second integer `$base` parameter.

 It's the problem outlined here: https://jakearchibald.com/2021/function-
 callback-risks/

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


More information about the wp-trac mailing list