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

WordPress Trac noreply at wordpress.org
Fri May 22 06:59:31 UTC 2026


#58291: Speed up WordPress hooks addition/removal by ~20%
---------------------------------------------+--------------------------
 Reporter:  bor0                             |       Owner:  westonruter
     Type:  defect (bug)                     |      Status:  closed
 Priority:  normal                           |   Milestone:  7.1
Component:  Plugins                          |     Version:  6.3
 Severity:  normal                           |  Resolution:  fixed
 Keywords:  has-patch commit has-unit-tests  |     Focuses:  performance
---------------------------------------------+--------------------------
Changes (by westonruter):

 * status:  reviewing => closed
 * resolution:   => fixed


Comment:

 In [changeset:"62408" 62408]:
 {{{
 #!CommitTicketReference repository="" revision="62408"
 Plugins: Improve hook performance by using `spl_object_id()` instead of
 `spl_object_hash()` to construct unique IDs.

 * Also use `spl_object_id()` similarly when registering and unregistering
 classic widgets.
 * Improve typing and phpdoc in `_wp_filter_build_unique_id()`. Return
 `null` for malformed callbacks.
 * Add tests for `_wp_filter_build_unique_id()`.
 * Improve type safety of `WP_Hook::add_filter()` in case an invalid
 callback is provided for parity with `::has_filter()` and
 `::remove_filter()`.

 Developed in https://github.com/WordPress/wordpress-develop/pull/11865
 Follow-up to r46220, r46801, r60179.

 Props bor0, westonruter, SergeyBiryukov, schlessera, arshidkv12, knutsp,
 spacedmonkey, swissspidy.
 See #64898.
 Fixes #58291.
 }}}

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


More information about the wp-trac mailing list