[wp-trac] [WordPress Trac] #58291: Speed up WordPress hooks addition/removal by ~20%

WordPress Trac noreply at wordpress.org
Tue May 19 21:42:48 UTC 2026


#58291: Speed up WordPress hooks addition/removal by ~20%
-------------------------------------------------+-------------------------
 Reporter:  bor0                                 |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  7.1
Component:  Plugins                              |     Version:  6.3
 Severity:  normal                               |  Resolution:
 Keywords:  changes-requested needs-refresh      |     Focuses:
  has-patch                                      |  performance
-------------------------------------------------+-------------------------
Changes (by bor0):

 * keywords:  changes-requested has-patch => changes-requested needs-refresh
     has-patch


Comment:

 Hey @westonruter, thanks!

 I opened this PR: https://github.com/WordPress/wordpress-
 develop/pull/11865

 This is a refreshed version of 58291.5 addressing the feedback from
 comments 7, 12, and 13:

 - Keeps `_wp_filter_build_unique_id()` as a global function in
 `plugin.php` rather than moving to a `private static` method, per
 @schlessera's finding that global function calls are ~2x faster than
 static method calls (comment 12). No deprecation, no BC break.
 - Drops the `spl_object_id` polyfill from `compat.php` since PHP 7.4+ is
 now required (comment 13).
 - Fixes the `@return` tag to `string|int` since `spl_object_id()` returns
 `int` for the direct-object path.
 - Also updates `WP_Widget_Factory::register()` and `unregister()` to use
 `spl_object_id` (comment 9).
 - Removes the stale `if ( ! $function_key )` guard in `has_filter()` as
 agreed in comment 6.

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


More information about the wp-trac mailing list